SRL Archive - OSR Help

main loop help


Le Jingle

2012-08-01 01:42:33

My main problem is, how to alternate a script between 2 players, whilst using the 6 hour fix too. Here's an example of what I'm trying to accomplish.

begin
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
ObjDTM_Setup;
SRL_Procs[SRL_OnFindRandom] := @Little_Logout;//simple proc to logout b/c we shouldn't get random events
script_setup;
repeat
repeat
if not LoggedIn then
smooth_login;
if rs_update then
break_until_pass; //nifty on weekly updates

dowork;
dowork1;
Wait(20+random(10));
doprog; //6hr, 15min
until(gettimerunning>=22500000) or (not loggedin);
NextPlayer(True); {*???}
until((count = need_number));
end.
So, if I start the script with player 0, then would nextplayer(true) keep switching from 0 to 1, then 1 to 0, etc.? Or would I need to somehow use SwitchToPlayer, or something more modified of SwitchToPlayer, or something else? Any advice/input/feedback very welcomed!

Getdropped

2012-08-01 01:48:51

From: Le Jingle
My main problem is, how to alternate a script between 2 players, whilst using the 6 hour fix too. Here's an example of what I'm trying to accomplish.

begin
SRL_SixHourFix := True;
Smart_FixSpeed := True;
SetupSRL;
ObjDTM_Setup;
SRL_Procs[SRL_OnFindRandom] := @Little_Logout;//simple proc to logout b/c we shouldn't get random events
script_setup;
repeat
repeat
if not LoggedIn then
smooth_login;
if rs_update then
break_until_pass; //nifty on weekly updates

dowork;
dowork1;
Wait(20+random(10));
doprog; //6hr, 15min
until(gettimerunning>=22500000) or (not loggedin);
NextPlayer(True); {*???}
until((count = need_number));
end.
So, if I start the script with player 0, then would nextplayer(true) keep switching from 0 to 1, then 1 to 0, etc.? Or would I need to somehow use SwitchToPlayer, or something more modified of SwitchToPlayer, or something else? Any advice/input/feedback very welcomed!


Here is some code snippets of what I use see if they help you ;)


procedure DeclarePlayers;
begin
HowManyPlayers := 1;//set higher if you plan on using more
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;//what player to start with

with Players[0] do
begin
Name := ''; //Character Name
Pass := ''; //Character Pass
Pin := ''; //Pin for bank
Active := true;
end;

{with Players[1] do
begin
Name := ''; //Character Name
Pass := ''; //Character Pass
Pin := ''; //Pin for bank
Active := true;
end;

with Players[2] do
begin
Name := ''; //Character Name
Pass := ''; //Character Pass
Pin := ''; //Pin for bank
Active := true;
end;

with Players[3] do
begin
Name := ''; //Character Name
Pass := ''; //Character Pass
Pin := ''; //Pin for bank
Active := true;
end; } //honestly if you need more than 4 accounts Ctrl + c and Ctrl + v =P
end;
//main loop starts here
DeclarePlayers;

repeat
LoginPlayer;
Wait(800);

repeat

until(not(loggedin));
NextPlayer(Players[CurrentPlayer].Active = False);//because you ARE logged out
until AllPlayersInactive;//multiplayer check

Le Jingle

2012-08-01 01:54:41

@getdropped69, I suppose I could just enter my accounts in as different players, in which will alternate them, but isn't there an easier / shorter way to achieve that?

Brandon

2012-08-01 03:11:57

I've written two choices here.. Either redirect the logout procedure to the wrapper.. OR just use the nested loops. You do not need both.


{$DEFINE SMART}
{$I SRL/SRL.Simba}

Procedure DeclarePlayers;
begin
HowManyPlayers := 2;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := 'PName';
Pass := 'PWord';
Pin := 'Pin';
Active := True;
end;

with Players[1] do
begin
Name := 'PName2';
Pass := 'PWord2';
Pin := 'Pin2';
Active := True;
end;
end;

Procedure WrapperExample;
begin
Players[CurrentPlayer].Active := False;
LoginPlayer; //Attempt to login the player to get the RsUpdate screen. SixHourFix will get kicked in.
end;

begin
{$IFDEF SMART}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}

DeclarePlayers;
SetupSRL;

//SRL_Procs[SRL_OnRSLogOut] := @WrapperExample; Uncomment to redirect.

repeat
repeat
//Do whatever in here.. main loop bleh..

until(Not Players[CurrentPlayer].Active);
until(AllPlayersInactive);
end.

Le Jingle

2012-08-01 03:20:18

Ah thanks for the example, that beats writing out a long list of players to use for only 2 accounts -.- And also, thanks for the general help to the community too, I think it's fair to add this 2nd thanks in here ;)