03.03.2018, 10:47
Quote:
Don t save the stats when a player disconnects . Save them right after you modify them , because otherwise in case of a server stop or restart, the data will be lost.
OnPlayerDisconnect is not called if the server crashes or restarts. |
Код:
CMD:setgold(playerid, params[]) { if(IsPlayerAdmin(playerid)) { new string[400], tname[MAX_PLAYER_NAME], targetid, maxcookies; if(sscanf(params, "ii", targetid, maxcookies)) { return SendClientMessage(playerid, 0xF8F8F8FFF, "Syntax: {Ffffff}/setgold <id> <amount>"); } for(new i=0;i<MAX_PLAYERS; i++) continue; { if((!IsPlayerConnected(targetid)) || (targetid == INVALID_PLAYER_ID)) { SendClientMessage(playerid,-1, "{f00f00}ERROR: {FFFFFF}Player isn't Connected!"); } } if(maxcookies < 0 || maxcookies > 100000000) { return SendClientMessage( playerid, 0xF8F8F8FFF, "{f00f00}ERROR: {FFFFFF}highest amount is 100000000."); } else { GetPlayerName(targetid, tname, sizeof(tname)); format(string, sizeof(string), "{A9C4E4}an administrator has set %s's golds amount to %i.", tname, maxcookies); SendClientMessageToAll(0xF8F8F8FFF, string); GameTextForPlayer(targetid,"~W~W~P~O~R~W! ~B~N~G~I~R~C~P~E! ~Y~GOLD! ~R~:)",3000,3); PlayerPlaySound(targetid, 17802, 0.0, 0.0, 0.0); new INI:File = INI_Open(UserPath(targetid)); PlayerInfo[targetid][pGold] = maxcookies; INI_WriteInt(File,"Gold",maxcookies); INI_Close(File); return 1; } } else { SendClientMessage(playerid, 0xf8F8F8FFF,"{F00f00}ERROR: {FFFFFF}You aren't authorized to use this command."); } return 1; }