Save player status
#1

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. 
Reply
#2

help me someone.
Reply
#3

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
Reply
#4

So I must add this code into OnGameModeExit too?
Reply
#5

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
Reply
#6

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.
Reply
#7

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

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]); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)