PDA

Просмотр полной версии : Script help


sobapi
06.01.2009, 08:18
Hello, i've been starting to work on a simple block CharInfo script, and it works. The problems is that i need to enable it, when i'm in the city and disable it, when i go outside of town. That's the part i can't figure out.

This is the script:

begin
if (FromServer) then begin
if pck[1]=#$03 then
pck:='';
end;
end.

What i'm shooting for is something like this:

When FromClient -> 38 2D 00 69 00 6E 00 73 00 69 00 64 00 65 00 00 00 00 00 00 00 (Say '-inside' in the ALL chat room) -> enable script

When FromClient -> 38 2D 00 6F 00 75 00 74 00 73 00 69 00 64 00 65 00 00 00 00 00 00 00 (Say '-outside' in the ALL chat room) -> disable script


I can't figure out how to easily do it.

QaK
06.01.2009, 13:00
sobapi, try this
var BS:bolean;

procedure INIT;
begin bs:=false;//default - block charinfo is false;
end;

begin
if (fromclient) and (pck=Hstr('38 2D 00 69 00 6E 00 73 00 69 00 64 00 65 00 00 00 00 00 00 00') then bs:=true;

if (fromclient) and (pck=Hstr('38 2D 00 6F 00 75 00 74 00 73 00 69 00 64 00 65 00 00 00 00 00 00 00') then bs:=false;

if (FromServer) and (bs) and (pck[1]=#$03) then
pck:='';
end;
end.

sobapi
06.01.2009, 20:21
Oh man, i owe you big time! It worked as a charm. Claps for you.

Now, and this is just for me to educate, i don't know why, but i had to change some tiny things. Maybe is my version of phx (3.1.8):

In green bolded the things i had to add:

var BS:boolean;//----> i had to change bolean to boolean

procedure INIT;
begin bs:=false;//default - block charinfo is false;
end;

begin
if (fromclient) and (pck=Hstr('38 2D 00 69 00 6E 00 73 00 69 00 64 00 65 00 00 00 00 00 00 00')) then bs:=true;//-----> I had to type that second close bracket.

if (fromclient) and (pck=Hstr('38 2D 00 6F 00 75 00 74 00 73 00 69 00 64 00 65 00 00 00 00 00 00 00')) then bs:=false;//-----> I had to type that second close bracket.

if (FromServer) and (bs) and (pck[1]=#$03) then begin//------> i had to add that begin sentence.
pck:='';
end;

end.

Let me break this down, and see if i understood:

You used that Boolean sentence as a on/off switch. You turn it on with the first package (-inside) and you turn it off with the second one (-outside).

And then you use that switch in the "if" to start the script.


Thanks you again man. I'm learning slow, but i'll get there :D

QaK
06.01.2009, 22:53
i had to change bolean to booleanoops
begin//------> i had to add that begin sentence.
* * * * * * * * * * * * * * pck:='';
* * * * * * * * * * * * * * end; double oops =)
i wrote this script for 5 minutes,so i didn't check this in PHK.
Thanks you again man.You wellcome =)