SRL Archive - Senior Scripts and Snippets

new setchat


Dark_Sniper

2007-05-29 16:36:11

Procedure ChatSet(ChatType : String; ChatBox : Integer);
var
color, T : Integer;
begin
Case LowerCase(ChatType) of
'hide' : Color := 16776960;
'off' : Color := 255;
'friend' : Color := 65535;
'on' : Color := 65280;
end;
if ChatBox <= 3 then
ChatBox:= 38 + 135 * (ChatBox - 1);
if findcolor(x, y, color, chatbox, 484, chatbox+15, 484+15) then
Exit;
repeat
Mouse(ChatBox, 480, 15, 15, true)
wait(100+random(100))
T:=T + 1;
until(findcolor(x, y, color, chatbox, 484, chatbox+15, 484+15)) or (T > 5)
end;

also as a function:

Function ChatSet(ChatType : String; ChatBox : Integer) : Boolean;
var
color, T : Integer;
begin
Result:=True;
Case LowerCase(ChatType) of
'hide' : Color := 16776960;
'off' : Color := 255;
'friend' : Color := 65535;
'on' : Color := 65280;
end;
if ChatBox <= 3 then
ChatBox:= 38 + 135 * (ChatBox - 1);
if findcolor(x, y, color, chatbox, 484, chatbox+15, 484+15) then
Exit;
repeat
Mouse(ChatBox, 480, 15, 15, true)
wait(100+random(100))
T:=T + 1;
until(findcolor(x, y, color, chatbox, 484, chatbox+15, 484+15)) or (T > 5)
if T >= 5 then
Result:=False;
end;




ok works every time and 4x shorter.


compared to:

procedure SetChat(state: string; chat: Integer);
var
x, y, setx, sety, C: Integer;
begin
setx := 55 + ((chat - 1) * 135);
sety := 490;
State := Lowercase(State);
case State of
'hide' :
if chat = 1 then
begin
while not(FindColor(x, y, 16776960, setx - 10, sety - 10, setx + 10, sety + 10))
do
begin
if (C > 9) then Break;
Mouse(setx, sety, 5, 5, True);
Wait(900 + Random(200));
C := C + 1;
end;
end else
Writeln('You can only set Public Chat to hide!');
'on' :
while not(FindColor(x, y, 65280, setx - 10, sety - 10, setx + 10, sety + 10))
do
begin
if (C > 9) then Break;
Mouse(setx, sety, 5, 5, True);
Wait(900 + Random(200));
C := C + 1;
end;
'friends' :
while not(FindColor(x, y, 65535, setx - 10, sety - 10, setx + 10, sety + 10))
do
begin
if (C > 9) then
Break;
Mouse(setx, sety, 5, 5, True);
Wait(900 + Random(200));
C := C + 1;
end;
'off' :
while not(FindColor(x, y, 255, setx - 10, sety - 10, setx + 10, sety + 10))
do
begin
if (C > 9) then Break;
Mouse(setx, sety, 5, 5, True);
Wait(900 + Random(200));
C := C + 1;
end;
else
WriteLn('SetChat - Incorrect State! Possible values: Hide, On, Friends, Off');
end;
end;

Spky

2007-05-29 17:26:41

Nice work ;).


Case ChatBox of
1: ChatBox:=38;
2: Chatbox:=38+135;
3: ChatBox:=38+(135*2);
end;

Could be something like


if ChatBox <= 3 then
ChatBox:= 38 + 135 * (ChatBox - 1);

I just can't help myself..

Smartzkid

2007-05-29 17:34:15

:p Nice

Just wondering, why did you make that if the other one works fine? Boredom?

Dark_Sniper

2007-05-29 17:35:35

no i made it way back when it did not work that good for me.

and yes i know i could have done that but i just did a case of statement so that was fresh in my mind atm :p

tarajunky

2007-05-29 18:14:09

Good job.

Procedure ChatSet(ChatBox : Integer; ChatType : String);
procedure SetChat(state: string; chat: Integer);

You should probably switch the two options around to match the previous version. String then Integer. That would make it backward compatible and it could be pasted directly in as an optimization to SetChat.

Dark_Sniper

2007-05-30 00:56:14

i was going to do that.

and ill shorten the code just a bit.