Saving This? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Saving This? (
/showthread.php?tid=340625)
Saving This? -
Mento - 08.05.2012
How do I save something like this:
pawn Код:
enum pInfo
{
jobs[15],
}
PlayerFiles[MAX_PLAYERS][pInfo];
Do I do this?
pawn Код:
INI_WriteInt(File, "Job1", PlayerFiles[playerid][pJobs[0]]);
...
INI_WriteInt(File, "Job1", PlayerFiles[playerid][pJobs[14]])
Or
pawn Код:
INI_WriteInt(playerid, "Job", PlayerFiles[playerid][pJobs])
Would that save all of them?
Please help me, thanks.
Re: Saving This? -
JaTochNietDan - 08.05.2012
You could use a simple loop:
pawn Код:
new str[5];
for(new i; i < 15; i++)
{
format(str, sizeof(str), "Job%d", i);
INI_WriteInt(File, str, PlayerFiles[playerid][pJobs[i]]);
}
Hope that helps.
Re: Saving This? -
Mento - 08.05.2012
So this way, it will save 15 different things in the player's file? Because I want to be able to use it like that, and how would I load them?
pawn Код:
new str[5];
for(new i; i < 15; i++)
{
format(str, sizeof(str), "Job%d", i);
INI_Int(str, PlayerFiles[playerid][pJobs[i]]);
}
Re: Saving This? -
JaTochNietDan - 08.05.2012
Indeed. It's basically the same as writing them out one by one except you're saving space and time.
It just repeats that bit of code while incrementing the i variable which is used to identify which one you are saving.
Re: Saving This? -
Mento - 08.05.2012
Thank you for your help
Re: Saving This? -
ReneG - 08.05.2012
Using an array basically means you want players to be able to have 15 jobs at once.