Ways of saving (yini) - 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: Ways of saving (yini) (
/showthread.php?tid=584460)
Ways of saving (yini) -
Lajko1 - 04.08.2015
I'm wondering if there's any better and more proper way of saving up to 15 player's crimes (for RP server)
What I did is this:
pawn Code:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths,
pCrime0,
pCrimeReason0[128],
pCrime1,
pCrimeReason1[128],
pCrime2,
pCrimeReason2[128]
// All way to 15 crimes
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Code:
CMD:suspect(playerid,params[])
{
new id, crime[128], string[128];
if(sscanf(params, "us[80]",id ,crime)) return SendClientMessage(playerid,-1,"USAGE: /suspect [PlayerID/Part of Name] [Crime]");
if(PlayerInfo[id][pCrime0] == 0)
{
format(string, sizeof(string), "Your crime is: %s", crime);
SendClientMessage(playerid, -1, string);
PlayerInfo[id][pCrime0] = 1;
PlayerInfo[id][pCrimeReason0] = crime;
}
else if(PlayerInfo[id][pCrime1] == 0)
{
format(string, sizeof(string), "Your crime is: %s", crime);
SendClientMessage(playerid, -1, string);
PlayerInfo[id][pCrime1] = 1;
PlayerInfo[id][pCrimeReason1] = crime;
}
else
{
format(string, sizeof(string), "Your crime is: %s", crime);
SendClientMessage(playerid, -1, string);
PlayerInfo[id][pCrime2] = 1;
PlayerInfo[id][pCrimeReason2] = crime;
}
return 1;
}
Re: Ways of saving (yini) -
Zonoya - 04.08.2015
Arrays, perhaps?
Like, instead of:
pCrime0 all the way to fifteen, have
Code:
pCrime[15],
pCrimeReasons[15][128],
Or something like that? You'd still have to save it all separately, though, I don't use Y_INI much for saving, so, couldn't help there.
Re: Ways of saving (yini) -
Lajko1 - 04.08.2015
Command remains in same way or is there any possibility of looping or whatever?