Log in

View Full Version : Progress report [Multiplayer]



King
12-08-2012, 04:01 AM
Wanted to add a progress report and multiplayer to my script, multiplayer went great, switches just fine and I understand it. I had a progress report for a single player as well. I want o add the progress report for multiple players.

The script will run fine until I call the progress report the I get this error


http://i.imgur.com/ZxhJ4.png


I have followed all the tuts I can find and moved where the report was called, even pasted the exact progress report tutorial (abu's) into my script and it still stopped in the same spot, if I comment that out, it goes to the next line. Nothing is displayed. This si the only thing that stopping me from releasing the updated version of my enchanter >.<


Program KingsEnchantressPUBLIC; //Made by SRLKing V1.1

{$Define Smart}
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/SmartGraphics.Simba}

var
T, B, i, FailCount, CurrentXp, OriginalXp, TotalProfit, RingsDone, TotalRingsDone: Integer;
TotalMagicXpGained, RingsMade, MagicXpPerHour: Array of Integer;
TimeGone, RingsPerHour, ProfitPerHour: Array of Integer;


procedure DeclarePlayers;
begin
HowManyPlayers := 1; // Number of players you are using
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0; //Player to star with

with Players[0] do
begin
Name := ''; // Player username
Pass := ''; // Player password
BoxRewards := ['XP', 'ostume', 'mote', 'oins', 'une', 'ssence'];
Active := True;
Pin := ''; //Your pin
Nick := ''; // Nick name for your player in the progress report
end;

// Uncomment to add players.

{ with Players[1] do
begin
Name := 'dog'; // Player username
Pass := 'cat'; // Player password
BoxRewards := ['XP', 'ostume', 'mote', 'oins', 'une', 'ssence'];
Active := True;
Pin := ''; //Your pin
end;

with Players[2] do
begin
Name := ''; // Player username
Pass := ''; // Player password
BoxRewards := ['XP', 'ostume', 'mote', 'oins', 'une', 'ssence'];
Active := True;
Pin := ''; //Your pin
end;


with Players[3] do
begin
Name := ''; // Player username
Pass := ''; // Player password
BoxRewards := ['XP', 'ostume', 'mote', 'oins', 'une', 'ssence'];
Active := True;
Pin := ''; //Your pin
end;}
end;

const
RingsToEnchant = 9999999999; //Number of loads of beer to buy
PriceSold = 2094; //Price you sold 1 ring for
PriceOfRing = 1300; //Price you paid per Emerald Ring
PriceOfCosmic = 206; //Price you paid per cosmic rune


// Do not touch below unless you know what you are doing! //
//--------------------------------------------------------------------------------//


Procedure Login;

begin
ClearDebug;
{$IFDEF SMART}
{$IFDEF SIMBAMAJOR980}
SMART_SERVER := 6;
SMART_MEMBERS := TRUE;
SMART_SIGNED := TRUE;
SMART_SUPERDETAIL := FALSE;
{$ELSE}
SRL_SIXHOURFIX := TRUE;
SMART_FIXSPEED := TRUE;
{$ENDIF}
{$ENDIF}
DeclarePlayers;
LoginPlayer;
MakeCompass('W');
SetAngle(SRL_ANGLE_HIGH);
end;

Function OpenBankSW:Boolean;
begin
OriginalXp :=GetXPBar(1);
if not LoggedIn then Exit;
MarkTime(b);
repeat
MarkTime(t);
writeln('Trying to open the bank chest');
OpenBankChest(20);
repeat
wait(100);
until(BankScreen or (TimeFromMark(t)>5000) or PinScreen);
if BankScreen or PinScreen then
begin
writeln('Opened the Bank');
if PinScreen then
begin
InPin(Players[0].Pin);
writeln('Inputting players pin');
end;
Result :=True;
end;
if not( PinScreen or BankScreen) then
begin
writeln('Failed to find and open the bank chest');
Inc(FailCount);
if FailCount=10 then
begin
Players[CurrentPlayer].Active := False;
LogOut;
Exit;
writeln('Could not open the bank');
end;
end;
until((TimeFromMark(b)>70000) or BankScreen);
ClearDebug;
end;

Procedure BankRemaining;
begin
if not LoggedIn then Exit;
OpenBankSW;
repeat
wait(50);
until(BankScreen or (TimeFromMark(t)>10000));
if BankScreen then
begin
DepositAll;
MarkTime(b);
repeat
wait(50)
until((TimeFromMark(b)>10000) or (InvCount=0));
writeln('Ending the script, thankyou for using');
end;
end;


function DepositEnchnatedItems:Boolean;
begin
if not LoggedIn then Exit;
MarkTime(t);
repeat
wait(50);
until(BankScreen or (TimeFromMark(t)>10000));
if BankScreen then
begin
Deposit(2, 28, True);
MarkTime(b);
repeat
wait(50)
until((TimeFromMark(b)>10000) or (InvCount=1));
if InvCount = 1 then
begin
wait(RandomRange(250,500));
Withdraw(0, 0, 27);
writeln('Withdrawing the item to enchant');
wait(RandomRange(250,500));
CloseBank;
result :=True;
end else
Begin
writeln('Failed to withdraw');
result :=False;
Players[CurrentPlayer].Active := False;
LogOut;
Exit;
end;
end;
ClearDebug;
end;

Function Enchant:Boolean;
begin
if not LoggedIn then Exit;
writeln('Beginning enchanting');
begin
for i:= 2 to 28 do
begin
MarkTime(t);
CurrentXp:= GetXPBar(1);
if not ExistsItem(i) then break;
if ExistsItem(i) then
SendKeys('1', 5, 5);
MouseItem(i, 1);
if FindBlackChatMessage('You do not have enough cosmic runes to cast this spell.') then
begin
writeln('Banking inventory then exiting due to cosmic runes being gone');
BankRemaining;
result :=False;
Players[CurrentPlayer].Active := False;
LogOut;
Exit;
end;
repeat
wait(100);
until((GetXPBar(1)>CurrentXP) or (TimeFromMark(t)>5000));
Inc(RingsDone);
Inc(TotalRingsDone);
result :=True;
end;
end;
end;



procedure ProgressReport;

begin
ClearDebug;
TimeGone[CurrentPlayer] := (GetTimeRunning/1000);
CurrentXp := GetXPBar(1);
TotalMagicXpGained[CurrentPlayer] := (CurrentXp - OriginalXp);
MagicXpPerHour[CurrentPlayer] := (3600*(TotalMagicXpGained[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
RingsPerHour[CurrentPlayer] := (3600*(RingsDone))/((TimeGone[CurrentPlayer]));
ProfitPerHour[CurrentPlayer] := (3600*(PriceSold-PriceOfRing-PriceOfCosmic))/((TimeGone[CurrentPlayer]));
TotalProfit := (RingsPerHour[CurrentPlayer]*(PriceSold-PriceOfRing-PriceOfCosmic));
RingsMade[CurrentPlayer] := (RingsDone);
begin
Writeln('***************************************** *************************');
Writeln('*/////////---------- Kings Enchantress V1.1 ----------\\\\\\\*');
Writeln('*/////////----------____________________________----------\\\\\\\*');
Writeln('***************************************** *************************');
Writeln('');
for i := 0 to HowManyPlayers - 1 do
begin
Writeln('*/////////--------- Proggy for the player: ' + Players[i].Nick + ' --------\\\\\\\\\*');
Writeln('*/////////We have been crafting rings for: ' + IntToStr(TimeGone[i]) + ' hours');
Writeln('*/////////We have made: ' + IntToStr(RingsMade[i]) + ' rings / Thats ' + IntToStr(RingsPerHour[i]) + ' rings per hour');
Writeln('*/////////We have gained: ' + IntToStr(TotalMagicXpGained[i]) + ' xp / Thats ' + IntToStr(MagicXpPerHour[i]) + ' xp per hour');
Writeln('*/////////We have gained: ' + IntToStr(TotalProfit) + ' GP / Thats ' + IntToStr(TotalProfit) + ' GP Per Hour');
Writeln('');
end;
end;
end;


procedure SetArrayLengths;
begin
SetLength(TimeGone,HowManyPlayers);
SetLength(TotalMagicXpGained,HowManyPlayers);
SetLength(MagicXpPerHour,HowManyPlayers);
SetLength(RingsPerHour,HowManyPlayers);
SetLength(ProfitPerHour,HowManyPlayers);
end;



begin
SRL_SixHourFix := True;
SetupSRL;
SetArrayLengths;
DeclarePlayers;
Login;
repeat
RingsDone := 0;
Repeat
if not LoggedIn then LoginPlayer;
if OpenBankSW then
begin
if DepositEnchnatedItems then
begin
ProgressReport;
wait(RandomRange(1000,1100));
Enchant;
end;
end;
Until((RingsDone>=RingsToEnchant) or not( LoggedIn));
NextPlayer(True);
until(false);
end.

Flight
12-08-2012, 04:06 AM
Try placing DeclarePlayers before SetArrayLengths.

King
12-08-2012, 04:09 AM
Try placing DeclarePlayers before SetArrayLengths.

The script still stops in the same spot as before with the variables swapped. You meant to switch the order in the mainloop correct?

Flight
12-08-2012, 04:26 AM
The script still stops in the same spot as before with the variables swapped. You meant to switch the order in the mainloop correct?

Yes, swap them in the order they're called. If you have DeclarePlayers called first then at that point, the number of players is defined, and your ArrayLengths can be set to the right value, otherwise, how you have it now, your ArrayLengths are all set to 0 and then your NumberOfPlayers is defined via DeclarePlayers. Understand?

King
12-08-2012, 04:28 AM
edited the script to this and the progress report displays but it doesnt display correctly,

example


*/////////--------- Proggy for the player: Max --------\\\\\\\\\*
*/////////We have been crafting rings for: 294 hours
*/////////We have made: 135 rings / Thats 1653 rings per hour
*/////////We have gained: 0 xp / Thats 0 xp per hour
*/////////We have gained: 971964 GP / Thats 971964 GP Per Hour

Program KingsEnchantressV1Priv; //Made by SRLKing

{$Define Smart}
{$I SRL/SRL.Simba}
{$I SRL/SRL/Misc/SmartGraphics.Simba}

var
T, B, i, FailCount, CurrentXp, OriginalXp, TotalProfit, RingsMade, RingsDone, RingsPerHour, TotalRingsDone: Integer;
TotalMagicXpGained, MagicXpPerHour: Array of Integer;
TimeGone, ProfitPerHour: Array of Integer;

procedure SetArrayLengths;
begin
SetLength(TimeGone,HowManyPlayers);
SetLength(TotalMagicXpGained,HowManyPlayers);
SetLength(MagicXpPerHour,HowManyPlayers);
SetLength(ProfitPerHour,HowManyPlayers);
end;



procedure DeclarePlayers;
begin
HowManyPlayers := 1; // Number of players you are using
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0; //Player to star with

with Players[0] do
begin
Name := ''; // Player username
Pass := ''; // Player password
BoxRewards := ['XP', 'ostume', 'mote', 'oins', 'une', 'ssence'];
Active := True;
Pin := ''; //Your pin
Nick := ''; // Nick name for your player in the progress report
end;

// Uncomment to add players.

{ with Players[1] do
begin
Name := 'dog'; // Player username
Pass := 'cat'; // Player password
BoxRewards := ['XP', 'ostume', 'mote', 'oins', 'une', 'ssence'];
Active := True;
Pin := ''; //Your pin
Nick := 'Max';
end;

with Players[2] do
begin
Name := ''; // Player username
Pass := ''; // Player password
BoxRewards := ['XP', 'ostume', 'mote', 'oins', 'une', 'ssence'];
Active := True;
Pin := ''; //Your pin
Nick := 'Max';
end;


with Players[3] do
begin
Name := ''; // Player username
Pass := ''; // Player password
BoxRewards := ['XP', 'ostume', 'mote', 'oins', 'une', 'ssence'];
Active := True;
Pin := ''; //Your pin
Nick := 'Max';
end;}
end;



const
RingsToEnchant = 9999999999; //Number of loads of beer to buy
PriceSold = 2094; //Price you sold 1 ring for
PriceOfRing = 1300; //Price you paid per Emerald Ring
PriceOfCosmic = 206; //Price you paid per cosmic rune


// Do not touch below unless you know what you are doing! //
//--------------------------------------------------------------------------------//


Procedure Login;

begin
ClearDebug;
{$IFDEF SMART}
{$IFDEF SIMBAMAJOR980}
SMART_SERVER := 6;
SMART_MEMBERS := TRUE;
SMART_SIGNED := TRUE;
SMART_SUPERDETAIL := FALSE;
{$ELSE}
SRL_SIXHOURFIX := TRUE;
SMART_FIXSPEED := TRUE;
{$ENDIF}
{$ENDIF}
DeclarePlayers;
LoginPlayer;
MakeCompass('W');
SetAngle(SRL_ANGLE_HIGH);
end;

Function OpenBankSW:Boolean;
begin
OriginalXp :=GetXPBar(1);
if not LoggedIn then Exit;
MarkTime(b);
repeat
MarkTime(t);
writeln('Trying to open the bank chest');
OpenBankChest(20);
repeat
wait(100);
until(BankScreen or (TimeFromMark(t)>5000) or PinScreen);
if BankScreen or PinScreen then
begin
writeln('Opened the Bank');
if PinScreen then
begin
InPin(Players[0].Pin);
writeln('Inputting players pin');
end;
Result :=True;
end;
if not( PinScreen or BankScreen) then
begin
writeln('Failed to find and open the bank chest');
Inc(FailCount);
if FailCount=10 then
begin
Players[CurrentPlayer].Active := False;
LogOut;
Exit;
writeln('Could not open the bank');
end;
end;
until((TimeFromMark(b)>70000) or BankScreen);
ClearDebug;
end;

Procedure BankRemaining;
begin
if not LoggedIn then Exit;
OpenBankSW;
repeat
wait(50);
until(BankScreen or (TimeFromMark(t)>10000));
if BankScreen then
begin
DepositAll;
MarkTime(b);
repeat
wait(50)
until((TimeFromMark(b)>10000) or (InvCount=0));
writeln('Ending the script, thankyou for using');
end;
end;


function DepositEnchnatedItems:Boolean;
begin
if not LoggedIn then Exit;
MarkTime(t);
repeat
wait(50);
until(BankScreen or (TimeFromMark(t)>10000));
if BankScreen then
begin
Deposit(2, 28, True);
MarkTime(b);
repeat
wait(50)
until((TimeFromMark(b)>10000) or (InvCount=1));
if InvCount = 1 then
begin
wait(RandomRange(250,500));
Withdraw(0, 0, 27);
writeln('Withdrawing the item to enchant');
wait(RandomRange(250,500));
CloseBank;
result :=True;
end else
Begin
writeln('Failed to withdraw');
result :=False;
Players[CurrentPlayer].Active := False;
LogOut;
Exit;
end;
end;
ClearDebug;
end;

Function Enchant:Boolean;
begin
if not LoggedIn then Exit;
writeln('Beginning enchanting');
begin
for i:= 2 to 28 do
begin
MarkTime(t);
CurrentXp:= GetXPBar(1);
if not ExistsItem(i) then break;
if ExistsItem(i) then
SendKeys('1', 5, 5);
MouseItem(i, 1);
if FindBlackChatMessage('You do not have enough cosmic runes to cast this spell.') then
begin
writeln('Banking inventory then exiting due to cosmic runes being gone');
BankRemaining;
result :=False;
Players[CurrentPlayer].Active := False;
LogOut;
Exit;
end;
repeat
wait(100);
until((GetXPBar(1)>CurrentXP) or (TimeFromMark(t)>5000));
Inc(RingsDone);
Inc(TotalRingsDone);
result :=True;
end;
end;
end;



procedure ProgressReport;

begin
ClearDebug;
TimeGone[CurrentPlayer] := (GetTimeRunning/1000);
CurrentXp := GetXPBar(1);
TotalMagicXpGained[CurrentPlayer] := (CurrentXp - OriginalXp);
MagicXpPerHour[CurrentPlayer] := (3600*(TotalMagicXpGained[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
RingsPerHour := (3600*(RingsDone))/((TimeGone[CurrentPlayer]));
ProfitPerHour[CurrentPlayer] := (3600*(PriceSold-PriceOfRing-PriceOfCosmic))/((TimeGone[CurrentPlayer]));
TotalProfit := (RingsPerHour*(PriceSold-PriceOfRing-PriceOfCosmic));
RingsMade:= (RingsDone);
begin
Writeln('***************************************** *************************');
Writeln('*/////////---------- Kings Enchantress V1.1 ----------\\\\\\\*');
Writeln('*/////////----------____________________________----------\\\\\\\*');
Writeln('***************************************** *************************');
Writeln('');
for i := 0 to HowManyPlayers - 1 do
begin
Writeln('*/////////--------- Proggy for the player: ' + Players[i].Nick + ' --------\\\\\\\\\*');
Writeln('*/////////We have been crafting rings for: ' + IntToStr(TimeGone[i]) + ' hours');
Writeln('*/////////We have made: ' + IntToStr(RingsMade) + ' rings / Thats ' + IntToStr(RingsPerHour) + ' rings per hour');
Writeln('*/////////We have gained: ' + IntToStr(TotalMagicXpGained[i]) + ' xp / Thats ' + IntToStr(MagicXpPerHour[i]) + ' xp per hour');
Writeln('*/////////We have gained: ' + IntToStr(TotalProfit) + ' GP / Thats ' + IntToStr(TotalProfit) + ' GP Per Hour');
Writeln('');
end;
end;
end;






begin
SRL_SixHourFix := True;
SetupSRL;
DeclarePlayers;
SetArrayLengths;
Login;
repeat
RingsDone := 0;
Repeat
if not LoggedIn then LoginPlayer;
if OpenBankSW then
begin
if DepositEnchnatedItems then
begin
ProgressReport;
wait(RandomRange(1000,1100));
Enchant;
end;
end;
Until((RingsDone>=RingsToEnchant) or not( LoggedIn));
NextPlayer(True);
until(false);
end.

King
12-08-2012, 04:30 AM
Yes, swap them in the order they're called. If you have DeclarePlayers called first then at that point, the number of players is defined, and your ArrayLengths can be set to the right value, otherwise, how you have it now, your ArrayLengths are all set to 0 and then your NumberOfPlayers is defined via DeclarePlayers. Understand?

This was the right idea, I had to swap them in both places, along with putting them at the very top of the script before my declare players. So I just have to get the progress report to display the correct data :P Thankyou you flight a M8g!

Flight
12-08-2012, 03:03 PM
This was the right idea, I had to swap them in both places, along with putting them at the very top of the script before my declare players. So I just have to get the progress report to display the correct data :P Thankyou you flight a M8g!

Happy to help buddy. I've had similar problems in the past, even as far back as my Private Server days.