[BANANA][LEFT]The first thing where going to do, is make the base, the TForm with his standard code. We will give the form a Height*Width of 800*600. You should not make your form much bigger because there are people who don't have a big screen. Yes this might be to large, but we will get rid of the left over space once the complete form design is done.
var
frmDesign: TForm;
procedure InitForm;
begin
frmDesign := CreateForm;
frmDesign.Left := 100;
frmDesign.Top := 100;
frmDesign.Width := 800;
frmDesign.Height := 600;
frmDesign.Caption := 'Test!'; // Rename to whatever you want
frmDesign.Color := ClWhite;
frmDesign.Font.Color := ClBlack;
end;
procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;
procedure ShowFormModal;
begin
frmDesign.ShowModal;
end;
procedure SafeShowFormModal;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal', v);
end;
Procedure ShowPlayerForm;
begin
SafeInitForm;
SafeShowFormModal;
end;
{In your script you just have to call ShowPlayerForm;}
Begin
ShowPlayerForm;
End.
[/LEFT]
[/BANANA]
[BANANA][LEFT]Now we are going to add items to our form. We will start of with the TListBox. Why not the banner first? That is because we don't know the width of our form yet, and so also not from the banner. Since we only have 1 TListBox, we don't have to put it in an array. So lets add it to our global variables, at the top of our script.
Var // and also your TForm will be in this variable list obviously
PlayerList: TListBox;
Now, to create the listbox in your form. We will set the .Top to 120, because we need to keep some space for banner, wish we will make later.
PlayerList := TListBox.Create(FrmDesign);
PlayerList.Parent := FrmDesign;
PlayerList.Top := 120;
PlayerList.Left := 10;
PlayerList.Width := 100;
PlayerList.Height := 170;
PlayerList.OnClick := @ItemClicked;
When you have added that to your form, you'll notice your script wont work. That's true, because we don't have the ItemClicked procedure yet. We are going to use the same .OnClick procedure for every OnClick we will get.
We do that as the following for our PlayerList:
Procedure ItemClicked(Sender: TObject);
Begin
Case Sender Of
PlayerList: Begin
// leave it empty for now
End;
End;
End;
Make sure you place the procedure above the form setup.
When you click on the PlayerList in the form, nothing will happen, and the list is empty. We will leave it that way for now, because we first want to make all components are in the right place.[/LEFT]
[/BANANA]
[BANANA][LEFT]The next thing we are going to add to our form, are the buttons. Since we have 7 buttons, we will put the TButton in an array, to keep our code short and easy over viewable.
So we are going to add three variables to the global vars.
- The button array (0 til 6)
- An integer for the loop
- A string array for the button captions
That will look like the following:
Var
Buttons: Array [0..6] Of TButton;
I: Integer;
CaptionA: Array Of String;
Lets move on to the setup of the buttons in the form. We will use a For To Do loop, to do all the buttons. There will be 2 lines of buttons. The line at the right of the ListBox, and a line horizontal under the ListBox. We are not going to set the button position for every button, we will use a small formula instaid.
CaptionA := ['Load player list', 'Save player list', 'Add player',
'Delete player', 'Start script', 'Exit without saving', 'Save and Exit'];
For I := 0 To 6 Do // See*
Begin
Buttons[I] := TButton.Create(FrmDesign);
Buttons[I].Parent := FrmDesign;
Buttons[I].Height := 20;
Buttons[I].OnClick := @ItemClicked;
Buttons[I].Caption := CaptionA[I];
Case I Of
0..3: Begin // case 0, 1, 2, 3
Buttons[I].Left := 120;
Buttons[I].Top := 150 + I * 30;
Buttons[I].Width := 100;
End;
4..6: Begin // case 4, 5, 6
Buttons[I].Left := 10 + 160 * (I - 4); // See**
Buttons[I].Top := 300;
Buttons[I].Width := 150;
End;
End;
End;
* With this loop the script will first setup button[0], then button[1], ect, until button[6].
** Why the -4? else the .Left of Buttons[4] will be: 10 + 160 * 4, and then the button would be way to much to the right. So don't forget the -4
The code above will take care of ALL your buttons. Take a very good look at the code above, and try to understand what the script exactly does.
In the setup of the button we have called at all buttons @ItemClick; as onclick procedure. To see if all your buttons work you should replace your ItemClick procedure with this:
Procedure ItemClicked(Sender: TObject);
Begin
Case Sender Of
PlayerList: Begin
// keep empty for now
End;
Buttons[0]: Begin
WriteLn('[BUTTON] Load players');
End;
Buttons[1]: Begin
WriteLn('[BUTTON] Save players');
End;
Buttons[2]: Begin
WriteLn('[BUTTON] Add player');
End;
Buttons[3]: Begin
WriteLn('[BUTTON] Delete player');
End;
Buttons[4]: Begin
WriteLn('[BUTTON] Start script');
End;
Buttons[5]: Begin
WriteLn('[BUTTON] Stop without save');
End;
Buttons[6]: Begin
WriteLn('[BUTTON] Stop but save first');
End;
End;
End;
When you run your script again, you will see that the debug says what you clicked when you click on a button.[/LEFT]
[/BANANA]
[BANANA][LEFT]We are going to make 1 button working already. The "Exit without save" button. We need this button working because we are going to remove the "Frame" of the form (the frame where you can close the form, mini and maxi size it).
Before we do that we are going to add a new variable to your script:
Var
StartReady: Boolean;
We need this variable to let the script know when the start button is pressed, cause if the start button is not pressed, but one of the exit buttons, the script should terminate after closing the form.
Lets go to Procedure ShowPlayerForm; and change it to this:
Procedure ShowPlayerForm;
begin
SafeInitForm;
SafeShowFormModal;
If Not StartReady Then TerminateScript;
end;
This action is very important.
Now, before removing the forms frame, we are going to make the "Exit without save" working. Go to your ItemClick procedure, and change Button[5] to This:
Buttons[5]: Begin
frmDesign.ModalResult:= mrOk; // this will close the form
End;
When you run your form again, you'll see that the form closes when you press the button. We can remove the forms frame now, and you'll still be able to close the form.
Add this to your form setup:
frmDesign.BorderStyle := bsNone;
Now you successfully removed the frame. Now, since the background color of the form is white, it won't be good visible. So we will change the forms background color to red. This might be ugly, but later in the tutorial we will add a image as background, wish will give you form an amazing look.
Change the background color of your form to red:
frmDesign.Color := ClRed;
Now, we also know the height of our form already! we can shorten the height of your form so all that extra space won't be there anymore, since we are not going to use it. I can tell you the form height should be "330" now, don't make it any less, cause some of your buttons won't be visible anymore! (If you did it anyway you can close your form by pressing ALT+F4). So lets change the forms height to 330:
frmDesign.Height := 330;
[/LEFT]
[/BANANA]
[BANANA][LEFT]In this step we are going to add the labels to the form. The labels will tell the user what to put in the box next to it. We need to make 8 labels. So we will make an array from 0 to 7. Add this to your vars:
Var
Labels: Array [0..7] Of TLabel;
We will also need I and CaptionA again, but we don't have to declare them again in the global vars, since there already in there.
Lets create the labels in your form:
CaptionA := ['Players name', 'Players pass', 'Players nick', 'Players Pin',
'Loads till switch', 'Use this player?', 'SRL ID', 'SRL Pass'];
For I := 0 To 7 Do // See*
Begin
Labels[I] := TLabel.Create(FrmDesign);
Labels[I].Parent := FrmDesign;
Labels[I].Caption := CaptionA[I];
Case I Of
0..5: Begin
Labels[I].Top := 120 + 30 * I;
Labels[I].Left := 230;
End;
6, 7: Begin
Labels[I].Top := 180 + 30 * (I - 6); // See**
Labels[I].Left := 450;
End;
End;
End;
* the loop will do Labels[1], then Labels[2], ect, until Labels[7]
** Again don't forget to do the -6, else it won't be at the correct position
And actually that's all about the labels :)[/LEFT]
[/BANANA]
[BANANA][LEFT]Then it's time to add the edit boxes! We will make 6 TEdits. Why not 8? cause for the "players.active" and the "players.loads" we are going to use a TComboBox. But we will start of making the TEdits now.
So we are going to make 6 TEdit's, that will make it an array form 0 to 5:
Var
Edits: Array [0..5] Of TEdit;
Then, to create your editboxes in your form, add this to your form setup:
For I := 0 To 5 Do
Begin
Edits[I] := TEdit.Create(FrmDesign);
Edits[I].Parent := FrmDesign;
Edits[I].Width := 100;
Edits[I].Height := 20;
Case I Of
0..3: Begin
Edits[I].Left := 340;
Edits[I].Top := 120 + 30 * I;
End;
4, 5: Begin
Edits[I].Left := 540;
Edits[I].Top := 180 + 30 * (I - 4); // See*
End;
End;
End;
Edits[1].PasswordChar := '*'; // See **
Edits[3].PasswordChar := '*';
Edits[5].PasswordChar := '*';
Edits[2].MaxLength := 4; // See***
Edits[3].MaxLength := 4;
* Again, don't forget the -4
** with this other people can't see your password, except for "password" they will see "********"
*** People's nickname should not be longer then 4, and there pin can be max 4 numbers
Checkout the PasswordChar and MaxLength. Those are really cool tools to make your form more user friendly and better. We don't have to do anything more to those :)[/LEFT]
[/BANANA]
[BANANA][LEFT]We can already see what the width of the form should be, but before we are going to edit that we will add the TComboBoxes first.
2 empty spots in the form, so we are going to make an array form 0 to 1 in your global vars:
Var
ComboBoxes: Array [0..1] Of TComboBox;
And to create your ComboBoxes in the form, add this to your form setup:
For I := 0 To 1 Do
Begin
ComboBoxes[I] := TComboBox.Create(FrmDesign);
ComboBoxes[I].Parent := FrmDesign;
ComboBoxes[I].width := 100;
ComboBoxes[I].Height := 20;
ComboBoxes[I].Left := 340;
ComboBoxes[I].Top := 240 + 30 * I;
End;
ComboBoxes[0].Items.Add('3'); // adding options to your combobox
ComboBoxes[0].Items.Add('4');
ComboBoxes[0].Items.Add('5');
ComboBoxes[0].Items.Add('6');
ComboBoxes[0].Items.Add('7');
ComboBoxes[1].Items.Add('True');
ComboBoxes[1].Items.Add('False');
Adding items to your boxes takes some space, but it's not worth putting those in an array ;)
And that's already it for the combo boxes![/LEFT]
[/BANANA]
[banana][left]Yesss, it's allmost time to get our banner, and to get rid of that ugly red background! But before we are going to do that we need to fix the width of your form.
Edit this in your form setup:
frmDesign.Width := 650;
Perfect! you now also know what the width and height of your banner and background should be!
Banner: 630 * 100
Background: 650 * 330[/left]
[/banana]
[banana][left]In this step, we will give your form a very nice look! Before we are going to add any code, we need to have our images ready. One for the background, and one for the banner. I Made those 2 already for this tutorial, but feel free to make your own.
Go to your scar folder, and create a new folder. We are going to call it "MKFormTut". Now, in your new map you'll have to save your 2 files. I'll call them "formbanner1.bmp" and "formbackground.bmp".
formbackground.bmp
formbanner1.bmp
Make sure you save them in the correct folder. If your not sure where to exactly where to save them you can run this small script in a new scar:
Begin
ClearDeBug;
WriteLn(AppPath + 'MKFormTut\');
WriteLn('');
End.
Now, we are going to add the images to the global vars. We have 2 images so an array from 0 to 1:
Var
Images: Array [0..1] Of TImage;
Before we start adding the images to the form, we have 3 new variables to add. b, w, h: integer;. Since we only need those 3 vars in the form setup, we will add the variables to the setup form procedure:
procedure InitForm;
Var
b, w, h: Integer;
begin
// ect
Now it's time to add the images to the form setup. NOTE: the images must be declared between the TForm and the First other object (the TListBox in this case)! Here we go:
// TForm setup is here
For I := 0 To 1 Do
Begin
Images[I] := TImage.Create(FrmDesign);
Images[I].Parent := FrmDesign;
Case I Of
0: Begin
Images[I].Width := 650;
Images[I].Height := 330;
b := loadbitmap(AppPath + 'MKFormTut\formbackground.bmp'); // See*
getbitmapsize(b, w, h);
copycanvas(getbitmapcanvas(b), Images[I].canvas, 0, 0, w,
h, 0, 0, w, h);
End;
1: Begin
Images[I].Width := 630;
Images[I].Height := 100;
Images[I].Left := 10;
Images[I].Top := 10;
b := loadbitmap(AppPath + 'MKFormTut\formbanner1.bmp'); // See*
getbitmapsize(b, w, h);
copycanvas(getbitmapcanvas(b), Images[I].canvas, 0, 0, w,
h, 0, 0, w, h);
End;
End;
End;
// all other TObjects are here
* If you gave it an other name, then set it to the other name of cause.
… ect
Your form must look awesome now! If your not happy with your background, just change the bmp file and restart the script to see the new background/banner.[/left]
[/banana]
[banana][left]Then, it's time to add our TTimer, because we don't want to bore people with the same banner all the time :)
I made some more banners to add to our form:
banner1
banner2
banner3
Name them to whatever you want. But make sure you save them in your own folder. For this tutorial they need to come in your MKFormTut\ folder.
First of this step, we are going to add the timer to your script. We will need the timer to change the banner images. Add the TTimer to your global vars:
Var
BannerTimer: TTimer;
And now, setup the timer in your form setup:
BannerTimer := TTimer.Create(FrmDesign);
BannerTimer.Interval := 5000; // See*
BannerTimer.Enabled := True; // See**
BannerTimer.OnTimer := @ItemClicked; // See***
* We want our banner to change every 5 seconds
** Activate your timer
*** ItemClicked also works for your timer, so why not use it?
Now we have our timer working, nothing is happening yet though. True, so lets change that! We will need a new global var so the script can remember wish banner it should display next:
Var
CurBanner: Integer;
We also need to add the, b, w and h again. This time we will add it tho the ItemClicked procedure:
Procedure ItemClicked(Sender: TObject);
Var
b, h, w: Integer;
Then, lets add the BannerTimer, to the case in ItemClicked:
Case Sender Of
BannerTimer: Begin
Case CurBanner Of // See*
0: b := loadbitmap(AppPath + 'MKFormTut\pcbanner.bmp'); // See**
1: b := loadbitmap(AppPath + 'MKFormTut\srlbanner.bmp');
2: b := loadbitmap(AppPath + 'MKFormTut\ownbanner.bmp');
3: b := loadbitmap(AppPath + 'MKFormTut\formbanner.bmp');
End;
getbitmapsize(b, w, h);
copycanvas(getbitmapcanvas(b), Images[1].canvas, 0, 0,
w, h, 0, 0, w, h);
CurBanner := CurBanner + 1; // See***
If CurBanner > 3 Then CurBanner := 0; // See****
End;
// and here are your other clickitems
* For B we need to load the current bitmap, to display as banner.
** Make sure your file is at the correct space, and change the name to what you called your banner
*** To display the next banner next time, you need to add 1 to the current banner.
**** The script can't display a banner that doesn't exists. So when you had your last banner we will go back to banner 0
And there you go! Changing banners! Awesome![/left]
[/banana]
Congratz! You now have the base of an awesome looking form!
[banana][left]You have completed the look of your form, and you have all the TComponents you need. Now it's time to make it work, and let the form actually do something!
The first thing we are going to make work is the Add new player button. And with this step there comes a lot more then just the button's procedure. You see, all the players in your form, must be stored, in an array. An array wish holds all the info from the player setup boxes for all players created in the from :)
We are going to make an array of TFormPlayer. TFormPlayer? is that correct? Yes, but it doesn't exist yet. Lets make a new type, and so create the TFormPlayer variable
Type
TFormPlayer = Record
Name, Pass, Nick, Pin, Loads, Active: String;
End;
So, for every box you have in your form, you add a string to your new Type. (or at least for what every player needs to have)
Lets make a new variable: FP (form players) Add it to your global vars. We also want to add the variable "CurFP: Integer;". This one is there for the form to know what player it's showing at that moment.
CurFP: Integer;
FP: Array Of TFormPlayer;
Now, we have the stuff where we can store all players in your form. We will later convert it to Players[].Name, ect.
We have made the new array for all of the players now. When we start the form, we want to have at least one player already. So we go to your ShowPlayerForm; procedure, and add the following to it:
Procedure ShowPlayerForm;
begin
SetArrayLength(FP, 1); // *
SafeInitForm;
SafeShowFormModal;
If Not StartReady Then TerminateScript;
end;
* Now we have one player, so the form is ready to store the new player strings in that FP part.
The FP part is done! Now it's time to make the AddPlayerButton work.
When a users hits the add player button, we simply have to add a new part to the FP array. We do that by making the length of the array bigger.
Jump to your ItemClicked procedure. There we have to work on our Add Player part. Within the add player case we are going to add this:
Buttons[2]: Begin
SetArrayLength(FP, GetArrayLength(FP) + 1);
End;
* This will add a new player to your FP array, and gives you space for another form player.
** We need to let the form know, that we are going to edit the latest and newest player.
Yay, now every time, you click the "add player button", you add a new player to your FP array! yaaaaaaaaaaaaaaaaaaay!
But wait, nothing seems be happening? That's not true. We just need to visualize it. And that's where we are going to make the LoadPlayer(); procedure for. To finnish your "AddNewPlayer" button, we add this to your code:
Buttons[2]: Begin
SetArrayLength(FP, GetArrayLength(FP) + 1);
LoadFP(High(FP), True); // *
End;
* Yes, you have an error now, and if you want to fix that you better hurry to step 12! :)
[/left][/banana]
[banana][left]YES! It's time we actually make the big major procedure! Procedure LoadFP();! This is the place where all your player info gets loaded, and saved into the FP array. And most important of all, here will all your stuff get visualized!
What this procedure is going to do is:
- Save your player info form your latest edit
- Load the players info of the player you want to edit now
- Show in the listbox all your players
- Show all the players data in the form for the current player (CurFP)
This procedure is the key to everything in your code.
So the first thing we are going to do, is create the new form procedure: (make sure you create it above the ItemClicked procedure)
Procedure LoadFP(WhatPlayer: Integer; SaveCurrentInfo: Boolean);
Begin
End;
As you can see I have added 2 variables in the procedure. WhatPlayer; this is the integer the script need of wish player it has to load this time. SaveCurrentInfo; Does the script want to save the info of the player wish is currently displayed.
When you have created this procedure you'll see that your script has no errors anymore ;) And that makes it time to make the procedure actually do something.
The first thing the scripts need to do, is to save the current player, before we change all the boxes, else it won't saved correctly, or just not saved at all. We start with the following code:
If SaveCurrentInfo Then
Begin
FP[CurFP].Name := Edits[0].Text;
FP[CurFP].Pass := Edits[1].Text;
FP[CurFP].Nick := Edits[2].Text;
FP[CurFP].Pin := Edits[3].Text;
FP[CurFP].Loads := ComboBoxes[0].Text;
FP[CurFP].Active := ComboBoxes[1].Text;
End;
Now we are sure new player info has been saved and we can start loading an other player! The first thing I would like to do is giving the TListBox an update, so users can overview there players when changes are made. We do that by first clearing the box, and then loading the player list in again:
Var
I: Integer; // add this at the top of the procedure!
// add this below the save player (in LoadFP)
PlayerList.Clear;
For I := 0 To High(FP) Do
If (FP[I].Name = '') Then
PlayerList.Items.Add(IntToStr(I) + ': ?')
Else
PlayerList.Items.Add(IntToStr(I) + ': ' + FP[I].Name);
That will show a clear list of your players, numbered and players without a name yet will get a "?".
The next step in LoadFP is that we need to load in the player we want to see now. We will fill the Edits and ComboBoxes up with the new CurFP:
CurFP := WhatPlayer;
PlayerList.ItemIndex := CurFP; // *
Edits[0].Text := FP[CurFP].Name;
Edits[1].Text := FP[CurFP].Pass;
Edits[2].Text := FP[CurFP].Nick;
Edits[3].Text := FP[CurFP].Pin;
ComboBoxes[0].Text := FP[CurFP].Loads;
ComboBoxes[1].Text := FP[CurFP].Active;
* Here we highlight the new CurFP in the listbox
The last, but also very important thing, is to disable the "delete player" button, when there are less then 2 players. This is to prevent out of range errors, because you can't delete players if they don't exist. We will make a check like this:
Buttons[3].Enabled := (GetArrayLength(FP) > 1);
That line might look a bit weird, but this is what it does: When there is more then 1 form player, it will enable the delete button, if there is only one, it will disable it.
Congrats! LoadFP should be done for now! But you might have noticed, when you click the "add player" button you have 2 players? That's correct, because you already had one when you loaded the form, but you didn't see it yet. To fix this you'll have to add this at the bottom of your InitForm; procedure:
LoadFP(0, False);
[/left][/banana]
[banana][left]OnClick PlayerList
When a user clicks on a char's name in the player list, the form should load in that player right after his name has been clicked. We can do this very very easily (thanks to LoadFP() <3 <3 <3).
Go to your ItemClicked() procedure, there you find the onclick for PlayerList:. When a users clicks on a name, the PlayerList.ItemIndex will change to the array number of the clicked item in the list. Since the player names and positions in the player list perfectly match, we can just use that value for LoadFP:
PlayerList: Begin
LoadFP(PlayerList.ItemIndex, True);
End;
And as you see above, the safe value is true, we don't want edited player info to get lost.[/left][/banana]
[banana][left][BUTTON] Delete player
Omg I made a bullshit player and I want it out of my list. THAT'S POSSIBLE, with the delete button. This button has a very nasty peace of code, and it might be hard to understand, but I will try to explain it as good as I can.
When you are going to delete a player, the FP array needs to get smaller. When you want to delete the last player of the list, it's simple. Just say HowMany FP = -1. But what if you want to delete player 3 of 5? Then there will be a gap in your array, so this is how it's done to prevent gap's like that:
To remove player 3 of 5, you need to move player 4 to position 3, and player 5 to position 4. This will remove player 3 without making a gap. When you've moved all players after the player you want to delete, you can make the array smaller, with SetArrayLenght(-1).
So in our delete player procedure we have 3 situations:
situation 1. The player you want to delete is the last player of the list.
situation 2. The player you want to delete is the last BUT 1 player of the list.
situation 3. The player you want to delete has 2 or more charterers after it.
We have to make the delete button work with all these 3 situations, and they will all work a little bit different!
I'll show you the source of how it's done (very short but powerfull code):
Buttons[3]: Begin
//WriteLn('[BUTTON] Delete player');
If Not (CurFP = High(FP)) Then // *
If (CurFP + 1 = High(FP)) Then
FP[CurFP] := FP[High(FP)] // **
Else
For I := CurFP To High(FP) - 1 Do // ***
FP[I] := FP[I + 1];
SetArrayLength(FP, GetArrayLength(FP) - 1); // ****
LoadFP(High(FP), False); // *****
End;
* When the case is situation 1, we don't have to peform any actions yet, we will just have to remove 1 player at the end of the procedure.
** When the case is situation 2, we have to switch the last player, to the "last but one" position! After that we can remove the last player at the end of the procedure.
*** When the case is situation 3, we have to switch all players, after the CurFP, a place back in the array. After that we can remove the last player at the end of the procedure.
**** This is where you say to your array, remove the last player of the array. This is fine to do now, since you have switched all your players in the array already.
***** After you have removed a player, your form has to load an other player and update the PlayerList! we do that with LoadFP() <3
As I said above, the procedure might be very hard to understand. If you still don't get anything, feel free to PM me or make a post in this thread.[/left][/banana]
[banana][left]The probably, most important button of the script! THE START BUTTON! MUAHAHAHA.
AT THIS POINT ADD {.include srl\srl.scar} TO YOUR SCRIPT!
You might have noticed, that all the players are now saved in FP[], all in strings. What we need to do now is to convert all strings into the SRL Players[] stoof! We have to convert the FP[].Name to Players[].Name, but also stuff like: FP[].Loads (STRING) to Players[].Integers[] (INTEGER). And that can't be done with some error checking, since you cannot convert the string "I would like to do 8 loads please" to the integer 8.
When you click the start button, the script will loop trough all your players, checking for a correct setup. This will be very user and script friendly. For example: when you forgot to fill in your players nickname at player number 3, the script will load player 3 for you and say "oops, it seems like you forgot player 3 his nick!". To do this for all players and there subs like "name, nick, ect", will take some space of code, but, in trade for that it will result a very nice user friendly script.
Before you start you have to save your current player. You just add "LoadFP(CurFP, True);" to the begin of your OnStartClick. we also need to set the length of your of players[] already. We do that like this:
Note that the script does do nothing with the srl stats boxes, this is because the srl stats system is currently down, and I'll update it when it's back
Buttons[4]: Begin
//WriteLn('[BUTTON] start script');
LoadFP(CurFP, True);
SetArrayLength(Players, GetArrayLength(FP));
For I := 0 To High(FP) Do
Begin
SetArrayLength(Players[I].Integers, 1); // *
SetArrayLength(Players[I].Strings, 0); // **
SetArrayLength(Players[I].Booleans, 1); // ***
If (FP[I].Name = '') Then
Begin
LoadFP(I, False);
ShowMessage('Oops, you forgot to give player ' + IntToStr(I) + ' a name!');
Exit;
End Else
Players[I].Name := FP[I].Name;
If (FP[I].Pass = '') Then
Begin
LoadFP(I, False);
ShowMessage('Oops, you forgot ' + FP[I].Name + ' his password!');
Exit;
End Else
Players[I].Pass := FP[I].Pass;
If (FP[I].Nick = '') Then
Begin
LoadFP(I, False);
ShowMessage('Oops, you forgot ' + FP[I].Name + ' his nickname!');
Exit;
End Else
Players[I].Nick := FP[I].Nick;
Players[I].Pin := FP[I].Pin; // no need to check
Try
Players[I].Integers[0] := StrToInt(FP[I].Loads);
Except
LoadFP(I, False);
ShowMessage('Oops, ' + FP[I].Name + ' has a wrong "loads" amoult!' +
' make sure it''s number only!');
Exit;
End;
Try
Players[I].Active := StrToBool(FP[I].Active);
Except
LoadFP(I, False);
ShowMessage('Oops, ' + FP[I].Name + ' has a wrong "active" amoult!' +
' choose an option from the drop down box!');
Exit;
End;
End;
StartReady := true;
frmDesign.ModalResult:= mrOk; // ****
End;
* Very important! here you must say how many custom integers your adding to your players[]
** Very important! here you must say how many custom strings your adding to your players[]
*** Very important! here you must say how many custom booleans your adding to your players[]
**** When the script gets at this line, it means that every player was succesfully checked, and that ALL your players are now in the old Players[CurrentPlayer]. stuff! READY TO ABUSE YOUR SCRIPT! With this like the form closes and continues the script!!!!!!!!!!!!!!!!!!! THE FORM IS WORKING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[/left]CONGRATS!
The script is working and it should now be working with your script!
If you got a smooth result, feel free to post a screenshot and I will make sure it ends up in the "wall of fame"[/banana]
[banana][left]Download background and banner[/left][/banana]