public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"Level",1);
INI_WriteInt(File,"Cash",GivePlayerMoney(playerid, 10000));
INI_WriteInt(File,"Sex",0);
INI_WriteInt(File,"Age",0);
INI_WriteInt(File,"Skin",0);
INI_WriteInt(File,"Leader",0);
INI_WriteInt(File,"Rank",0);
INI_WriteInt(File,"Team",0);
INI_WriteInt(File,"Member",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"VIP",0);
INI_WriteInt(File,"Muted",0);
INI_WriteInt(File,"Tutorial",0);
INI_WriteInt(File,"Mute Time",0);
INI_WriteInt(File,"Banned",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
new sex[] = " Male \n Female ";
ShowPlayerDialog(playerid, DIALOG_SEX, DIALOG_STYLE_LIST, "Please selecet your Gender", sex, "Select","Quit Game");
}
}
public OnPlayerDisconnect(playerid, reason)
{
GetPlayerMoney(playerid);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_WriteInt(File,"Leader",PlayerInfo[playerid][pLeader]);
INI_WriteInt(File,"Rank",PlayerInfo[playerid][pRank]);
INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
INI_WriteInt(File,"Member",PlayerInfo[playerid][pMember]);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
INI_WriteInt(File,"Tutorial",PlayerInfo[playerid][pTut]);
INI_WriteInt(File,"Mute Time",PlayerInfo[playerid][pMuteTime]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pLocked]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
return 1;
}
public SaveUserData(playerid)
{
new PlayerName[MAX_PLAYERS];
GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
INI_WriteInt(File,"Leader",PlayerInfo[playerid][pLeader]);
INI_WriteInt(File,"Rank",PlayerInfo[playerid][pRank]);
INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
INI_WriteInt(File,"Member",PlayerInfo[playerid][pMember]);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
INI_WriteInt(File,"Tutorial",PlayerInfo[playerid][pTut]);
INI_WriteInt(File,"Mute Time",PlayerInfo[playerid][pMuteTime]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pLocked]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
printf("[userdata] Player Data of %s has been saved.", PlayerName);
return 1;
}
INI_WriteInt(File,"Cash",GivePlayerMoney(playerid, 10000));
INI_WriteInt(File, "Cash", 10000);
GivePlayerMoney(playerid, 10000);
OnPlayerDisconnect(playerid, reason) { SaveUserData(playerid); };
OnPlayerSpawn(playerid) { GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]); }
So you write the data upon disconnect, what's the point of the SaveUserData function?
PHP код:
PHP код:
|
The SaveUserData is used when i use /GMX to save stats prior to the restart. But that hasnt seemed to be working, still got alot of stuff to work out, which is hard doing majority myself, other than coming to the forum asking for help sometimes.
|
public SaveUserData(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid));
INI_WriteInt(File,"Leader",PlayerInfo[playerid][pLeader]);
INI_WriteInt(File,"Rank",PlayerInfo[playerid][pRank]);
INI_WriteInt(File,"Team",PlayerInfo[playerid][pTeam]);
INI_WriteInt(File,"Member",PlayerInfo[playerid][pMember]);
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
INI_WriteInt(File,"Muted",PlayerInfo[playerid][pMuted]);
INI_WriteInt(File,"Tutorial",PlayerInfo[playerid][pTut]);
INI_WriteInt(File,"Mute Time",PlayerInfo[playerid][pMuteTime]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pLocked]);
INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
INI_Close(File);
return 1;
}
CMD:gmx(playerid, params[])
{
SaveUserData(playerid);
SetTimer("Gmx",3000,false);
SendRconCommand("gmx");
return 1;
}