help quick - 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: help quick (
/showthread.php?tid=496393)
help quick -
Mriss - 21.02.2014
Im making a score save system with Dini, when I log in and get score then log out it saves, but when I log in again it doesnt load the score... whats the code to do this, This is my OnPlayerConnect
Код:
public OnPlayerConnect(playerid)
{
new string[128];
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, sizeof(plname));
PlayerInfo[playerid][Level] = 0;
PlayerInfo[playerid][Money] = 0;
PlayerInfo[playerid][Vip] = 0;
PlayerInfo[playerid][Admin] = 0;
PlayerInfo[playerid][Spawn] = 0;
PlayerInfo[playerid][Score] = 0;
format(string, sizeof(string), "/accounts/%s.ini", plname);
if(dini_Exists(string))
{
gPlayerAccount[playerid] = 1;
}
else
{
gPlayerAccount[playerid] = 0;
}
return 1;
}
OnPlayerDisconnect
Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),"/accounts/%s.ini",name);
if(dini_Exists(file))
{
dini_IntSet(file, "Password",PlayerInfo[playerid][Pass]);
dini_IntSet(file, "Level",PlayerInfo[playerid][Level]);
dini_IntSet(file, "Money",PlayerInfo[playerid][Money]);
dini_IntSet(file, "Admin",PlayerInfo[playerid][Admin]);
dini_IntSet(file, "Vip",PlayerInfo[playerid][Vip]);
dini_IntSet(file, "Spawn",PlayerInfo[playerid][Spawn]);
dini_IntSet(file, "Score", GetPlayerScore(playerid));
}
gPlayerLogged[playerid] = 0;
return 1;
}
Re: help quick -
Dignity - 21.02.2014
You set the score to be 0 without checking if the player is unregistered first.
pawn Код:
public OnPlayerConnect(playerid)
{
new string[128];
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, sizeof(plname));
format(string, sizeof(string), "/accounts/%s.ini", plname);
if(dini_Exists(string))
{
gPlayerAccount[playerid] = 1;
}
else
{
gPlayerAccount[playerid] = 0;
PlayerInfo[playerid][Level] = 0;
PlayerInfo[playerid][Money] = 0;
PlayerInfo[playerid][Vip] = 0;
PlayerInfo[playerid][Admin] = 0;
PlayerInfo[playerid][Spawn] = 0;
PlayerInfo[playerid][Score] = 0;
}
return 1;
}
Try this ^
Re: help quick -
Mriss - 21.02.2014
Dsnt work, when I got some score then logged out, this is what my .ini file looked like...
Код:
Password=257753960
Money=0
Admin=10
Vip=0
Spawn=0
Level=0
Score=15