Results 1 to 12 of 12

Thread: How to Setup DeclarePlayers;

  1. #1
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default How to Setup DeclarePlayers;

    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=

    Code:
    Howmanyplayers
    How many players you are using.
    Code:
    NumberOfPlayers(howmanyplayer);
    How many players are there, using howmanyplayers as a const.
    Code:
    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...
    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
    SCAR Code:
    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.

    Code:
    begin
      SetupSRL; //need this declareplayers to work
      declareplayers;
      cleardebug;
      activateclient;
      repeat
      push;
      scream;
      until(poop)
    end.
    But we also need our
    SCAR Code:
    {.include srl/srl.scar}

    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.
    Last edited by Mr. Doctor; 10-20-2009 at 08:58 PM.

  2. #2
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

  3. #3
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Didn't think i needed them.
    Edited: Standards added
    Last edited by Mr. Doctor; 09-03-2009 at 09:38 AM.

  4. #4
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Your standards aren't all correct,

    SCAR Code:
    if(This)then
      That;

    You need two spaces before That;.

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

    SCAR Code:
    repeat
      This;
      That;
      This;
    until(False);


  5. #5
    Join Date
    Feb 2009
    Location
    AZ, USA
    Posts
    460
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Umm, I think if you're making a tutorial on DeclarePlayers you should tell about the other things you can set such as BoxRewards...
    Is your account in an old-school random? Help SRL-OSR solve randoms!

  6. #6
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by ian. View Post
    Your standards aren't all correct,

    SCAR Code:
    if(This)then
      That;

    You need two spaces before That;.

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

    SCAR Code:
    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.
    Last edited by Mr. Doctor; 09-03-2009 at 10:55 AM.

  7. #7
    Join Date
    Oct 2006
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Junkj View Post
    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  := '';
      Players[0].string[0]:= ''; // this
      Players[0].boolean[0] := ''; // this
      Players[0].pin :='';//this
    should be

    Code:
    Players[0].Strings[0]:= 'String';
    Players[0].Booleans[0] := True;

  8. #8
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by r!ch!e View Post
    should be

    Code:
    Players[0].Strings[0]:= 'String';
    Players[0].Booleans[0] := True;
    fixed

  9. #9
    Join Date
    Jul 2008
    Location
    Canada
    Posts
    1,612
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

  10. #10
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Smarter Child View Post
    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

  11. #11
    Join Date
    Oct 2009
    Location
    Minnesota
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Players[0].Active := ''; //Active or not
    take out the ''s people may get confused because you do not use them in that line

  12. #12
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •