Saving This?
#1

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.
Reply
#2

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.
Reply
#3

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]]);
}
Reply
#4

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.
Reply
#5

Thank you for your help
Reply
#6

Using an array basically means you want players to be able to have 15 jobs at once.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)