SRL Archive - SRL Archives

Chat.scar SetChat(); Fixed


Coh3n

2010-02-18 02:24:16

Well, the current one doesn't work when you want to turn a chat type off because the 'ff' text can't be found (I posted about that bug a while ago, but I don't think anything could have been done). I tried messing around with font bitmap, but had no luck, so I fixed SetChat. I also added constants as you'll see, and made the function return a boolean.

Old

{*******************************************************************************
procedure SetChat(state: String; chat: Integer);
By: Wizzup?, WT-Fakawi, Starblaster100 & N1ke!
Description: Sets Chat to desired state
Chat: Game Public Private Clan Trade Assist
0 1 2 3 4 5
*******************************************************************************}
procedure SetChat(state: string; chat: Integer);
var
x, y, mx, Color: Integer;
begin
case chat of
0: mx := 90;
1: mx := 145;
2: mx := 200;
3: mx := 260;
4: mx := 320;
5: mx := 373;
else
begin
srl_Warn('SetChat', 'chat(' + IntToStr(chat) + ') does not exist.', warn_AllVersions);
Exit;
end;
end;
State := LowerCase(State);
case State of
'on', 'all': Color := 65280;
'off': Color := 255;
'hide': Color := 16776960;
'friends', 'filter': Color := 65535;
else srl_Warn('SetChat', state + ' does not exist.', warn_AllVersions);
end;
State := Capitalize(State);
if not FindColor(x, y, Color, mx - 10, 486, mx + 10, 506) then
begin
Mouse(mx, 496, 8, 8, False);
Wait(450 + Random(175));
ChooseOption(State);
end;
end;

New

const
CHAT_GAME = 0;
CHAT_PUBLIC = 1;
CHAT_PRIVATE = 2;
CHAT_CLAN = 3;
CHAT_TRADE = 4;
CHAT_ASSIST = 5;

{*******************************************************************************
procedure SetChat(state: String; chat: Integer);
By: Wizzup?, WT-Fakawi, Starblaster100, N1ke! & Coh3n
Description: Sets Chat to desired state
Chat: Game Public Private Clan Trade Assist
0 1 2 3 4 5
*******************************************************************************}
function SetChat(state: string; chat: Integer): Boolean;
var
x, y, mx, Color: Integer;
begin
mx := 90 + (chat * 55);

if (not InRange(chat, CHAT_GAME, CHAT_ASSIST) then
begin
srl_Warn('SetChat', 'chat(' + IntToStr(chat) + ') does not exist.', warn_AllVersions);
Exit;
end;

case Lowercase(State) of
'on', 'all': Color := 65280;
'off': Color := 255;
'hide': Color := 16776960;
'friends', 'filter': Color := 65535;
else
srl_Warn('SetChat', state + ' does not exist.', warn_AllVersions);
end;

if (not FindColor(x, y, Color, mx - 10, 486, mx + 10, 506)) then
begin
Mouse(mx, 496, 4, 4, False);
Wait(RandomRange(50, 150));

if (Lowercase(State) = 'off') then
begin
case chat of
CHAT_PUBLIC: Mouse(mx, 496 - 33, 8, 3, True);
CHAT_PRIVATE..CHAT_ASSIST: Mouse(mx, 496 - 20, 8, 3, True);
end;

Wait(RandomRange(50, 150));
Result := FindColor(x, y, Color, mx - 10, 486, mx + 10, 506);
end else
Result := WaitOption(Capitalize(State), 300);
end;
end;
I did test 15-20 times turning the chats on/off/etc, so it does work. :)

Comments?

Sir R. M8gic1an

2010-02-18 03:43:41

Lovely.

~RM

Naum

2010-02-18 05:16:21

Couldn't this:

  case chat of
CHAT_GAME: mx := 90;
CHAT_PUBLIC: mx := 145;
CHAT_PRIVATE: mx := 200;
CHAT_CLAN: mx := 260;
CHAT_TRADE: mx := 320;
CHAT_ASSIST: mx := 373;
else

Be:

mx := 90 + (Chat * 55);

Or would that mess everything up?

Wanted

2010-02-18 10:52:05

Meh, chat is outdated all together… I've never really liked it.

I've been using this in my scripts

{*******************************************************************************
function CurrentChat: string;
By: IceFire908
Description: Returns the current chat you have open.
*******************************************************************************}

function CurrentChat: string;
var
Ch: TStringArray;
M: TPoint;
I: Byte;
begin
Result := 'unknown';
GetMousePos(M.X, M.Y);
if (PointInBox(M, IntToBox(3, 481, 404, 503))) then
MMouse(M.X, M.Y - 33, 5, 5);
for I := 0 to 6 do
if (GetColor(9 + (57 * I), 484) <> 5399409) then
Break;
Ch := ['all', 'game', 'public', 'private', 'clan', 'trade', 'assist'];
if (not (InRange(I, 0, 6))) then
Exit;
Result := Ch[I];
end;

{*******************************************************************************
function CurrentChatStatus(Chat: string): string;
By: IceFire908
Description: Returns the current chat status.
*******************************************************************************}

function CurrentChatStatus(Chat: string): string;
var
St, Ch: TStringArray;
C: TIntegerArray;
M, T: TPoint;
I: Integer;
II: Byte;
S: TBox;
begin
Result := 'unknown';
GetMousePos(M.X, M.Y);
if (PointInBox(M, IntToBox(3, 481, 404, 503))) then
MMouse(M.X, M.Y - 33, 5, 5);
if (LowerCase(Chat) = 'all') then
begin
if (CurrentChat = 'all') then
Result := 'on'
else
Result := 'off';
Exit;
end;
C := [65280, 65535, 255, 16776960]
St := ['on', 'friends', 'off', 'hide'];
Ch := ['game', 'public', 'private', 'clan', 'trade', 'assist'];
if (not (InStrArrEx(LowerCase(Chat), Ch, I))) then
Exit;
S := IntToBox(71 + (57 * I), 492, 107 + (57 * I), 501);
T := Point((S.X1 + S.X2) div 2, (S.Y1 + S.Y2) div 2);
for II := 0 to 3 do
if (FindColorSpiral(T.X, T.Y, C[II], S.X1, S.Y1, S.X2, S.Y2)) then
if ((Ch[I] = 'game') and (C[II] = 65535)) then
Result := 'filter'
else
if ((Ch[I] = 'game') and (C[II] = 65280)) then
Result := 'all'
else
Result := St[II];
end;

{*******************************************************************************
function SetChatEx(Chat, Status: string): Boolean;
By: IceFire908
Description: Sets the chat to desired status.
*******************************************************************************}

function SetChatEx(Chat, Status: string): Boolean;
var
Ch: TStringArray;
Cha, Sta: string;
C, M: TPoint;
I: Integer;
begin
GetMousePos(M.X, M.Y);
if (PointInBox(M, IntToBox(3, 481, 404, 503))) then
MMouse(M.X, M.Y - 33, 5, 5);
Cha := LowerCase(Chat);
Sta := LowerCase(Status);
Result := (CurrentChatStatus(Cha) = Sta);
if (Result) then
Exit;
Ch := ['all', 'game', 'public', 'private', 'clan', 'trade', 'assist'];
if (not (InStrArrEx(Cha, Ch, I))) then
Exit;
C := Point(33 + (56 * I), 492);
if (((Cha = 'all') and (Sta = 'on')) or (Sta = 'view')) then
begin
if (not (CurrentChat = Cha)) then
Mouse(C.X, C.Y, 5, 5, True);
Result := True;
Exit;
end;
Mouse(C.X, C.Y, 5, 5, False);
Wait(200 + Random(100));
Result := ChooseOption(Capitalize(Status));
end;

Coh3n

2010-02-18 13:51:56

From: Rasta Magician
Lovely.

~RM

Well thank you. :p

From: Naum
Couldn't this:

  case chat of
CHAT_GAME: mx := 90;
CHAT_PUBLIC: mx := 145;
CHAT_PRIVATE: mx := 200;
CHAT_CLAN: mx := 260;
CHAT_TRADE: mx := 320;
CHAT_ASSIST: mx := 373;
else

Be:

mx := 90 + (Chat * 55);

Or would that mess everything up?


No, that would work. I just replaced the numbers with constants. Didn't even look at the values.


From: IceFire908
Meh, chat is outdated all together… I've never really liked it.

It shouldn't be now. ;) Although I didn't look through the rest of the functions. Just the SetChat ones.

ZephyrsFury

2010-03-05 06:08:53

I don't think this ever got added so I'm adding it now. Thanks Cohen. :)

Coh3n

2010-03-05 08:54:30

From: ZephyrsFury
I don't think this ever got added so I'm adding it now. Thanks Cohen. :)

No problem. :)

RAM

2010-03-07 21:03:01

Were there some recent changes to Chat.Scar that causes the AutoResponders to reply to themselves ? I'm using Masterkill's SARS…

Coh3n

2010-03-07 23:39:24

From: RAM
Were there some recent changes to Chat.Scar that causes the AutoResponders to reply to themselves ? I'm using Masterkill's SARS…

Not sure, the only I changed was the SetChats procedure.