SA-MP Forums Archive
Some one I need help thanks. - 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: Some one I need help thanks. (/showthread.php?tid=146178)



Some one I need help thanks. - kujox32 - 06.05.2010

pawn Код:
public OnPlayerUpdate(playerid)
{
    new file[128];
    new uCash = GetPlayerMoney(playerid);
    dini_IntSet(file,"AdminLevel", PlayerInfo[playerid][AdminLevel]);
    dini_IntSet(file,"Cash", uCash);
    dini_IntSet(file,"Kills", PlayerInfo[playerid][pKills]);
    dini_IntSet(file,"Deaths", PlayerInfo[playerid][pDeaths]);
    dini_IntSet(file,"Locked", PlayerInfo[playerid][pLocked]);
    dini_IntSet(file,"Local", PlayerInfo[playerid][pLocal]);
    dini_IntSet(file,"Int", PlayerInfo[playerid][pInt]);
}
using this to update the money/kills/deaths with this register/login system but the money/kills/deaths still don't save.
http://forum.sa-mp.com/index.php?topic=126584.0

Can anyone help please?


Re: Some one I need help thanks. - westre - 06.05.2010

You didn't open the file of the player.

Assuming you use the .ini extension, use this.
pawn Код:
new name[MAX_PLAYER_NAME];
format(file, sizeof(file), "%s.ini", name);



Re: Some one I need help thanks. - kujox32 - 06.05.2010

Quote:
Originally Posted by WESTre
You didn't open the file of the player.

Assuming you use the .ini extension, use this.
pawn Код:
new name[MAX_PLAYER_NAME];
format(file, sizeof(file), "%s.ini", name);
Thanks for the help


Re: Some one I need help thanks. - PotH3Ad - 06.05.2010

I don't recommend using OnPlayerUpdate for saving stuff in files, it will cause a lot of lag because OnPlayerUpdate is called about 20 times per second, I recommend using a timer instead...

Here is the code if you need it:

pawn Код:
public OnPlayerConnect(playerid)
{
    //Set a timer for the player that repeats every 2 seconds to update the player's stats...
    SetPVarInt(playerid, "UpdateTimer", SetTimerEx("UpdatePlayer", 2000, true, "i", playerid));
}

public OnPlayerDisconnect(playerid)
{
    //Kill the update timer for the player...
    KillTimer(GetPVarInt(playerid, "UpdateTimer"));
}

//Called every 2 seconds for a player
stock UpdatePlayer(playerid)
{
    new file[128];
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "%s.ini", name);
    new uCash = GetPlayerMoney(playerid);
    dini_IntSet(file,"AdminLevel", PlayerInfo[playerid][AdminLevel]);
    dini_IntSet(file,"Cash", uCash);
    dini_IntSet(file,"Kills", PlayerInfo[playerid][pKills]);
    dini_IntSet(file,"Deaths", PlayerInfo[playerid][pDeaths]);
    dini_IntSet(file,"Locked", PlayerInfo[playerid][pLocked]);
    dini_IntSet(file,"Local", PlayerInfo[playerid][pLocal]);
    dini_IntSet(file,"Int", PlayerInfo[playerid][pInt]);
    return 1;
}



Re: Some one I need help thanks. - kujox32 - 06.05.2010

http://forum.sa-mp.com/index.php?topic=171553.0

Is that the problem then pot?

Код:
error 017: undefined symbol "SetPVarInt" error 017: undefined symbol "GetPVarInt"



Re: Some one I need help thanks. - PotH3Ad - 07.05.2010

Quote:
Originally Posted by kujox32
http://forum.sa-mp.com/index.php?topic=171553.0

Is that the problem then pot?

Код:
error 017: undefined symbol "SetPVarInt" error 017: undefined symbol "GetPVarInt"
You need the latest SA-MP server package (R7) Link: http://forum.sa-mp.com/index.php?topic=161491.0
I don't really think that's the problem in the video though, but the onplayerupdate callback will cause a lot of lag when saving shit every time its called so you should use the timer instead.


Re: Some one I need help thanks. - kujox32 - 07.05.2010

Quote:
Originally Posted by [___
PotH3Ad ]
Quote:
Originally Posted by kujox32
http://forum.sa-mp.com/index.php?topic=171553.0

Is that the problem then pot?

Код:
error 017: undefined symbol "SetPVarInt" error 017: undefined symbol "GetPVarInt"
You need the latest SA-MP server package (R7) Link: http://forum.sa-mp.com/index.php?topic=161491.0
I don't really think that's the problem in the video though, but the onplayerupdate callback will cause a lot of lag when saving shit every time its called so you should use the timer instead.
Turns out that update was the problem lol xD Its fixed now tho thanks ,


Re: Some one I need help thanks. - PotH3Ad - 07.05.2010

No problem