[Help]Dini, again - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help]Dini, again (
/showthread.php?tid=109140)
[Help]Dini, again -
Dirty_bum - 18.11.2009
Hi i need help with dini, again..
I've done this code practicing round with it
pawn Код:
#include <a_samp>
#include <zcmd>
public OnPlayerConnect(playerid)
{
new file[50], Float:Armour;
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "%s.ini", name);
if(!dini_Exists(file))
{
dini_Create(file);
dini_FloatSet(file, "Armour", 0);
printf("%s's file created", name);
}
else
{
Armour = dini_Float(file, "Armour");
SetPlayerArmour(playerid, Armour);
printf("%s's file loaded", name);
}
return 1;
}
COMMAND:atest(playerid, params[])
{
SetPlayerArmour(playerid, 100);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
new Float:Armour, file[50];
GetPlayerArmour(playerid, Armour);
dini_FloatSet(file, "Armour", Armour);
return 1;
}
It does work getting the players armour on connect, but when leaving it doesnt set the new armour value...anyone know why?
Thanks
Re: [Help]Dini, again - Zeex - 18.11.2009
That's because you didn't set the file name before you write the data to it
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[50], Float:Armour;
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "%s.ini", name);
GetPlayerArmour(playerid, Armour);
dini_FloatSet(file, "Armour", Armour);
return 1;
}
Re: [Help]Dini, again -
Dirty_bum - 18.11.2009
god im nub, thx
Re: [Help]Dini, again -
LarzI - 18.11.2009
I recommend using udb_encode for player files.
Since a player might have special characters in his name/nick and therefore the file can't be saved.