SRL Archive - OSR Help

I need help with Multi-Player.


Paula_Deen

2012-02-02 01:49:49

I have Multi-Player fully functional.

There is just one small problem with it. When the last player is done, the script does not end.
The script just stays running at the log-in screen until someone manually ends the script.

program ChocolateCrusher;

{$DEFINE SMART}
{$i SRL/srl.simba}

var
x, y, chocbar, chocdust, BarsCrushed: Integer;

{YOU MUST HAVE EITHER A KNIFE OR A PESTLE AND MORTAR IN YOUR TOOLBELT!

-If you are a /member/, use the pestle and mortar.
The pestle and mortar crushes chocolate twice the speed of a knife.

-Free to play people will have to stick with a knife.

IMPORTANT:
-Make sure you have your Chocolate Bars in the FIRST bank slot.
The script will end if it is in any other slot.}

Const //Make sure you set 'UsingPestle', 'SoulWarsBanking', and 'LaggyComputer' accordingly!

UsingPestle = true; // True = Pestle and Mortar. False = Knife

SoulWarsBanking = false; // Bank at Soul Wars? True = Soul Wars. False = Other (see below)

LaggyComputer = false; // true = you're using a laggy computer. (This WILL lower profit/hr)
// false = you are using a fast computer.

Members = true; // True = Members World. False = Free World.
Mouse_Speed = 17; // Mouse speed. Higher = Faster. (17 is default)
Version = '1.1';

NumbOfPlayers = 1; //How many players you are using.
StartPlayer = 0; //Player to start with. (0 = first character)

// YOU MUST HAVE EITHER A KNIFE OR A PESTLE AND MORTAR IN YOUR TOOLBELT

procedure DeclarePlayers;
var i:integer;
begin
NumberOfPlayers(NumbOfPlayers);
CurrentPlayer := StartPlayer;
for i := 0 to NumbOfPlayers-1 do
Players[i].BoxRewards := ['xp', 'oins', 'ostume', 'mote'];

with Players[0] do
begin
Name := ''; //Player username.
Pass := ''; //Player password.
Pin := ''; //Bank Pin. (Leave blank if you do not have a bank pin.)
Loc := 'vwb'; //Banking Location (See below) (Soul Wars banking is is constants (aka - "Const"))
Active := True;
end;

// YOU MUST HAVE EITHER A KNIFE OR A PESTLE AND MORTAR IN YOUR TOOLBELT!
//
// Banking Locations: (*Note* - Some banks may not work)
// 'vwb' = Varrock West Bank
// 'veb' = Varrock East Bank
// 'fwb' = Falador West Bank
// 'feb' = Falador East Bank
// 'db' = Draynor Bank
// 'akb' = Al-Kharid Bank
// (Soul Wars banking is selected in the constants (aka - "Const"))

//To use multiple accounts, remove the {}'s from the below coding.
//Make sure you adjust "NumbOfPlayers", which is found in the constants! (aka - "Const")

{with Players[1] do
begin
Name := ''; //Player username.
Pass := ''; //Player password.
Pin := ''; //Bank Pin. (Leave blank if you do not have a bank pin.)
Loc := 'vwb'; //Banking Location (See below) (Soul Wars banking is above)
Active := true;
end;}
{with Players[2] do
begin
Name := ''; //Player username.
Pass := ''; //Player password.
Pin := ''; //Bank Pin. (Leave blank if you do not have a bank pin.)
Loc := 'vwb'; //Banking Location (See below) (Soul Wars banking is above)
Active := true;
end;}
end;

procedure AntiRandoms;
begin
FindNormalRandoms;
LampSkill := 'prayer' //This can be changed to any skill!
end;

////////////////////////////////////////////////////////////////////////////////
// No Editing is required below this point! //
////////////////////////////////////////////////////////////////////////////////

Procedure Antiban;
Begin
Case Random (400) of
0..14: Begin SleepAndMoveMouse(6000 + Random(750)); End;
15..19: Begin GameTab(tab_Inv) ExamineInv; GameTab(28); End;
20..30: Begin RandomAngle(1); End;
30..35: Begin GameTab(Tab_Stats); Wait(3000 + Random(400)); GameTab(28); End;
36..40: Begin GameTab(tab_Stats) HoverSkill('random', False); GameTab(28); End;
End;
End;

procedure InitDTMs;
begin
chocbar := DTMFromString('mwQAAAHic42RgYOABYlYgFgFiQSBmY4AAkLgklOYAYgEomwmqBsQWBmJ2qHpfHXGoLG78n4EwYCQCwwEAFn4CcQ==');
chocdust := DTMFromString('m1gAAAHic42JgYOAEYnYg5gNiZiAWAGIOBgjgBmJ+IBaFqgHJMwIxLxBzQeW4oGrZgJgViO1VhIEkE0H8n4E4wEgkRgAAHfUCSg==');
end;

procedure FreeDTMs;
begin
FreeDTM(chocbar);
FreeDTM(chocdust);
end;

procedure Proggy;
begin
Writeln('//////////////////Paulas Chocolate Crusher\\\\\\\\\\\\\\\\\\');
Writeln('///////////////////////By Paula Deen\\\\\\\\\\\\\\\\\\\\\\\\');
Writeln('Run Time: ' + TimeRunning);
Writeln('Total Loads: ' + IntToStr(BarsCrushed));
Writeln('Chocolate Dust made: ' + IntToStr(BarsCrushed*28));
WriteLn('Total Profit made: ' + IntToStr(BarsCrushed*28*50));
Writeln('//////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\');
end;

procedure WithdrawChoc;
begin
if not LoggedIn then
Exit;
AntiRandoms;
if (PinScreen) then
InPin(Players[CurrentPlayer].Pin);
if (BankScreen) then
DepositAll;
WriteLn('Banking');
Wait(300 + Random(200));
FixBank;
MMouse(55,108,9,9);
Case (LaggyComputer) of
true: Wait(650 + 400);
false: Wait(250 + 200);
end;
if IsUpText('bar') then
begin
ClickMouse2(false);
Case (LaggyComputer) of
true: Wait(650 + 250);
false: Wait(100 + 200);
end;
WaitOptionMulti(['Withdraw-All', 'All'], 200);
Wait(200 + 200);
end else
if not IsUpText('bar') then
begin
WriteLn('Could not find Chocolate Bar (wrong uptext). Trying again...');
Wait(1000);
MMouse(55,108,9,9);
Case (LaggyComputer) of
true: Wait(650 + 400);
false: Wait(200 + 200);
end;
if IsUpText('bar') then
begin
ClickMouse2(false);
Case (LaggyComputer) of
true: Wait(650 + 400);
false: Wait(200 + 200);
end;
WaitOptionMulti(['Withdraw-All', 'All'], 200);
Wait(200 + Random(200))
end else
if not IsUpText('bar') then
begin
WriteLn('Could not find Chocolate Bar (wrong uptext). Trying again...');
Wait(1000);
MMouse(55,108,9,9);
Case (LaggyComputer) of
true: Wait(650 + 400);
false: Wait(200 + 200);
end;
if IsUpText('bar') then
begin
ClickMouse2(false);
Case (LaggyComputer) of
true: Wait(650 + 400);
false: Wait(200 + 200);
end;
WaitOptionMulti(['Withdraw-All', 'All'], 200);
Wait(200 + Random(100))
end else
if not IsUpText('bar') then
begin
if (BankScreen) then
CloseBank;
end;
begin
WriteLn('Could not find Chocolate Bar (wrong uptext). Switching Player/Logging out.');
Players[CurrentPlayer].Active := False;
Logout;
Exit;
end;
end;
end;

Case (LaggyComputer) of
true: Wait(650 + 300);
false: Wait(200 + 200);
end;
CloseBank;
end;

procedure CrushChoc;
begin
if not LoggedIn then
Exit;
begin
if FindDTM(chocbar, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 7, 7, False)
end else
begin
wait(1000);
WriteLn('Could not find Chocolate Bar (invalid DTM). Trying again...');
if FindDTM(chocbar, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 7, 7, False)
end else
begin
wait(1000);
WriteLn('Could not find Chocolate Bar (invalid DTM). Trying again...');
if FindDTM(chocbar, x, y, MIX1, MIY1, MIX2, MIY2) then
Mouse(x, y, 7, 7, False)
end;
end;
Case (LaggyComputer) of
true: Wait(750 + 350);
false: Wait(300 + 100);
end;
ChooseOption('Powder')
end;

begin
wait(1000)
if FindDTM(chocdust, x, y, MCX1, MCY1, MCX2, MCY2) then
MMouse(x, y, 22, 23);
Case (LaggyComputer) of
true: Wait(750 + 350);
false: Wait(300 + 250);
end;
if IsUpText('ake') then
begin
ClickMouse2(true)
end else
begin
wait(1000)
WriteLn('Could not crush Chocolate (lag?). Trying again...');
if FindDTM(chocdust, x, y, MCX1, MCY1, MCX2, MCY2) then
MMouse(x, y, 22, 23);
Case (LaggyComputer) of
true: Wait(750 + 350);
false: Wait(300 + 250);
end;
end;
if IsUpText('ake') then
begin
ClickMouse2(true);
end else
begin
wait(1000)
WriteLn('Could not crush Chocolate (lag?). Trying again...');
if FindDTM(chocdust, x, y, MCX1, MCY1, MCX2, MCY2) then
MMouse(x, y, 22, 23);
Case (LaggyComputer) of
true: Wait(750 + 350);
false: Wait(300 + 250);
end;
if IsUpText('ake') then
ClickMouse2(true);
end;
end;
WriteLn('Crushing Chocolate Bars');
Wait(1500 + Random(2000));
Antiban;
AntiRandoms;
Case (UsingPestle) of
true: Wait(13000 + 2000);
false: Wait(26000 + 2000);
end;
BarsCrushed:=BarsCrushed+1;
end;


begin
Smart_Server := 10;
Smart_Members := Members;
SetupSRL;
DeclarePlayers;
MouseSpeed := Mouse_Speed;
LoginPlayer;

repeat
repeat
Case (SoulWarsBanking) of
true: OpenBankChest(SRL_BANK_SW);
false: OpenBank(Players[CurrentPlayer].Loc, True, True);
end;
Proggy;
WithdrawChoc;
InitDTMs;
CrushChoc;
FreeDTMs;
Proggy;
until (not Loggedin);
NextPlayer(Players[CurrentPlayer].Active);
until false;
end.

Also, does anyone know how I can make "UsingPestle" and "SoulWarsBanking" unique to each player?
Right now it's a constant throughout all of the players, which is a bit inconvenient.

KingKong

2012-02-02 05:09:29

1)Change the two lines before the final end to this:

NextPlayer(False);
until (PlayersActive = 0);

2)Add Booleans[0], Booleans[1] to declareplayers:

with Players[0] do
begin
Name := ''; //Player username.
Pass := ''; //Player password.
Pin := ''; //Bank Pin. (Leave blank if you do not have a bank pin.)
Loc := 'vwb'; //Banking Location (See below) (Soul Wars banking is is constants (aka - "Const"))
Active := True;
Booleans[0] := True; //true = use pestle, false for knife
Booleans[1] := False; //true = use soulwars
end;

3)lol'd at LaggyComputer :p

Markus

2012-02-02 05:23:40

This is intended behaviour of SRL.
If you don't want this, add a hook to SRL_Procs[srl_InNextPlayerLoop] and there you can make it terminate the script;