SRL Archive - Research & Development Lounge

GameTab 10 Functions! (Clan chat)


Floor66

2008-12-06 08:41:06

UPDATE: Shortened all functions in. Removed TPA's, they were unnecessary because of STATIC (non-changing) colours!


My custom made GameTab 10 functions!
To use these you must open your GameTab.scar and look for:
InStrArrEx

Around that is:
Function InStrArrEx(S: String; StrArr: TStringArray; Var Where: Integer): Boolean; forward;
function CloseWindow: Boolean; forward;
function ClickContinue(Click, Wait: Boolean): Boolean; forward;

Change that to:
Function InStrArrEx(S: String; StrArr: TStringArray; Var Where: Integer): Boolean; forward;
function CloseWindow: Boolean; forward;
function ClickContinue(Click, Wait: Boolean): Boolean; forward;
Procedure TypeSend(Text: String); forward;

Then
Paste the code below underneath the corresponding section in GameTab.scar

//****************************************************************************//
// * GameTab 10 Related Functions.
//****************************************************************************//

{*******************************************************************************
Function InClanChat: Boolean;
By: Floor66
Description: Checks if we are in a Clan Chat
*******************************************************************************}

Function InCC: Boolean;
Begin
If GetCurrentTab <> 10 Then GameTab(10);
Result := Not FindTextTpa(39935, 0, MIX1, MIY1, MIX2, MIY2, 'ot in chat', 3, Nothing);
End;

{*******************************************************************************
Procedure LeaveCC;
By: Floor66
Description: Leaves the current Clan Chat
*******************************************************************************}

Function LeaveCC: Boolean;
Var
x, y, t : Integer;
Begin
If GetCurrentTab <> 10 Then GameTab(10);
If FindTextTpaEx(39935, 0, MIX1, MIY1, MIX2, MIY2, x, y, 'eave', 3, Nothing) Then
Begin
Mouse(x, y+10, 7, 7, True);
MarkTime(t);
While Not InCC Do
Begin
Wait(50+Random(100));
If TimeFromMark(t) > 10000 Then
Begin
Result := False;
Exit;
End;
End;
Result := True;
End;
End;

{*******************************************************************************
Function JoinCC(Username: String; LeaveIfIn: Boolean): Boolean;
By: Floor66
Description: Joins the specified Clan Chat
Example: JoinCC('zezima', True);
Will go out of current chat and join 'zezima'

Example2: JoinCC('zezima', False);
Will quit if we're already inside a chat
*******************************************************************************}

Function JoinCC(Username: String; LeaveIfIn: Boolean): Boolean;
Var
x, y, T, T2 : Integer;
Begin
If GetCurrentTab <> 10 Then GameTab(10);
Case LeaveIfIn Of
True: If InCC Then LeaveCC;
False: If InCC Then Exit;
End;
MarkTime(T2);
While InCC Do
Begin
Wait(50+Random(25));
If TimeFromMark(T2) > 10000 Then
Begin
Result := False;
Exit;
End;
End;
If FindTextTpaEx(39935, 10, MIX1, MIY1, MIX2, MIY2, x, y, 'oin', 3, Nothing) Then
Begin
Mouse(x, y, 7, 7, True);
End;
While Not FillIn Do Wait(50+random(25));
TypeSend(Username);
MarkTime(T);
While Not InCC Do
Begin
Wait(50+Random(100));
If TimeFromMark(T) > 10000 Then
Begin
Result := False;
Break;
Exit;
End;
End;
Result := True;
End;

Procedure TypeSendCC(Txt: String);
Begin
If Not InCC Then Exit;
TypeSend('/'+ Txt);
End;

Sandstorm

2008-12-06 11:06:09

Both InClanChat were longer then needed I believe, do something like this:

Function InClanChat: Boolean;
Var
I : Integer;
TPA : TPointArray;
Begin
FindColorsTolerance(TPA, 6619135, MIX1, MIY1, MIX2, MIY2, 1);
For I := 0 To High(TPA) Do
Begin
Result := (GetColor(TPA[i].x, TPA[i].y) = 6619135)
If Result then
Exit;
End;
End;

For both of them. That should work. Beyond that, nice functions.

Naum

2008-12-06 11:14:07

Function InClanChat: Boolean;
Var
I, L : Integer;
TPA : TPointArray;
Begin
FindColorsTolerance(TPA, 6619135, MIX1, MIY1, MIX2, MIY2, 1);
L := High(TPA);
For I := 0 To L Do
Begin
If (GetColor(TPA[i].x, TPA[i].y) = 6619135) Then
Begin
Result := True;
Exit;
End;
End;
End;


could be shotened to:

Function InClanChat: Boolean;
Var
I, L : Integer;
TPA : TPointArray;
Begin
FindColorsTolerance(TPA, 6619135, MIX1, MIY1, MIX2, MIY2, 1);
For I := 0 To High(TPA) Do
Begin
Result := GetColor(TPA[i].x, TPA[i].y) = 6619135;
Exit;
End;
End;

Why not use a simple get color, If the colors are static?

Floor66

2008-12-06 11:15:25

True, wasn't 100% mindclear when I made this lolz :P

Sandstorm

2008-12-06 11:23:02

From: NaumanAkhlaQ
Function InClanChat: Boolean;
Var
I, L : Integer;
TPA : TPointArray;
Begin
FindColorsTolerance(TPA, 6619135, MIX1, MIY1, MIX2, MIY2, 1);
L := High(TPA);
For I := 0 To L Do
Begin
If (GetColor(TPA[i].x, TPA[i].y) = 6619135) Then
Begin
Result := True;
Exit;
End;
End;
End;


could be shotened to:

Function InClanChat: Boolean;
Var
I, L : Integer;
TPA : TPointArray;
Begin
FindColorsTolerance(TPA, 6619135, MIX1, MIY1, MIX2, MIY2, 1);
For I := 0 To High(TPA) Do
Begin
Result := GetColor(TPA[i].x, TPA[i].y) = 6619135;
Exit;
End;
End;

Why not use a simple get color, If the colors are static?


Lol, Naum, I beat you to it. Also, that would exit after the first try whether it's true or not.


If Result Then
Exit;

Floor66

2008-12-06 11:32:29


{*******************************************************************************
Function InClanChat: Boolean;
By: Floor66
Description: Checks if we are in a Clan Chat
*******************************************************************************}

Function InClanChat: Boolean;
Var
I, L : Integer;
Begin
Result := (GetColor(645, 272) = 65280);
End;

Static colors ftw :p

Sandstorm

2008-12-06 11:36:52

Function InClanChat: Boolean;
Begin
Result := (GetColor(645, 272) = 65280);
End;

Lol.

Floor66

2008-12-06 11:40:56

EDIT:
Shortened all functions, static colours ftw :p