SA-MP Forums Archive
Save player status - 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: Save player status (/showthread.php?tid=657823)



Save player status - Thanks - 15.08.2018

Hi I've making a Register & Login System It's working but after a players Reconnected all stats reset why? such as Admin level they will set his admin level from 5 to 0 why after reconnected?

This the code onplayerdisconnected

PHP код:
public OnPlayerDisconnect(playeridreason)
{
    new 
file[200]; // We declare the size of the file
    
GetPlayerName(playerid,file,sizeof(file)); // We get the file name
    
format(file,sizeof(file),DOF2_File(file));// We get the user path from DOF2_File (folder Users)
    
DOF2_SetInt(file"Kills",PlayerInfo[playerid][pKills]); // We set/update the players settings.
    
DOF2_SetInt(file"Deaths",PlayerInfo[playerid][pDeaths]);
    
DOF2_SetInt(file"Money",PlayerInfo[playerid][pMoney]);
    
DOF2_SetInt(file"Score",PlayerInfo[playerid][pScore]);
    
DOF2_SetInt(file"AdminLevel",PlayerInfo[playerid][pAdmin]);
    
DOF2_SetInt(file"IP",PlayerInfo[playerid][pIP]);
    
DOF2_SetInt(file"Hours",PlayerInfo[playerid][pHours]);
    
DOF2_SetInt(file"Kidnaper",PlayerInfo[playerid][pKidnaper]);
    
DOF2_SetInt(file"Hitman",PlayerInfo[playerid][pHitman]);
    
DOF2_SetInt(file"Medic",PlayerInfo[playerid][pMedic]);
    
DOF2_SetInt(file"GrabageMan",PlayerInfo[playerid][pGrabage]);
    
DOF2_SetInt(file"ConArtist",PlayerInfo[playerid][pConArtist]);
    
DOF2_SetInt(file"Mechanie",PlayerInfo[playerid][pMechanie]);
    
DOF2_SaveFile(); // Saves the file. 



Re: Save player status - Thanks - 16.08.2018

help me someone.


Re: Save player status - NeXTGoD - 16.08.2018

Why you need to save this under disconnect? if there will be a server crash? you should save it instantly when you make changes to your player files folder


Re: Save player status - Thanks - 17.08.2018

So I must add this code into OnGameModeExit too?


Re: Save player status - GameOvr - 17.08.2018

Quote:
Originally Posted by NeXTGoD
Посмотреть сообщение
Why you need to save this under disconnect? if there will be a server crash? you should save it instantly when you make changes to your player files folder
lol R u really crazy if he didnt save the player's stats OnPlayerDisconnect...player's data will lose


Re: Save player status - Dayrion - 17.08.2018

Quote:
Originally Posted by GameOvr
Посмотреть сообщение
lol R u really crazy if he didnt save the player's stats OnPlayerDisconnect...player's data will lose
Data must be saved when changed, not everytime the player disconnect.


Re: Save player status - Thanks - 17.08.2018

I want same but why the score & money dose not saved? can u help me w


Re: Save player status - Unkovic - 17.08.2018

Quote:
Originally Posted by Thanks
Посмотреть сообщение
I want same but why the score & money dose not saved? can u help me w
try with this

PHP код:
DOF2_SetInt(file"Money",GetPlayerMoney(playerid)); 
    
DOF2_SetInt(file"Score",GetPlayerScore(playerid)); 
But, there is also may be a problem. When you set Money/Score, you must also set that in enum
PHP код:
PlayerInfo[playerid][pMoney] += sum;
SetPlayerMoney(playeridPlayerInfo[playerid][pMoney]);