Help! - 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! (
/showthread.php?tid=160860)
Help! -
Lorenc_ - 18.07.2010
Hello, I got a problem with my XP system.. When i go to my accounts directory and set my XP to like 100 then join the server, it loads but when i disconnect it dosent save for some reason...
My code:
pawn Код:
if(dini_Exists(file))
{
dini_IntSet(file, "XP", PlayerInfo[playerid][pXP]);
}
^^ OnPlayerDisconnect
pawn Код:
forward PlayerXPTimer(playerid);
public PlayerXPTimer(playerid)
{
if(gPlayerLogged[playerid] == 1)
{
new file[128];
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(file, sizeof(file), ACC_FOLDER, pname);
new string[128];
TextDrawHideForPlayer(playerid, TDSTATS[playerid]);
format(string, sizeof(string), "~p~XP:%d", dini_Int(file, "XP"));
TextDrawSetString(TDSTATS[playerid], string);
TextDrawShowForPlayer(playerid, TDSTATS[playerid]);
}
}
^^ The timer that never ends - ( for updating the status of XP ) and that timer in on the login section..
Does anyone know how to fix this
Help xD
Re: Help! -
Jeffry - 18.07.2010
If the "file" path correct?
And what does it save in your userfile?
Re: Help! -
Lorenc_ - 18.07.2010
Quote:
Originally Posted by Jeffry
If the "file" path correct?
And what does it save in your userfile?
|
Here:
pawn Код:
#define ACC_FOLDER "%s.ini"
^^ thats the directory
and it saves this:
Re: Help! -
Grim_ - 18.07.2010
Are you setting PlayerInfo[playerid][pXP] to the amount of XP in the file when they login?
pawn Код:
PlayerInfo[playerid][pXP] = dini_Int(file, "XP");
Re: Help! -
Lorenc_ - 18.07.2010
Quote:
Originally Posted by Grim_
Are you setting PlayerInfo[playerid][pXP] to the amount of XP in the file when they login?
pawn Код:
PlayerInfo[playerid][pXP] = dini_Int(file, "XP");
|
No, I set a timer on the login part so it can load the settings... Scroll up.. I've pasted the timer on the topic.
anyways,
this is how it should be right?
pawn Код:
format(string, sizeof(string), "~p~XP:%d", dini_Int(file, "XP"));
TextDrawSetString(TDSTATS[playerid], string);
Re: Help! -
Jeffry - 18.07.2010
Can you post your OnPlayerDisconnect. I think you first set the variable to "0" and then you save it.
Re: Help! -
Lorenc_ - 18.07.2010
Sure,
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),ACC_FOLDER,name);
if(dini_Exists(file))
{
dini_IntSet(file, "XP", PlayerInfo[playerid][pXP]);
}
gPlayerLogged[playerid] = 0;
return 1;
}
Re: Help! -
Lorenc_ - 20.07.2010
Long bump
Re: Help! -
Jeffry - 20.07.2010
Maybe try:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new file[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(file,sizeof(file),ACC_FOLDER,name);
new tmp[20];
format(tmp, 20, "%d", PlayerInfo[playerid][pXP]);
if(dini_Exists(file))
{
dini_IntSet(file, "XP", tmp);
}
gPlayerLogged[playerid] = 0;
return 1;
}
Maybe this works...
Re: Help! -
Lorenc_ - 20.07.2010
Quote:
Originally Posted by Jeffry
Maybe try:
pawn Код:
public OnPlayerDisconnect(playerid, reason) { new file[128]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(file,sizeof(file),ACC_FOLDER,name); new tmp[20]; format(tmp, 20, "%d", PlayerInfo[playerid][pXP]); if(dini_Exists(file)) { dini_IntSet(file, "XP", tmp); } gPlayerLogged[playerid] = 0; return 1; }
Maybe this works...
|
argument type mismatch (argument 3)
Line:
pawn Код:
dini_IntSet(file, "XP", tmp);