SRL Archive - SRL Archives

RC.scar


Timer

2008-02-15 00:02:31

Possible "More Advaced" RC.scar?

//----------------------------------------------------------------------------//
//-- Scar Standard Resource Library --//
//-- ยป Remote Control Routines Beta --//
//----------------------------------------------------------------------------//
// * function RCReadCommand: String; // * by WT-Fakawi
// * procedure RCSetNick; // * by WT-Fakawi
// * function RCFindMaster(var Mx, My: Integer; X1, Y1, X2, Y2: Integer): Boolean; // * by WT-Fakawi
// * function RCHowManyOnline: Integer; // * by WT-Fakawi
// * function RCFindFriend: String; // * by WT-Fakawi
// * function RCPrivateMessageColorFound: Boolean; // * by WT-Fakawi
// * function ReturnStatus: String; // * by WT-Fakawi
// * procedure RCResetStatus; // * by WT-Fakawi
// * function RC: Boolean; // * by WT-Fakawi

{ var RCMaster: String;
Description: Master Player (Controller) User Nick. }
var
RCMaster, RCLoc: string;

{ var MasterBitMapMask, RCTimeMark: Integer;
Description: Variables used in the Remote Control include. }
var
MasterBitMapMask: Integer;

const
RCStatus = 'playing'; // commands the RCMaster types.
RCReset = 'try a'; // may be replaced by anything less suspicious
RCStop = 'stop';
RCLogOut = 'logout';
RCll_a = 'll a';//Tell Active
RCll_ina = 'ina';//Tell InActive
RCBreak = 'break';// 5-10Min Break
FPlayer = 'se p';//Turn Player False
TPlayer = 'ue p';//Turn Player True
APlayer = 'dd p';//Add Player During Run Time (I Getz A Run-Time Error... =[)

{*******************************************************************************
function RCReadCommand: String;
by: WT-Fakawi
Description: Returns string of red typed message (color 128)
*******************************************************************************}

function RCReadCommand: string;
var LC:TPoint;
begin
LC:= TextCoords(8);
Result := LowerCase(Trim(GetTextAtEx(LC.x - 2, LC.y - 2, 45, SmallChars, False, False, 0,
2, 128, 45, False, tr_NormalChars)));
end;

{*******************************************************************************
procedure RCSetNick;
by: WT-Fakawi
Description: Creates MasterBitMapMask for recognisition
*******************************************************************************}

procedure RCSetNick;
begin
MasterBitMapMask := CreateBitmapMaskFromText(RCMaster, smallChars);
end;

{*******************************************************************************
function RCFindMaster(var Mx, My: Integer; X1, Y1, X2, Y2: Integer): Boolean;
by: WT-Fakawi
Description: Finds MasterBitMapMask (Master Name) and returns its coordinates
in Mx and My.
Could be usefull also for friend-finding.
*******************************************************************************}

function RCFindMaster(var Mx, My: Integer; X1, Y1, X2, Y2: Integer): Boolean;
begin
Result := FindBitmapMaskTolerance(MasterBitMapMask, Mx, My, X1, Y1, X2, Y2,
50, 10)
end;

{*******************************************************************************
function RCHowManyOnline: Integer;
by: WT-Fakawi
Description: Returns the number of online Friends.
*******************************************************************************}

function RCHowManyOnline: Integer;
var
i, frX, frY, incY: Integer;
begin
for i := 1 to 12 do
begin
if FindColor(frX, frY, 65280, 667, 235 + incY, 672, 243 + incY) or
// green - same world
FindColor(frX, frY, 65535, 667, 235 + incY, 672, 243 + incY) then
// yellow - different world
Result := Result + 1;
incY := incY + 15;
end;
end;

{*******************************************************************************
function RCFindFriend: String;
by: WT-Fakawi
Description: Returns the name of the First Friend in the FriendList
*******************************************************************************}

function RCFindFriend: string;
begin
Result := LowerCase(Trim(GetTextAtEx(556, 231, 45, SmallChars, True, False, 0,
2, 16777215, 20, False, tr_NormalChars)));
end;

{*******************************************************************************
function RCPrivateMessageColorFound: Boolean;
by: WT-Fakawi
Description: Returns True if Color 128 (red) was found in ChatWindow.
*******************************************************************************}

function RCPrivateMessageColorFound: Boolean;
var
dumX, dumY: Integer;
begin
Result := FindColor(dumX, dumY, 128, MCX1, MCY1, MCX2, MCY2);
end;

{*******************************************************************************
function ReturnStatus: String;
by: WT-Fakawi
Description: Returns a concatenated string with the False Player Names.
If you feel this is too suspicious, use Players.nick (recommended)
*******************************************************************************}

function RCReturnStatus: string;
var
i: Integer;
PlayersString: string;
oneFalse: Boolean;

begin
for i := 0 to HowManyPlayers - 1 do
begin
if Players[i].Active = False then
begin
Insert(Players[i].Name, PlayersString, 0);
Insert(' ', PlayersString, 0);
oneFalse := True;
end;
end;
Result := PlayersString;
if not oneFalse then Result := 'Everything is cool.';
WriteFileString(TheFile, TheTime + ' ' + '********** RC STATUS: ' +
PlayersString + Chr(13));
end;

{*******************************************************************************
procedure RCResetStatus;
by: WT-Fakawi
Description: Resets the Status of ALL Players to True
*******************************************************************************}

procedure RCResetStatus;
var
i: Integer;
begin
for i := 0 to HowManyPlayers - 1 do
begin
if Players[i].Active = False then
begin
Players[i].Active := True;
if RCLoc <> '' then
Players[i].Loc := RCLoc;
end;
end;
WriteFileString(TheFile, TheTime + ' ' + '********** RC RESET ' + Chr(13));
end;

{*******************************************************************************
function RC: Boolean;
by: WT-Fakawi
Description: High Level Remote Control Command. Handles Remote Control.
Works as follows:
Checks for existence of red color in chat window.
If red color is found, it checks for the existence of the MasterBitMapMask.
If found it waits 60 seconds for pm "status" or pm "reset".
Then RC sleeps five minutes to get rid of the red text.
*******************************************************************************}

procedure FindATradeByRick; ForWard;
function RC: Boolean;
var
Masx, Masy, RCMark, cp: Integer;
Player: string;
D1: Boolean;
begin
SetChat('on', 1);
SetChat('on', 2);
SetChat('on', 3);
SetChat('on', 4);
SetChat('on', 5);
begin {not Needed 'Begin'}
if RCPrivateMessageColorFound then // check for Color 128
begin
RunControl(False);
Result := True;
MasterBitMapMask := CreateBitmapMaskFromText(RCMaster, smallChars);
SetChat('off', 1);
if RCFindMaster(Masx, Masy, MCX1, MCY1, MCX2, MCY2) then
begin
GameTab(8);
if RCHowManyOnline <> 0 then
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('hi');
MarkTime(RCMark);
repeat // wait 60 secs for command
WriteLn(RCReadCommand);
{if (pos(APlayer, RCReadCommand )<> 0) then
begin
CP := HowManyPlayers + 1;
NumberOfPlayers(CP);
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('Username');
Wait(2000);
while (RCReadCommand = 'Username') or (RCReadCommand = 'username') do Wait(5000);
Player := RCReadCommand;
Players[HowManyPlayers].Name := Player;
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('Pass');
Wait(2000);
while (RCReadCommand = 'Pass') or (RCReadCommand = 'pass') do Wait(5000);
Player := RCReadCommand;
Players[(HowManyPlayers + 1)].Pass := Player;
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('NickName');
Wait(2000);
while (RCReadCommand = 'Nickname') or (RCReadCommand = 'nickname') do Wait(5000);
Player := RCReadCommand;
Players[(HowManyPlayers)].Nick := Player;
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('Location');
Wait(2000);
while (RCReadCommand = 'Location') or (RCReadCommand = 'location') do Wait(5000);
Player := RCReadCommand;
Players[(HowManyPlayers)].Loc := Player;
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('add integers');
Wait(2000);
while (RCReadCommand = 'Add integers') or (RCReadCommand = 'add integers') do Wait(5000);
Player := RCReadCommand;
if pos('yes', Player) <> 0 then
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('how many');
Wait(2000);
while (RCReadCommand = 'How many') or (RCReadCommand = 'how many') do Wait(5000);
Player := RCReadCommand;
cp := StrToInt(Player);
for cp2 := 0 to cp do
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('Integer ' + inttostr(cp2));
Wait(2000);
while (RCReadCommand = 'Number') or (RCReadCommand = 'number') do Wait(5000);
Player := RCReadCommand;
Players[HowManyPlayers].Integers[cp2] := StrToInt(Player);
end;
end;
SetChat('on', 1);
SetChat('on', 1); // hmm lets fix that :)
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;}
if (pos(TPlayer, RCReadCommand )<> 0) then
begin
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('Listening');
Wait(2000);
while (RCReadCommand = 'Listening') or (RCReadCommand = 'listening') do Wait(5000);
Player := RCReadCommand;
for cp := 0 to HowManyPlayers - 1 do
begin
if Player = Players[cp].Name then
begin
D1 := True;
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
Wait(500);
TypeSend(Players[cp].Name + ' is True');
Players[cp].Active := True;
end;
end;
if not D1 then
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('Invalad Player');
end;
SetChat('on', 1);
SetChat('on', 1); // hmm lets fix that :)
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;
if (pos(FPlayer, RCReadCommand )<> 0) then
begin
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('Listening');
Wait(2000);
while (RCReadCommand = 'Listening') or (RCReadCommand = 'listening') do Wait(5000);
Player := RCReadCommand;
for cp := 0 to HowManyPlayers - 1 do
begin
if Player = Players[cp].Name then
begin
D1 := True;
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
Wait(500);
TypeSend(Players[cp].Name + ' is False');
Players[cp].Active := False;
end;
end;
if not D1 then
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('Invalad Player');
end;
SetChat('on', 1);
SetChat('on', 1); // hmm lets fix that :)
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;
if (pos(FPlayer, RCReadCommand )<> 0) then
begin
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend(RCReturnStatus);
SetChat('on', 1);
SetChat('on', 1); // hmm lets fix that :)
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;
if (pos(RCStatus, RCReadCommand )<> 0) then
begin
Wait(1000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend(RCReturnStatus);
SetChat('on', 1);
SetChat('on', 1); // hmm lets fix that :)
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;
if (pos(RCReset, RCReadCommand) <> 0) then
begin
GameTab(8);
Wait(1000 + Random(500));
RCResetStatus;
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('True For ' + IntToStr(HowManyPlayers) + ' Players');
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;
if (pos(RCLogOut, RCReadCommand) <> 0) then
begin
Logout;
FreeBitmap(MasterBitMapMask);
Exit;
end;
if (pos(RCStop, RCReadCommand) <> 0) then
begin
FreeBitmap(MasterBitMapMask);
TerminateScript;
end;
if (pos(RCbreak, RCReadCommand )<> 0) then
begin
repeat
LogOut;
until(Not LoggedIn);
Wait((1000 * 60 * 5) + Random((1000 * 60 * 5)));
LogInPlayer;
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
Exit;
end;
if (pos('ina', RCReadCommand )<> 0) then
begin
GameTab(8);
for cp := 0 to HowManyPlayers - 1 do
begin
if Players[cp].Active = False then
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend(Players[cp].Name);
end;
end;
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
LogOut;
LogInPlayer;
Exit;
end;
if (pos('una', RCReadCommand )<> 0) then
begin
GameTab(8);
for cp := 0 to HowManyPlayers - 1 do
begin
if Players[cp].Active = False then
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend(Players[cp].Name);
end;
end;
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
LogOut;
LogInPlayer;
Exit;
end;
if (pos(RCll_a, RCReadCommand )<> 0) then
begin
GameTab(8);
for cp := 0 to howmanyplayers - 1 do
begin
if Players[cp].Active = True then
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend(Players[cp].Name);
end;
end;
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;
if (pos('rad', RCReadCommand )<> 0) then
begin
FindATradeByRick;
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;
if (pos('loc', RCReadCommand )<> 0) then
begin
for cp := 0 to howmanyplayers - 1 do
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
if Players[Cp].Loc = '' then
begin
TypeSend(Players[cp].Name + ': UnKnown');
end else
TypeSend(Players[cp].Name + ': ' + Players[Cp].Loc);
end;
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;
if (pos('ello', RCReadCommand )<> 0) then
begin
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
TypeSend('Wassup');
Wait(7000 + Random(500));
RCFindMaster(Masx, Masy, MIX1, MIY1, MIX2, MIY2);
Mouse(Masx + 2, Masy + 2, 10, 0, True);
if (pos('nm', RCReadCommand )<> 0) then
TypeSend('same.');
typesend('');
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
LogOut;
LoginPlayer;
Exit;
end;
Wait(1000);
until (TimeFromMark(RCMark) > 60000);
end else
begin
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
LogOut;
LogInPlayer;
Exit;
end;
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
end else
begin
SetChat('on', 1);
SetChat('on', 1);
FreeBitmap(MasterBitMapMask);
LogOut;
LogInPlayer;
Exit;
end;
end;
end; {Not Needed 'end;'}
end;

Harry

2008-02-21 14:41:09

Why do you need
SetChat('on', 1);
SetChat('on', 2);
SetChat('on', 3);
SetChat('on', 4);
SetChat('on', 5);
?

Timer

2008-02-28 18:55:08

Forgot to remove it… lol, it was for personal uses. i added trader / autoer reponder / evry thing in my Cautorespond.scar ;)

Harry

2008-02-28 20:15:38

Oh, I see…

I hope you set the AutoRespond boolean to true :p