02.05.2013, 15:39
Quote:
Writing files in OnPlayerDeath() is a really bad idea but if you must use it why bother getting the weapon data when you know all values will be 0 why not just write the default values to file there is absolutely no need to do what your doing. This way you can eliminate some code as well.
|
Код:
ResetPlayerWeapons(playerid); new string[64], Name[MAX_PLAYER_NAME], kName[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, sizeof(Name)); GetPlayerName(killerid, kName, sizeof(Name)); format(string, sizeof(string), "You have killed %s and have received their money.", Name); SendClientMessage(killerid, COLOR_LIGHTBLUE, string); format(string,sizeof(string), "You were killed by %s", kName); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); new money; money = GetPlayerMoney(playerid); GivePlayerMoney(killerid, money); GivePlayerMoney(playerid, -money); SendClientMessage(playerid, COLOR_BRIGHTRED, "You have died and lost all of your money."); PlayerInfo[killerid][pKills]++; PlayerInfo[playerid][pDeaths]++; 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,"Weapon0",0); INI_WriteInt(File,"Ammo0",0); INI_WriteInt(File,"Weapon1",0); INI_WriteInt(File,"Ammo1",0); INI_WriteInt(File,"Weapon2",0); INI_WriteInt(File,"Ammo2",0); INI_WriteInt(File,"Weapon3",0); INI_WriteInt(File,"Ammo3",0); INI_WriteInt(File,"Weapon4",0); INI_WriteInt(File,"Ammo4",0); INI_WriteInt(File,"Weapon5",0); INI_WriteInt(File,"Ammo5",0); INI_WriteInt(File,"Weapon6",0); INI_WriteInt(File,"Ammo6",0); INI_WriteInt(File,"Weapon7",0); INI_WriteInt(File,"Ammo7",0); INI_WriteInt(File,"Weapon8",0); INI_WriteInt(File,"Ammo8",0); INI_WriteInt(File,"Weapon9",0); INI_WriteInt(File,"Ammo9",0); INI_WriteInt(File,"Weapon10",0); INI_WriteInt(File,"Ammo10",0); INI_WriteInt(File,"Weapon11",0); INI_WriteInt(File,"Ammo11",0); INI_WriteInt(File,"Weapon12",0); INI_WriteInt(File,"Ammo12",0); INI_Close(File);