SRL Archive - Outdated Tutorials

[Outdated]DeclarePlayers with SRL's Playerform


Sumilion

2007-09-25 12:18:33

One of the many new functions that SRL 4 has to offer is SRLPlayerForm();

It sets, loads, saves your players all in a form. Using it is a piece of cake.

First a list of possibilities :
  • Right click menu on tabs
  • Ability to use Armies
  • Can switch Players by holding Ctrl and drag the tab
  • Can add a variable amount of extra options and give the options unique names.

Then the picture :


Thats all i can think of at the moment.

Basically all you need to run it is this :

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

begin
SetupSRL;
SRLPlayerForm(True, [], [], [], []);
end.

Running that will give you the default player form with no extra settings.

Extra settings :

The '[]' parameters in the function stand for extra settings. '[]' in scar means an array, in this case we are using an array of strings (TStringArray).

In order of appearance this is what the TStringArray's stand for :

  • Booleans
  • Integers
  • Strings
  • Extendeds

So lets say we want to add an Integer, the function would then be called like this :

SRLPlayerForm(True, [], [''], [], []);

Lets say we want to add 3 booleans, 1 integer, 4 strings and 2 extendeds :

SRLPlayerForm(True, ['', '', ''], [''], ['', '', '', ''], ['', '']);

When you leave the name of an extra settings blanc ( '' ) it will name it ie. Integer[0]. When you use 'IntTest' it will ask IntTest.

SRLPlayerForm(True, [''], ['', ''], [], []);

will ask :

  • Boolean[0]
  • Integer[0]
  • Integer[1]

SRLPlayerForm(True, ['BoolTest'], ['IntTest', 'IntTest2'], [], []);

will ask :

  • Booltest
  • IntTest
  • IntTest2

However note that even though the form might ask Booltest the script will know it as Boolean[0]. Same thing goes for the other settings.

It could be used like this for example :

SRLPlayerForm(True, ['Pick Equip?', 'Withdraw New Picks?'], ['Nr of Trips'], ['Rock Name to Mine', 'Bank to bank at'], []);

The parameter where i used True is if you want it to show the form or just load the players. True obviously mean show, false means just load nothing else.

Another great feature of the player form is the ability to import and export players from and to the "DeclarePlayers" Procedure, found in the "File" drop down menu

Basically, if you open a script with the procedure "DeclarePlayers" in it all properly filled out, it will parse them into the form for you, and saves you the trouble of having to do it yourself.

Furthermore, if you fill in all of your players in the form and want to put them into the DeclarePlayers format, select your army, and hit the export button. The full DeclarePlayers procedure will be automatically generated for you.

Please note: Importing player data may not always work as the script has to scripted with perfect standards for it to work, I.E:

[php]
Players[0].name := 'Starblaster100';
[/php]

Space between 'name' and ':=' and ':=' and the String / Number / Bool / Extended

Anything i missed ?

ShowerThoughts

2007-09-25 12:23:54

nice thanks to hear ;)

Tim0suprem0

2007-09-25 12:29:53

Woah sweet! I'm gonna check this out! :D

Sumilion

2007-09-25 12:34:30

Thanks,

i stickied it, if any mod / admin thinks it shouldn't be, be my guest to unsticky it but in my opinion its pretty usefull to read through.

mastaraymond

2007-09-25 13:58:15

From: Sumilion
Thanks,

i stickied it, if any mod / admin thinks it shouldn't be, be my guest to unsticky it but in my opinion its pretty usefull to read through.
Thats a lot of coding, well done!

Starblaster100

2007-09-25 14:30:00

I gotta say, Sum as done an amazing job with the new player form: so easy to use with such flexibility is rarely ever seen.

I encourage lots of people to use this; it would be a shame to see it go to waste

To Sumilion: You missed importing and exporting players, here is the code you can add:

Another great feature of the player form is the ability to import and export players from and to the "DeclarePlayers" Procedure, found in the "File" drop down menu

Basically, if you open a script with the procedure "DeclarePlayers" in it all properly filled out, it will parse them into the form for you, and saves you the trouble of having to do it yourself.

Furthermore, if you fill in all of your players in the form and want to put them into the DeclarePlayers format, select your army, and hit the export button. The full DeclarePlayers procedure will be automatically generated for you.

Please note: Importing player data may not always work as the script has to scripted with perfect standards for it to work, I.E:

[php]
Players[0].name := 'Starblaster100';
[/php]

Space between 'name' and ':=' and ':=' and the String / Number / Bool / Extended

Sumilion

2007-09-25 15:33:15

From: Starblaster100
I gotta say, Sum as done an amazing job with the new player form: so easy to use with such flexibility is rarely ever seen.

I encourage lots of people to use this; it would be a shame to see it go to waste


Thanks a lot star :) and i added your part now.

itSchRis917

2007-09-30 22:53:19

[Runtime Error] : Out Of Range in line 536 in script C:\Program Files\SCAR 3.11\includes\SRL\SRL\Core\Users.scar
Help is greatly appreciated.

Sumilion

2007-10-01 10:13:16

Erhm…
536 = {*******************************************************************************

for me…

What were you doing ?

itSchRis917

2007-10-01 17:13:42

Line 536 for me:

PlayerPages[TabNumber] := TTabSheet.Create(srl_PlayerForm);

I was just copying and pasting the parameters and such that you used in the above tutorial, wanting to see how it worked. I have called SetupSRL also, is there anything else i need to call?

Infantry001

2007-10-01 17:50:08

Maybe you don't have latest SRL perhaps? Or devs have different version of SRL?

itSchRis917

2007-10-01 18:11:04

Nevermind guys, got it.

Sumilion

2007-10-02 08:43:26

Were you perhaps using SRL 4 beta ? :p

itSchRis917

2007-10-02 14:25:52

No, i think i was using rev #3 of SRL 4.. :p

The Claw

2007-10-04 22:00:44

This is truly a great piece of scripting, I'm going to use it in all of my scripts now most likely. Good work sumilion. Where are the settings for your players and army details stored though?

Sumilion

2007-10-05 05:00:46

Scar > Chars.ini

n3ss3s

2007-10-05 05:38:57

Thank you!!

Since 4 Beta I was always wondering how do I set it up, even though I maybe could've read through the code, but very good tut 5/5! :D

The Claw

2007-10-05 07:35:03

Few suggestions:

- Add Players.Loc to the default form
- A few buttons along the side to press instead of going to Exit > Save or whatever
- Maybe the possibility to have default options in the boxes - so we could go ['Location - Bank'] and it would add it to Location, with the default as Bank.

:)

PhantomCode

2008-06-29 06:25:32

Thanks very much, Sum! I'm going to use this a lot.:D

@The Claw: That 3rd one is an awesome idea! (Chants at Devs "WE WANT DEFAULTS IN THE SRL PLAYERFORM!") :D

EDIT: Sorry for the bump but I give thanks where thanks are due!

the nerd

2008-07-22 17:35:14

I would like to point out the in SRL 4 Rev 20 the SRLPlayerForm(); functions is in the /misc/user.scar file which need to be added in the includes.

ScarScript:By Drunkenoldma [LEFT]{.include SRL/SRL/Misc/users.scar} [/LEFT]

Magiic

2008-08-11 04:34:27

yeah i always use this because its a lot easier than making people set up their players and somebody whos never used scar before who just wants to hack people wouldn't be able to run it so it adds a tad more security

XRaye

2008-08-11 12:13:24

From: the nerd
I would like to point out the in SRL 4 Rev 20 the SRLPlayerForm(); functions is in the /misc/user.scar file which need to be added in the includes.

ScarScript:By Drunkenoldma [LEFT]{.include SRL/SRL/Misc/users.scar} [/LEFT]



Thanks i was wondering what was going on, once i'm done adding it to my script i'll say how it went or if i need help.

EDIT:

How do i know the difference between booleans, integers, strings, and extendeds?

Mariuswbz

2008-08-15 13:30:47

Awesome. I'm going to use this in every script i make :P

spicynachos2

2008-09-30 01:44:14

kinda understand…

Clippi

2008-10-24 13:04:53

Nice gonna use this in every script from now on :)

wabakoo420

2009-01-04 15:32:28

Thanks! I was wondering how to set that up for a while.

Dervish

2010-05-08 07:32:24

This seems broken, sadly enough : /

BraK

2011-05-26 02:29:41

This is outdated until someone manages to fix the player form.

~BraK