SRL Archive - OSR Outdated Tutorials

How to Setup DeclarePlayers;


Mr. Doctor

2009-09-03 04:53:23

Junkjs Basic Setting up DeclarePlayers;

DeclarePlayers; allows us to add an array of a player(s)

DeclarePlayers is used in most scripts, this how we are able to login players.

This is the Procedure=


procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; //username
Players[0].Pass := ''; //password
Players[0].Nick := ''; //3-4 letters of your username, no caps or first letter
Players[0].Active := boolean; //Active or not
end;

Breakdown=

Howmanyplayers
How many players you are using.
NumberOfPlayers(howmanyplayer);
How many players are there, using howmanyplayers as a const.
CurrentPlayer:= 0;
What your current player is.

The rest is obvious.
On to players…
Players[0]- This is that player that you are using or logging in with. 1 acount goes in here.
You will see Players[1] and Players[2] and ect. This mean that the script supports multiple players. There are more strings and booleans like…

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := boolean;
Players[0].strings[0]:= 'yadda'; // this
Players[0].booleans[0] := true/false; // this
Players[0].pin :='';//this

Boolean returns a value as true or false.
String is pink text like in writeln

Writeln('Yadda');
Wrapped in ''

Pin is used for banking scripts for entering your bank pin. The rest can be added for just a certain player. But those booleans and that string is just for THAT Player, if it was for all it would be in the const. And player[1] could also have the same options but the user might make a boolean false and player[0]'s was true for just for that player.

But this procedure does not work yet? Whys this? We haven't declared our players yet!! 0MFGz0Rz F0 R3@L??Yes.

Declare players goes in our main loop, but not in the loop.

begin
SetupSRL; //need this declareplayers to work
declareplayers;
cleardebug;
activateclient;
repeat
push;
scream;
until(poop)
end.

But we also need our
{.include srl/srl.scar}

Copy and paste this into your script as so…

program New;
{.include SRL/SRL.scar} //HERE!

procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; //username
Players[0].Pass := ''; //password
Players[0].Nick := ''; //3-4 letters of your username, no caps or first letter
Players[0].Active := boolean; //Active or not
end;

begin
SetupSRL; //need this declareplayers to work
declareplayers;
cleardebug;
activateclient;
repeat
push;
scream;
until(poop)
end.

That includes the srl folders…

But what did you say? Its not logging in? WHAT?!?!
Simple
You didn't make it login your player. How do we do this.
With the smartly made function loginplayer;.
But what if its already logged in?
Simple again,
FAIL SAFES.
If it fails something it is still safe, get it? Fail safes is common in scripts because what if something is wrong? Failsafes take care of it.
  if(not(loggedin))then
Loginplayer;
What its telling scar to do…


Hello scar…
IF its NOT LOGGEDIN THEN
LoginPlayer;


Semicolons are needed as it marks the end of a command like, like in my max payne command debug box. Also for standards.
Opening parenthesis and closing are also used for standards.
And where do we put this FAILSAFE you say??
Also in your main loop. As soo…


program New;
{.include SRL/SRL.scar}

procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := ''; //username
Players[0].Pass := ''; //password
Players[0].Nick := ''; //3-4 letters of your username, no caps or first letter
Players[0].Active := boolean; //Active or not
end;

begin
SetupSRL; //need this declareplayers to work
declareplayers;
cleardebug;
activateclient;
if(not(loggedin))then
Loginplayer;
repeat
push;
scream;
until(poop)
end.

And thats pretty much it for the basics…

There are alot of other functions like randomnextplayer;.
You can find these under=
SRL\Misc\Users.scar

in the manual. Don't tell me that its hard finding that 1 giant bold red line because Ctrl-f can also help you find it.

As for the end, a whole program so you can read over and understand…


program New;
{.include SRL/SRL.scar} //includes srl folders

procedure DeclarePlayers; //our procedure always needs this name
begin
HowManyPlayers:= 1; //how many players
NumberOfPlayers(HowManyPlayers); //Number of players using howmanyplayers as a const
CurrentPlayer := 0; //Current player

Players[0].Name := ''; //username
Players[0].Pass := ''; //password
Players[0].Nick := ''; //3-4 letters of your username, no caps or first letter
Players[0].Active := boolean; //Active or not BOOLEAN true or false
end;

begin
SetupSRL; //need this declareplayers to work
declareplayers; //procedure, ALWAYS need before login player or else you will get a runtime error.-Smarter Child
cleardebug; //cleards debug box
activateclient; //minimizes scar client
if(not(loggedin))then //failsafe if the player is not logged in then...
Loginplayer; //logs in player
repeat //repeats whats under it
push;
scream;
until(poop) // until something happens
end. // end of your script
Using Booleans, Integers and Strings

And now you want to include these in you script you say?
Heres your part of the tutorial.

You've added..

players[#].Booleans[#]:= boolean;

to your script now and your wondering how to use it. And im ready to explain.
In order to use this, which is quite simple, is really like a constant(const). It works the same way, just you cant name it what you want.

What a const would look like before you use declareplayers; =

If(booleanconsthere)then
....
What a const would look like when you put it in declareplayers; (as ONLY boolean,integer or string)=

If(Players[CurrentPlayer].Booleans[0]=True)
Or

If(Players[CurrentPlayer].Booleans[0]=False)

Same thing with integers.


If(var Mathsign(<,>,=) players[CurrentPlayer].Integers[#])

Without explanations…


If(Kill >= players[CurrentPlayer].Integers[#])

Using Greater then or Equal as my math signs for my integer.
For strings? Easy…


case Lowercase(Players[currentplayer].strings[#]) of
'yadda': doyadda;
'poopie': dopoopie;

If your wondering why i put currentplayer, its because its getting the array from the current player that its using.
You could use other players like [0] but that line is a for all the players.

If you don't know what a case is.

http://www.villavu.com/forum/showthread.php?t=50327

Basically what lowercase means it turns the string(if it has capitals) to lowercase.

Congrats, you learns how to use DeclarePlayers; more advanced, Congrats!

DeclarePlayers Functions


TUser = record
Name: string; // * User Name
Pass: string; // * User Pass
Pin: string; // * Current Users Pin Number
Nick: string; // * Screen Name for random detection
NickTPA: TPointArray; // * TPA Of Player Name
Level: array[0..24] of Word; // * Levels of all skills.
Active: Boolean; // * Set to True if Ok, False if Lost.
Loc: string; // * User Location
Skill: string; // * User Action to Perform
Worked: Integer; // * Time User has worked
Banked: Integer; // * Number of Banks User has done
Rand: string; // * Current Random
Booleans: array of Boolean; // * For reports, etc.
Integers: array of Integer; // * For reports, etc.
Strings: array of string; // * For reports, etc.
Extendeds: array of Extended; // * For reports, etc.
BoxRewards: TStringArray; // * Partial texts for rewards, place in order of want.

- Thanks Boreas

Useful Functions.


function LoggedIn: Boolean;
By: WT-Fakawi
Description:
Returns True if Logged In.

procedure NumberOfPlayers(Number: Integer);
By: BenLand100 / Wizzup?
Description:
Makes the Players array have Number indexes, also sets strings and
other player array's too standard 100.

function PlayersActive: Integer;
By: ss23
Description:
Numbers of players active in the Players array.

function AllPlayersInactive: Boolean;
By: ZephyrsFury
Description:
Returns true if all players are inactive in the Players array.

function LoggedIn: Boolean;
By: WT-Fakawi
Description:
Returns True if Logged In.

procedure NumberOfPlayers(Number: Integer);
By: BenLand100 / Wizzup?
Description:
Makes the Players array have Number indexes, also sets strings and
other player array's too standard 100.

function PlayersActive: Integer;
By: ss23
Description:
Numbers of players active in the Players array.

function AllPlayersInactive: Boolean;
By: ZephyrsFury
Description:
Returns true if all players are inactive in the Players array.

procedure Logout;
By: Starblaster100 / Raymond
Description:
Logs you out.

procedure LoginPlayer;
By: SRL Developers
Description:
Logs in the Player[CurrentPlayer]. Detects most Client Login Errors

procedure RandomNextPlayer(Active: Boolean);
By: Dankness based on WT-Fawki's NextPlayer and modified by Ron and by Raymond
Description:
Picks Random Player that is Active and Logs in

procedure NextPlayer(Active: Boolean);
By: Dankness and modified by Ron and by Raymond
Description:
Logs in the next player.
Boolean: True - Current player is ok. False - Current player is false.

procedure CheckUserNicks;
By: Sumilion / Raymond
Description:
Checks if all nicks are set correct.

Smarter Child

2009-09-03 05:04:14

Good tutorial, but what is up with the standards :confused: no offense.

Mr. Doctor

2009-09-03 05:35:05

Didn't think i needed them.
Edited: Standards added

ian.

2009-09-03 06:40:10

Your standards aren't all correct,


if(This)then
That;

You need two spaces before That;. :)

And for repeat..until loops it needs to be..


repeat
This;
That;
This;
until(False);

:)

Ogre

2009-09-03 06:46:48

Umm, I think if you're making a tutorial on DeclarePlayers you should tell about the other things you can set such as BoxRewards…

Mr. Doctor

2009-09-03 06:52:51

From: ian.
Your standards aren't all correct,


if(This)then
That;

You need two spaces before That;. :)

And for repeat..until loops it needs to be..


repeat
This;
That;
This;
until(False);

:)


Fixed.


Umm, I think if you're making a tutorial on DeclarePlayers you should tell about the other things you can set such as BoxRewards…


As i said basic. I'll probably add a section with useful functions.

Rick

2009-09-04 07:05:39

From: Junkj

You will see Players[1] and Players[2] and ect. This mean that the script supports multiple players. There are more strings and booleans like…

Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := '';
Players[0].string[0]:= ''; // this
Players[0].boolean[0] := ''; // this
Players[0].pin :='';//this


should be

Players[0].String[B]s[/B][0]:= 'String';
Players[0].Boolean[B]s[/B][0] := True;

Mr. Doctor

2009-09-04 07:14:11

From: r!ch!e
should be

Players[0].String[B]s[/B][0]:= 'String';
Players[0].Boolean[B]s[/B][0] := True;


fixed

Smarter Child

2009-09-05 05:46:11

Also add that you must put declareplayers; before loginplayer; or you will get a runtime error. :)

Mr. Doctor

2009-10-12 11:58:52

From: Smarter Child
Also add that you must put declareplayers; before loginplayer; or you will get a runtime error. :)


Fixed and adding a part that will show you how to use the boolean and strings and integers.

Edit:Added :D

ItsBrucey

2009-10-19 16:19:48

Players[0].Active := ''; //Active or not


take out the ''s people may get confused because you do not use them in that line

Mr. Doctor

2009-10-20 16:57:30

Yes, thank you. Your ItsBrucey is a contraction. Therefore it's It'sBrucey. :D