Help with resetting weapons on player death
#5

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
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.
You mean like this?

Код:
	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);
Reply


Messages In This Thread
Help with resetting weapons on player death - by Spikmun - 02.05.2013, 14:59
Re: Help with resetting weapons on player death - by Yashas - 02.05.2013, 15:04
Re: Help with resetting weapons on player death - by Spikmun - 02.05.2013, 15:22
Re: Help with resetting weapons on player death - by Pottus - 02.05.2013, 15:24
Re: Help with resetting weapons on player death - by Spikmun - 02.05.2013, 15:39
Re: Help with resetting weapons on player death - by Pottus - 02.05.2013, 15:41
Re: Help with resetting weapons on player death - by Yashas - 02.05.2013, 15:48
Re: Help with resetting weapons on player death - by Spikmun - 02.05.2013, 15:52

Forum Jump:


Users browsing this thread: 1 Guest(s)