Multiplayer Proggies
If you do not know how to use Multiplayer: Go here
Names and variables
Before reading this part, make sure you understand fully how to create Single Player Proggies and how to use the functions. Now, for naming variables, we want to do it exactly the same way we did above, make a list of these we want to be updated on in the Proggy and pick an appropriate variable name for it, like so:
- How many Loads I've done -- I'll name it LoadsDone
- How many Loads I've done per hour -- I'll name it LoadsPerHour
- How much XP I've gained -- I'll name it XPGain
- How much XP I've gained per hour -- I'll name it XPGainPerHour
- How many Runes I've crafted -- I'll name it Runes
- How many Runes I've crafted per hour -- I'll name it RunesPerHour
Now you just want to put these variables into your script. To do this, you declare them globally, so put 'var' at the start of your script just before you DeclarePlayers. Like so:
Simba Code:
Var
CurrentXP, OriginalXP: Integer;
XPGain, LoadsDone, XPPerHour, Runes: Array of Integer;
TimeGone, LoadsPerHour, RunesPerHour: Array of Integer;
Because this is a Multiplayer Proggy, the variables need to be defined as an Array of Integer rather than just an integer like in the Single Player Proggies, with the exception of CurrentXP and OriginalXP. You should also take note
- TimeGone, which I will use in the Proggy to help me find out at what rate I have done procedures e.g (RunesPerHour)
- OriginalXP, which I will use to tell me how much XP I had to start of with - needed to find XPGain
- CurrentXP, which I will use to tell me how much XP I have at the moment - needed to find XPGain
Now that we have successfully put these Variables into our Script we need to know how to use them.
Functions Needed
You should know these already, but if you skipped the Single Player Proggies section....
Here are the main functions you will need to get your Proggy to work...:
Simba Code:
GetTimeRunning
Inc(variable)
IncEx(variable, amount)
GetXPBar(1,2 or 3)
InvCount
GetAmountBox(box: TBox): integer; // Thanks to Er1k!
GetBankItemAmount(const Row, Col: Integer): Integer; // Thanks to Er1k x2!
...and this is what they do:
GetTimeRunning - Gets how long you have been playing the Script in milliseconds
Inc(variable) - This increases the variable you put in the brackets by 1.
IncEx(variable, amount) - This increases the variable you put in the brackets by the amount you put in after the comma
GetXPBar(1,2 or 3) - Gets the amount of XP you currently have. You can put in the number 1, 2 or 3 depending on which one seems to work for your script
InvCount - Returns amount of items in your inventory
GetAmountBox - Returns the amount of an item at in the box ‘box’. Use this for counting stackable items in your inventory. For 'box' put InvBox(i), with i being the inventory box you want to search in.
GetBankItemAmount - Returns the amount of an item in the bank at bank screen coordinates. For the first number put in the row you're searching in and for the second put in the column.
Using Functions
Once you've learned what those functions do, you want to know where to use them in your script.
Using Functions within your Script
The variables used here: LoadsDone, Runes
This is easy to do but it is also easy to forget. When using functions within your script on Multiplayer, you want to find out how well each player has done. You want to know how many loads each player did and how much xp each player gained.
So we do this by adding:
after all our variables so it only finds the variable for the current player. If you don't understand what this means, look at the example below:
If I have just completed one load worth of Runecrafting. After I click the altar I would put this just before ending my Altar Clicking function:
Simba Code:
Inc(LoadsDone) // for single Player Proggies
Inc(LoadsDone[CurrentPlayer]) // for Multiplayer Proggies
So it would increase my LoadsDone by 1 for the Current Player I am using..
Please not that the functions do not change, you simply add [CurrentPlayer] after your variable.
Using functions in your proggy
The variables used here are: TimeGone, XPGain, XPPerHour, LoadsPerHour, RunesPerHour, CurrentXP, OriginalXP
These variables are the ones we can't just simply update after doing the function. Instead, we define them here in the Proggy so we can see how they have updated.
The first thing you want to do when creating your Proggy is find out how long the script has been running for and define it with our variable TimeGone and the function GetTimeRunning, but remember what we said about adding [CurrentPlayer] after our variables? We do it here too:
Simba Code:
TimeGone[CurrentPlayer] := (GetTimeRunning/1000);
Now we want to find out how much XP has been gained.
First we use the variable CurrentXP and the function GetXPBar(1) to find out how much XP we currently have, but in this case only we don't have to add [CurrentPlayer] as the we are not going to actually write in the CurrentXP, instead we're using it to find the XPGain.
Simba Code:
CurrentXP := GetXPBar(1);
Then we use the OriginalXP variable we included earlier and put it in the mainloop, right after you Log In, but before you start your actual script. Put it in like this:
Simba Code:
OriginalXP := GetXPBar(1);
So far you've found the XP you had before actually running the script and the Current XP that the player has. Now you can use this to find the increase in XP.
To do this, we use the variable XPGain and minus the OriginalXP from the CurrentXP, like so:
Simba Code:
XPGain[CurrentPlayer] := (CurrentXP - OriginalXP);
So this will tell us how much XP we have Gained since starting the script. However even though I didn't use [CurrentPlayer] for CurrentXP and OriginalXP, I must use it for XPGain as I will be writing that in in the Proggy.
PerHour values require the TimeGone variable which we have already defined.
To find PerHour vales you simply divide the appropriate variables by the TimeGone and then times by 3600 to get the amount per hour. but also remember that here you must add [CurrentPlayer] after your variables.
Like so:
For XPPerHour:
Simba Code:
XPPerhour[CurrentPlayer] :=(3600*(XPGain[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
For LoadsPerHour:
Simba Code:
LoadsPerhour[CurrentPlayer] :=(3600*(LoadsDone[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
For RunesPerHour:
Simba Code:
RunesPerHour[CurrentPlayer] := (3600*(Runes[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
Finally, we have defined all of our variables. If you have done it right the start of your Proggy Should look like this:
Simba Code:
procedure ProggyTest;
begin
if LoadsDone[CurrentPlayer] mod 5=0 then
ClearDebug;
CurrentXP := GetXPBar(1);
TimeGone[CurrentPlayer] := (GetTimeRunning/1000);
XPGain[CurrentPlayer] := (CurrentXP - OriginalXP);
XPPerhour[CurrentPlayer] :=(3600*(XPGain[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
LoadsPerhour[CurrentPlayer] :=(3600*(LoadsDone[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
RunesPerHour[CurrentPlayer] := (3600*(Runes[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
Writing the Proggy
Here are two simple functions you will need to know to Write Proggies.
-Writeln simply Writes a Line in the debug box. You put the text within apostrophes.
-IntToStr simply converts an integer into a string so it can be written in the debug box.
The first thing you want to do when writing the Proggy for a Multiplayer Script is add the variable 'i' into the Proggy. Like this:
Simba Code:
procedure ProggyTest;
var
i: Integer;
begin
Then, after all those variables we just defined, on the next line we want to write begin and add:
Simba Code:
for i := 0 to HowManyPlayers - 1 do
This will declare the player we are using. If we are using the first player in the script(Players[0]), then i=0. If we are using the player after that then i=1. You can change the values appropriately to the number of players your script supports.
NOW, after adding this, we need to add[i] after all the variables we are writing in, that way it only writes the values for the player we are using (Players[0], Players[1] etc...) Writing the loads, unlike in Single Player Proggies now goes like this:
Simba Code:
Writeln('We have done: ' + IntToStr(LoadsDone[i]);
So it writes in 'We have done: ' followed by the amount of LoadsDone followed by [i]. Simple right?
Here are a few more examples:
Writing the amount of Runes Crafted would go like this:
Simba Code:
Writeln('We have crafted ' + IntToStr(Runes[i])
Writing the amount of Runes Crafted per hour would go like this:
Simba Code:
Writeln('We have crafted: ' + IntToStr(RunesPerHour[i]) + ' Runes Per Hour')
So now that you now how to Write In your variables into your Proggy. You can begin begin to mess around with it to improve the appearance of it. Here is what the code of my Proggy looks like(note that I've improved the appearance of the Proggy so it more complicated - but all it is is stars :
Simba Code:
procedure ProggyTest;
var
i: Integer;
begin
if LoadsDone[CurrentPlayer] mod 5=0 then
ClearDebug;
CurrentXP := GetXPBar(1);
TimeGone[CurrentPlayer] := (GetTimeRunning/1000);
XPGain[CurrentPlayer] := (CurrentXP - OriginalXP);
XPPerhour[CurrentPlayer] :=(3600*(XPGain[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
LoadsPerhour[CurrentPlayer] :=(3600*(LoadsDone[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
RunesPerHour[CurrentPlayer] := (3600*(Runes[CurrentPlayer]))/((TimeGone[CurrentPlayer]));
begin
Writeln('******************************************************************');
Writeln('*/////////---------- Abu''s''AirKrafter Version 2 ----------\\\\\\\*');
Writeln('*/////////----------____________________________----------\\\\\\\*');
Writeln('******************************************************************');
Writeln('');
for i := 0 to HowManyPlayers - 1 do
begin
Writeln('*/////////--------- Proggy for the player: ' + Players[i].Nick + ' --------\\\\\\\\\*');
Writeln('*/////////We have done: ' + IntToStr(LoadsDone[i]) + ' Loads / Thats ' + IntToStr(LoadsPerHour[i]) + ' loads per hour');
Writeln('*/////////We have gained: ' + IntToStr(XPGain[i]) + ' xp / Thats ' + IntToStr(XPPerHour[i]) + ' xp per hour');
Writeln('*/////////We have crafted ' + IntToStr(Runes[i]) + ' Runes / Thats ' + IntToStr(RunesPerHour[i]) + ' Runes Per Hour');
Writeln('');
end;
end;
end;
And here is what it looks like in action:
Progress Report:
******************************************************************
*/////////---------- Abu's'AirKrafter Version 2 ----------\\\\\\\*
*/////////----------____________________________----------\\\\\\\*
******************************************************************
*/////////--------- Proggy for the player: jwka --------\\\\\\\\\*
*/////////We have done: 1 Loads / Thats 23 loads per hour
*/////////We have gained: 140 xp / Thats 3230 xp per hour
*/////////We have crafted 142 Runes / Thats 3276 Runes Per Hour
*/////////--------- Proggy for the player: N/A. --------\\\\\\\\\*
*/////////We have done: 0 Loads / Thats 0 loads per hour
*/////////We have gained: 0 xp / Thats 0 xp per hour
*/////////We have crafted 0 Runes / Thats 0 Runes Per Hour
One final thing
The last thing you have to do, is set the lengths of your array. To do this simply make a procedure like this and set the lengths to HowManyPlayers:
Simba Code:
procedure SetArrayLengths; //renamed to fit purpose
begin
SetLength(TimeGone,HowManyPlayers);
SetLength(XPPerHour,HowManyPlayers);
SetLength(LoadsPerHour,HowManyPlayers);
SetLength(XPGain,HowManyPlayers);
SetLength(LoadsDone,HowManyPlayers);
SetLength(Runes,HowManyPlayers);
SetLength(RunesPerHour,HowManyPlayers);
end;
And then load that in your mainloop after SetUpSRL;
And that's how to make a Progress Report for a Single Player and Multiplayer Script!
If you have any problems, simply read over the guide.
If you want to go one step further and get your Progress Report Onscreen, then go here
Special Thanks to:
bolshak25 - for helping me understand how to use Proggies