SRL Archive - Outdated Tutorials

Types + PlayerArray Tutorial


WhiteShadow

2006-11-23 02:08:26

Did you know you can make your own type of variable? Well you can learn now.

Common types that are already made are : Extended, Integer, Char, String, LongInt(Integer), etc…
Using the "Type" Statement you can make your own variable type. :D Very easy. I'm going to make a new variable called "iOre".

The first type you can use is records, records hold 2 + different variable types in one.
This is a Rs example, this can be used for holding a rock's color, tolerance, and uptext.

type //type statement. 
iOre = record //record.
Color : Integer; //2 + variables.
Tol : Integer;
UpTxt : String;
end;

We declared a new variable that holds 3 things. Now we use this new variable we made!
var
Rock : iOre;

procedure LoadValues;
begin
Rock.Color := 8684676; //Yes you do Variable.(dot) [and what the record was holding]
Rock.Tol := 5;
Rock.UpTxt := 'Tin';
end;

Put together.

program Example;

type //type statement.
iOre = record //record.
Color : Integer; //2 + variables.
Tol : Integer;
UpTxt : String;
end;

var
Rock : iOre;

procedure LoadValues;
begin
Rock.Color := 8684676;
Rock.Tol := 5;
Rock.UpTxt := 'Tin';
end;

begin
LoadValues;
end.

Understand that this is part of how the player array works! Except after they use this variable with an array.

Break down.

program HoldPlayers;

type
User = record //record
Integer1 : Integer; //hold's user's number
Blah : Integer; //other random number value
Yes : Boolean; //some true false thing

//^just some random variables..


end;

var
Players : array[0..2] of User; //array of the user! They set the array with HowManyPlayers though.


begin
Players[0].Integer := 2; //Looks familiar?
Players[1].Blah := 3;
Players[2].Yes := True;

end.

If you don't understand something still please ask!

Freddy1990

2006-11-23 06:22:08

Nice tutorial :)

Infantry001

2006-11-23 08:42:19

wow thanks! thats a very helpful tut!

JAD

2007-02-23 10:59:28

it's a pretty good tut. i learned something with the new variable types like that and stuff. I already knew about arrays, but for people that don't, that part of tutorial could be a little confusing. maybe if you made examples, player arrays that people use in scripts maybe? I just think that somebody new to arrays would get lost in that section, maybe I'm wrong though. pretty good tut though.

TheGodfather

2007-03-05 01:47:57

great i get how to make a spontaneous variable now :)

WhiteShadow

2007-03-05 02:00:43

From: TheGodfather
great i get how to make a spontaneous variable now :)


heh, not exactly spontaneous. :D

It's good for specific uses, for example Players

{ type TUser;
Description: The User Record. }
type
TUser = record
Name: string; // * User Name
Pass: string; // * User Pass
Nick: string; // * Screen Name for random detection
Active: Boolean; // * Set to True if Ok, False if Lost.
Loc: string; // * User Location
Skill: string; // * User Action to Perform
Level: array[0..21] of word;
// * Levels of all skills. SetIn GetPlayerLevels.
Ore: string; // * test
WaitTime: Integer; // * Wait Time for Each User, Good for Autofighters
Fight: Boolean; // * If we want the Char to randomly fight
Worked: Integer; // * Time User has worked
Banked: Integer; // * Number of Banks User has done
Killed: Integer; // * Number of Kills User has made
Boolean1: Boolean; // * For reports, etc.
Boolean2: Boolean; // * For reports, etc.
Boolean3: Boolean; // * For reports, etc.
Integer1: Integer; // * For reports, etc.
Integer2: Integer; // * For reports, etc.
Integer3: Integer; // * For reports, etc.
Integer4: Integer; // * For reports, etc.
String1: string; // * For reports, etc.
String2: string; // * For reports, etc.
String3: string; // * For reports, etc.
Extended1: Extended; // * For reports, etc.
Extended2: Extended; // * For reports, etc.
Extended3: Extended; // * For reports, etc.
end;

the mose long ass useful list i've ever seen. :]]

WhoCares357

2007-03-05 12:53:59

TYVM, helped me mucho. +rep