28.10.2012, 19:04
yes, i am pretty shure that it saves correctly... take a look:
Код:
enum pInfo { pPass, pLogged, pCash, pAdmin, pKills, pDeaths, pBanned } new PlayerInfo[MAX_PLAYERS][pInfo]; public OnPlayerConnect(playerid) { if(fexist(UserPath(playerid))) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","Type your password below to login.","Login","Quit"); } else { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,"Registering...","Type your password below to register a new account.","Register","Quit"); } OnPlayerUpdateExTimer[playerid] = SetTimerEx("OnPlayerUpdateEx", 1000, true, "i", playerid); godcar[playerid] = false; return 1; } public OnPlayerDisconnect(playerid, reason) { new INI:File = INI_Open(UserPath(playerid)); INI_SetTag(File,"data"); INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)); INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]); INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]); INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]); INI_Close(File); PlayerInfo[playerid][pLogged] = 0; KillTimer(OnPlayerUpdateExTimer[playerid]); godcar[playerid] = false; return 1; } public OnPlayerUpdate(playerid) { if(GetPlayerMoney(playerid) > PlayerInfo[playerid][pCash] || GetPlayerMoney(playerid) < PlayerInfo[playerid][pCash]) { GivePlayerMoney(playerid,PlayerInfo[playerid][pCash] - GetPlayerMoney(playerid)); return 1; } new armedweapon = GetPlayerWeapon(playerid); new Name[MAX_PLAYER_NAME],string[128]; GetPlayerName(playerid,Name,sizeof(Name)); if(armedweapon == 38) { if(PlayerInfo[playerid][pAdmin] < 1) { format(string,sizeof(string),"AdmCmd: %s was banned by the server, Reason: Minigun Cheats",Name); SendClientMessageToAll(COLOR_LIGHTRED,string); BanEx(playerid,"Minigun Cheats"); } } return 1; } 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, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit"); new INI:File = INI_Open(UserPath(playerid)); new Name[MAX_PLAYER_NAME],string[128]; INI_SetTag(File,"data"); INI_WriteInt(File,"Password",udb_hash(inputtext)); INI_WriteInt(File,"Logged",0); INI_WriteInt(File,"Cash",3000); INI_WriteInt(File,"Admin",0); INI_WriteInt(File,"Kills",0); INI_WriteInt(File,"Deaths",0); INI_WriteInt(File,"Banned",0); INI_Close(File); SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0); SpawnPlayer(playerid); ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,"Success!","Great! You are now registered!","Ok",""); GetPlayerName(playerid,Name,sizeof(Name)); format(string,sizeof(string),"%s has registered.",Name); print(string); format(string,sizeof(string),"Welcome %s",Name); SendClientMessage(playerid,COLOR_WHITE,string); PlayerInfo[playerid][pLogged] = 1; if(PlayerInfo[playerid][pAdmin] > 0) { format(string,sizeof(string),"SERVER: You are logged in as Level %d Admin.",PlayerInfo[playerid][pAdmin]); SendClientMessage(playerid,COLOR_WHITE,string); } } } case DIALOG_LOGIN: { if(!response) return Kick(playerid ); if(response) { if(udb_hash(inputtext) == PlayerInfo[playerid][pPass]) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); if(PlayerInfo[playerid][pBanned] == 1) { GameTextForPlayer(playerid,"~w~This account is ~r~banned",20000,1); Kick(playerid); } GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,"Success!","You have successfully logged in!","Ok",""); new Name[MAX_PLAYER_NAME],string[128]; GetPlayerName(playerid,Name,sizeof(Name)); format(string,sizeof(string),"%s has logged in.",Name); print(string); GetPlayerName(playerid,Name,sizeof(Name)); format(string,sizeof(string),"%s has registered.",Name); print(string); format(string,sizeof(string),"Welcome %s",Name); SendClientMessage(playerid,COLOR_WHITE,string); PlayerInfo[playerid][pLogged] = 1; if(PlayerInfo[playerid][pAdmin] > 0) { format(string,sizeof(string),"SERVER: You are logged in as Level %d Admin.",PlayerInfo[playerid][pAdmin]); SendClientMessage(playerid,COLOR_WHITE,string); } } else { ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit"); } return 1; } return 1; } } return 1; } forward LoadUser_data(playerid,name[],value[]); public LoadUser_data(playerid,name[],value[]) { INI_Int("Password",PlayerInfo[playerid][pPass]); INI_Int("Cash",PlayerInfo[playerid][pCash]); INI_Int("Admin",PlayerInfo[playerid][pAdmin]); INI_Int("Kills",PlayerInfo[playerid][pKills]); INI_Int("Deaths",PlayerInfo[playerid][pDeaths]); INI_Int("Banned",PlayerInfo[playerid][pBanned]); return 1; } stock UserPath(playerid) { new string[128],playername[MAX_PLAYER_NAME]; GetPlayerName(playerid,playername,sizeof(playername)); format(string,sizeof(string),PATH,playername); return string; }