I want to use ini files to save player data, however I can't find a decent tutorial on the subject.
if I wanted to save multiple characters with 4 data types (Name, Pass, Nick, Pin), how would I do it...
I want to use ini files to save player data, however I can't find a decent tutorial on the subject.
if I wanted to save multiple characters with 4 data types (Name, Pass, Nick, Pin), how would I do it...
Current Script Project
Pot of flour gatherer - 95% done
Can't get Simba to work? Click here for a tutorial
Here is an example ini:Code:WriteINI procedure WriteINI(const Section, KeyName, NewString, FileName: string); ReadINI function ReadINI(const Section, KeyName, FileName: string): string; DeleteINI procedure DeleteINI(const Section, KeyName, FileName: string);
To read the key you would do ReadKey := ReadINI('section', 'keyname', AppPath + Filename);Originally Posted by filename.ini
That would return 'kyle'.
Write and read should be self explanatory I hope.
Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
Originally Posted by #srl
"A programmer is just a tool which converts caffeine into code"
here is how i increased my stats
Simba Code:Inc(Script_Total[TOTAL_HIGH_ALCHES]);
WriteINI('Script_Total', '1', IntToStr(Script_Total[TOTAL_HIGH_ALCHES]), ScriptPath + 'ScriptStats.INI');
IncEx(Script_Total[TOTAL_XP_GAINED], 65);
WriteINI('Script_Total', '3', IntToStr(Script_Total[TOTAL_XP_GAINED]), ScriptPath + 'ScriptStats.INI');
i read them like this
SCAR Code:procedure Script_Totals;
var
i : Integer;
begin
for i := 0 to 4 do
Script_Total[i] := StrToIntDef(ReadINI('Script_Total', IntToStr(i), ScriptPath + 'ScriptStats.INI'), 0);
Writeln(' Total Time Ran : ' + MsToTime(Script_Total[TOTAL_TIME_RAN], Time_Formal));
Writeln(' Total High Alches : ' + IntToStr(Script_Total[TOTAL_HIGH_ALCHES]));
Writeln(' Total Curses : ' + IntToStr(Script_Total[TOTAL_CURSES]));
Writeln(' Total XP Gained : ' + IntToStr(Script_Total[TOTAL_XP_GAINED]));
Writeln(' Script Runs : ' + IntToStr(Script_Total[TOTAL_STARTS]));
end;
for each player just do a for to do loop and write each players name, pin, etc
i didnt really explain it to well but i hope you get the idea
OK thanks guys, just a quick question on forms, can I open a second form (ie like load players form) and if you can, how, because CreateForm doesn't seem to be working...
Last edited by Bad Boy JH; 03-06-2011 at 06:40 AM.
Current Script Project
Pot of flour gatherer - 95% done
Can't get Simba to work? Click here for a tutorial
You can but iirc it can't be modal?
Edit: Idk what I'm talking about ? I done it before lon ago, search the forum.
Last edited by Sex; 03-06-2011 at 06:46 AM.
Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
Originally Posted by #srl
"A programmer is just a tool which converts caffeine into code"
I forgot to call ShowModal, but that freezed everything
so I just called Show, but that stuffed it up, because the function that loaded it kept working. Which means I can't load the player, any ideas?
In the mean time i may look into some other scripts with a form and load player.
Current Script Project
Pot of flour gatherer - 95% done
Can't get Simba to work? Click here for a tutorial
Show me what you put I'll do it.
Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
Originally Posted by #srl
"A programmer is just a tool which converts caffeine into code"
Got a method that makes it work, but when i free the sub-form it causes the error message "access violation"
Current Script Project
Pot of flour gatherer - 95% done
Can't get Simba to work? Click here for a tutorial
It's like your own personal SRL stats.How original and nice idea!
I found that here.Simba Code:Program FormTest;
var
frmDesign : TForm;
frmDesign2 : TForm;
OpenNewForm : TButton;
Label1 : TLabel;
Procedure ButtonClick(Sender: TObject); Forward;
Procedure InitForm;
Begin
frmDesign := TForm.Create(nil);
frmDesign.Left := 250;
frmDesign.Top := 114;
frmDesign.Width := 258;
frmDesign.Height := 118;
frmDesign.Caption := 'frmDesign';
frmDesign.Color := clBtnFace;
frmDesign.Font.Color := clWindowText;
frmDesign.Font.Height := -11;
frmDesign.Font.Name := 'MS Sans Serif';
frmDesign.Font.Style := [];
frmDesign.Visible := False;
frmDesign.PixelsPerInch := 96;
OpenNewForm := TButton.Create(frmDesign);
OpenNewForm.Parent := frmDesign;
OpenNewForm.Left := 88;
OpenNewForm.Top := 32;
OpenNewForm.Width := 89;
OpenNewForm.Height := 25;
OpenNewForm.Caption := 'Open New Form';
OpenNewForm.TabOrder := 8;
OpenNewForm.OnClick := @ButtonClick;
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 InitForm2;
Begin
frmDesign2 := TForm.Create(nil);
frmDesign2.Left := 288;
frmDesign2.Top := 151;
frmDesign2.Width := 172;
frmDesign2.Height := 61;
frmDesign2.Caption := 'frmDesign';
frmDesign2.Color := clBtnFace;
frmDesign2.Font.Color := clWindowText;
frmDesign2.Font.Height := -11;
frmDesign2.Font.Name := 'MS Sans Serif';
frmDesign2.Font.Style := [];
frmDesign2.Visible := False;
frmDesign2.PixelsPerInch := 96;
Label1 := TLabel.Create(frmDesign);
Label1.Parent := frmDesign2;
Label1.Left := 48;
Label1.Top := 8;
Label1.Width := 72;
Label1.Height := 13;
Label1.Caption := 'Yay New Form!';
End;
procedure SafeInitForm2;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm2', v);
end;
procedure ShowFormModal2;
begin
frmDesign2.ShowModal;
end;
procedure SafeShowFormModal2;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('ShowFormModal2', v);
end;
Procedure ButtonClick(Sender: TObject);
Begin
Case Sender Of
OpenNewForm :
Begin
SafeInitForm2;
SafeShowFormModal2;
End;
End;
End;
Begin
SafeInitForm;
SafeShowFormModal;
End.
Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
Originally Posted by #srl
"A programmer is just a tool which converts caffeine into code"
There are currently 1 users browsing this thread. (0 members and 1 guests)