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=
SCAR Code:
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=
How many players you are using.
Code:
NumberOfPlayers(howmanyplayer);
How many players are there, using howmanyplayers as a const.
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...
Code:
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
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.
Code:
begin
SetupSRL; //need this declareplayers to work
declareplayers;
cleardebug;
activateclient;
repeat
push;
scream;
until(poop)
end.
But we also need our
Copy and paste this into your script as so...
Code:
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.
SCAR Code:
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...
SCAR Code:
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=
Code:
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...
SCAR Code:
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..
SCAR Code:
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; =
SCAR Code:
If(booleanconsthere)then
....
What a const would look like when you put it in declareplayers; (as ONLY boolean,integer or string)=
SCAR Code:
If(Players[CurrentPlayer].Booleans[0]=True)
Or
SCAR Code:
If(Players[CurrentPlayer].Booleans[0]=False)
Same thing with integers.
SCAR Code:
If(var Mathsign(<,>,=) players[CurrentPlayer].Integers[#])
Without explanations...
SCAR Code:
If(Kill >= players[CurrentPlayer].Integers[#])
Using Greater then or Equal as my math signs for my integer.
For strings? Easy...
SCAR Code:
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
Code:
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.