SRL Archive - Outdated Tutorials

How to use MultiPlayer to base your script on


Killerdou

2007-06-11 09:52:08

Guide to use multiplayer as the base of your script!
Things you will have to know before you can use this guides
- variables, constants, functions, procedures and standards
- basic knowledge about NextPlayer(True/False), DeclarePlayers and the Players array

Now to begin with, we are going to make a new procedure:

Procedure ChangeLocation(Location : String);
begin
Players[CurrentPlayer].loc := Location;
end;
This is not neccesary, but it makes your script look better.
Let me introduce you to some anti random functions from Wizzup? and WT-Fakawi, these
will be used to check for randoms while we wait for our character to log out.

Function FindFastRandoms: Boolean; // Credits to WT-Fakawi.
var
i: Integer;
begin
for i:=1 to 10 do
begin
case I of
1: If FindDead then
Result := True;
2: If FindMod then
Result := True;
3: If FindMime then
Result := True;
4: If FindMaze then
Result := True;
5: If FindQuiz then
Result := True;
6: If FindDemon then
Result := True;
7: if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
8 : If RC Then Result := True;

9: If FindTalk Then Result := True;

10: If HandleTrade Then Result := True;
End;
Wait(1);
end;
end;

//Credits to Wizzup?.

Function ScanMiniMap(iFrom, iTo, Distance: Integer): Integer;

Var
I, iX,iY: Integer;
Begin
For I := iFrom To ITo Do
Begin
iX := Round(Distance * Sin(I * Pi / 180)) + 648;
iY := Round(-Distance * Cos(I * Pi / 180)) + 80;
If GetColor(iX, iY) = 0 Then
Begin
Result := Result + 1;
End;
End;
End;

Function FindNormalRandomsTimeEx: Boolean;

Var
TempTime, Time1, Time2: LongInt;

Begin
TempTime := GetSystemTime;
If TempTime - NormalRandomsTime > 6000 Then
Begin
NormalRandomsTime := GetSystemTime;
Time1 := GetSystemTime;
Result := FindNormalRandoms;
Time2 := GetSystemTime;
Status('Calling FNRandoms; Took '+IntToStr(Time2-Time1)+'.');
Exit;
End;

If TempTime - FastRandomsTime > 2000 Then
Begin
FastRandomsTime := GetSystemTime;
Time1 := GetSystemTime;
Result := FindFastRandoms;
Time2 := GetSystemTime;
Status('Calling FFRandoms; Took '+IntToStr(Time2-Time1)+'.');
Exit;
End;

If TempTime - FindTalkTime > 500 Then
Begin
FindTalkTime := GetSystemTime;
Time1 := GetSystemTime;
Result := FindTalk;
Time2 := GetSystemTime;
Status('Calling FT; Took '+IntToStr(Time2-Time1)+'.');
Exit;
End;
End;
//End Credits to Wizzup?.
As to what this actually does is of no importance to this guide.
Now we need to put these functions together into a logout procedure:

Procedure WaitLogout; // Thanks to Wizzup?.
begin
Repeat
FindNormalRandomsTimeEx;
Wait(10);
If TimeFromMark(MyMark) > 240000 Then Begin Logout; Break; End;
Until Not LoggedIn;
end;
What this does is logout for us, and hopefully without having to press the logout
button, which sends some information to Jagex which can be used to get your acount banned.
The next thing to do is make a player switcher:

Procedure SwitchPlayer(KeepPlayerActive : Boolean);
begin
WaitLogout;//the logout we just made
NextPlayer(KeepPlayerActive);
//here you can add the setup such as dochats or check for axe colors and autocolor functions
//can go here aswell. this is actually the reason why this procedure is made.
end;

At this point we are going to put everything togetter.

Repeat
If (LoggedIn) and (Loads mod NumberOfLoads = 0) and (Loads <> 0) then SwitchPlayer(True);// change this
//so it will switchplayer when a player is done and it is time for a next player to start
If Players[CurrentPlayer].loc = 'StuffToDo' then DoStuff;//change this to something that actually describes what you do
If Players[CurrentPlayer].loc = 'DoneStuff' then WalkToSomewhere;
If Players[CurrentPlayer].loc = 'AtSomeWhere' then DoSomethingElse;
If Players[CurrentPlayer].loc = 'DoneSomethingElse' then WalkBack;
If not LoggedIn then SwitchPlayer(False);//switches when a player is found to be logged out and deactivates that player
until not Players[CurrentPlayer].Active;//stops the loop when all players are inactive

If you put all of this togetter you get this:

{.include SRL/SRL.scar}
{.include SRL/SRL/misc/trade.scar}

//setup
const
NumberOfUsers = 6;
NumberOfLoads = 10;

Var
StartPlayer, Loads, NormalRandomsTime, FastRandomsTime, FindTalkTime, MyMark, FallyBuildingColor : integer;

Procedure DeclarePlayers;
Begin
StartPlayer := 1
NumberOfPlayers( NumberOfUsers );
CurrentPlayer := StartPlayer;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Loc :='StuffToDo';
Players[0].Active:=True;

Writeln( IntToStr ( NumberOfUsers ) + ' Players' );
End;



Procedure SetupScript;//everyone should understand what this does
begin
ActivateClient;
SetupSRL;
DeclarePlayers;
Wait(100);
end;


Procedure ChangeLocation(Location:string);
begin
Players[CurrentPlayer].Loc := Location;
end;


Function FindFastRandoms: Boolean; // Credits to WT-Fakawi.
var
i: Integer;
begin
for i:=1 to 10 do
begin
case I of
1: If FindDead then
Result := True;
2: If FindMod then
Result := True;
3: If FindMime then
Result := True;
4: If FindMaze then
Result := True;
5: If FindQuiz then
Result := True;
6: If FindDemon then
Result := True;
7: if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
8 : If RC Then Result := True;

9: If FindTalk Then Result := True;

10: If HandleTrade Then Result := True;
End;
Wait(1);
end;
end;

//Credits to Wizzup?.

Function ScanMiniMap(iFrom, iTo, Distance: Integer): Integer;

Var
I, iX,iY: Integer;
Begin
For I := iFrom To ITo Do
Begin
iX := Round(Distance * Sin(I * Pi / 180)) + 648;
iY := Round(-Distance * Cos(I * Pi / 180)) + 80;
If GetColor(iX, iY) = 0 Then
Begin
Result := Result + 1;
End;
End;
End;

Function FindNormalRandomsTimeEx: Boolean;

Var
TempTime, Time1, Time2: LongInt;

Begin
TempTime := GetSystemTime;
If TempTime - NormalRandomsTime > 6000 Then
Begin
NormalRandomsTime := GetSystemTime;
Time1 := GetSystemTime;
Result := FindNormalRandoms;
Time2 := GetSystemTime;
Status('Calling FNRandoms; Took '+IntToStr(Time2-Time1)+'.');
Exit;
End;

If TempTime - FastRandomsTime > 2000 Then
Begin
FastRandomsTime := GetSystemTime;
Time1 := GetSystemTime;
Result := FindFastRandoms;
Time2 := GetSystemTime;
Status('Calling FFRandoms; Took '+IntToStr(Time2-Time1)+'.');
Exit;
End;

If TempTime - FindTalkTime > 500 Then
Begin
FindTalkTime := GetSystemTime;
Time1 := GetSystemTime;
Result := FindTalk;
Time2 := GetSystemTime;
Status('Calling FT; Took '+IntToStr(Time2-Time1)+'.');
Exit;
End;
End;
//End Credits to Wizzup?.

Procedure WaitLogout; // Thanks to Wizzup?.
begin
Repeat
FindNormalRandomsTimeEx;
Wait(10);
If TimeFromMark(MyMark) > 240000 Then Begin Logout; Break; End;
Until Not LoggedIn;
end;


Procedure SwitchPlayer(KeepPlayerActive : Boolean);
begin
WaitLogout;//the logout we just made
NextPlayer(KeepPlayerActive);
//here you can add the setup such as dochats or check for axe colors and autocolor functions
//can go here aswell. this is actually the reason why this procedure is made.
end;

Procedure DoStuff;
begin
If not LoggedIn then exit;
ChangeLocation('DoneStuff');
end;

Procedure WalkToSomewhere;
begin
If not LoggedIn then exit;
ChangeLocation('AtSomewhere');
end;

Procedure DoSomethingElse;
begin
If not LoggedIn then exit;
ChangeLocation('DoneSomethingElse');
end;

Procedure WalkBack;
begin
If not LoggedIn then exit;
ChangeLocation('StuffToDo');
end;


begin
SetupScript;
Repeat
If (LoggedIn) and (Loads mod NumberOfLoads = 0) and (Loads <> 0) then SwitchPlayer(True);// change this
//so it will switchplayer when a player is done and it is time for a next player to start
If Players[CurrentPlayer].loc = 'StuffToDo' then DoStuff;//change this to something that actually describes what you do
If Players[CurrentPlayer].loc = 'DoneStuff' then WalkToSomewhere;
If Players[CurrentPlayer].loc = 'AtSomeWhere' then DoSomethingElse;
If Players[CurrentPlayer].loc = 'DoneSomethingElse' then WalkBack;
If not LoggedIn then SwitchPlayer(False);//switches when a player is found to be logged out and deactivates that player
until not Players[CurrentPlayer].Active;
end.


Optionally you can put this as your default scar file, there is a tut on that somewhere…

Well this was my first tutorial, so please dont be to harsh on me and i hope you enjoyed it

—Iloveit8—

Stevee

2007-06-23 03:53:55

i think it was greatm a good scar template, especially since none will hafta worry about randoms cuz of yoru script!!!. now all u need to do is implement some autoresponders(autotalker is sooooo gay) and you'll be set!!! il add some rep if u do that as well.

Killerdou

2007-06-24 09:53:21

you still need to use other randoms, as it only checks for randoms while logging out, and there is absolutely no need for an autotalker… and i dont care about rep… i think no one actually cares about rep on this forum, but thanks for your reply:)

lordsaturn

2007-08-07 17:24:19

Thanks. Very helpful.