Anti Weapon Reset -
Blackazur - 06.02.2013
Hello, i have an Question how to make that when an Player die and he buyed an Weapon, that the Weapon get not reseted after Death?
Re: Anti Weapon Reset -
Scenario - 06.02.2013
Save the weapon that the player bought from the store into a variable, or perhaps a two-dimensional variable to save the weapon ID, and the amount of ammo (if your system works like that).
pawn Code:
new
weapInfo[MAX_PLAYERS][2];
When the player buys the weapon, put the weapon ID into the first dimension, and the amount of ammo into the second dimension.
pawn Code:
weapInfo[playerid][0] = WEAPON_ID;
weapInfo[playerid][1] = WEAPON_AMMO;
Under OnPlayerDeath you could possibly set a bool variable so we can use it under OnPlayerSpawn to make sure the player actually died before we give them the weapon and ammo.
pawn Code:
new
bool:justDied[MAX_PLAYERS] = false; // top of your script
justDied[playerid] = true; // under OnPlayerDeath
Then we just see if the player just died, if they did, we give them their weapon. Put this under OnPlayerSpawn:
pawn Code:
if(justDied[playerid])
{
GivePlayerWeapon(playerid, weapInfo[playerid][0], weapInfo[playerid][1]);
}
AW: Anti Weapon Reset -
Blackazur - 06.02.2013
Ah Thanks, and how to make then that only the buyed Weapons from 1 Team get not reseted? So that the Weapons from "TEAM_HUMAN" get not reseted, and the Weapons from "TEAM_ZOMBIE" reseted.
Re: Anti Weapon Reset -
Scenario - 06.02.2013
Using the code I just gave you, modify anything under OnPlayerDeath to match this:
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPlayerTeam(playerid) == TEAM_HUMAN) justDied[playerid] = true;
return 1;
}
AW: Anti Weapon Reset -
Blackazur - 06.02.2013
Code:
ResetPlayerWeaponStats(playerid);
OnplayerDeath
Code:
stock ResetPlayer(playerid)
{
ResetPlayerWeaponStats(playerid);
return 1;
}
stock ResetPlayerWeaponStats(playerid)
{
ResetPlayerWeapons(playerid);
for(new i=1;i==45;i++)
{
PlayerWeapon[playerid][i] = 0;
}
return 1;
}
Thanks but i have an question if you can make me this too with this Code so that i can use my old one, and that just the Weaps from TEAM_ZOMBIE get reseted not from TEAM_HUMAN. Because it reset the buyed Weapons from TEAM_HUMAN too when the Player get random Zombie.
Re: Anti Weapon Reset -
Scenario - 06.02.2013
Just add this under OnPlayerDeath:
pawn Code:
if(GetPlayerTeam(playerid) == TEAM_ZOMBIE) ResetPlayerWeaponStats(playerid);
AW: Anti Weapon Reset -
Blackazur - 06.02.2013
I still have not the buyed Weapons must i add maybe something on OnPlayerSpawn or so?
Re: Anti Weapon Reset -
Scenario - 06.02.2013
Show me your code for when a player buys a weapon. And also show me your code for OnPlayerSpawn.
AW: Anti Weapon Reset -
Blackazur - 06.02.2013
Code:
new PlayerWeapon[MAX_PLAYERS][45];
On top of my Script.
Code:
stock GivePlayerWeaponEx(playerid,weaponid,ammo)
{
PlayerWeapon[playerid][weaponid] = 1;
GivePlayerWeapon(playerid,weaponid,ammo);
return 1;
}
Code:
case DIALOG_WEAPONS:
{
switch(listitem) // ShowPlayerDialog(playerid,DIALOG_WEAPONS,DIALOG_STYLE_LIST,"WEAPON MENU","9mm's - $250\nSilenced 9mm - $500\nSawnoffs - $1000\nCombat shotgun - $1500\nMicro UZIs - $2000\nMP5 - $2500\nAK47 - $3000","OKAY","CANCEL");
{
case 0:
{
if(PlayerMoney[playerid] < 1500) return SendClientMessage(playerid,COLOR_RED,"«| You need $1500! |»");
GivePlayerMoneyEx(playerid,-1500);
GivePlayerWeaponEx(playerid,22,9999);
format(str,144,"«| %s has bought 9mms using /shop |»",PlayerName[playerid]);
SendClientMessageToAll(0xFF997FFF,str);
}
When he buy something.
Here.
Re: Anti Weapon Reset -
Scenario - 06.02.2013
And what about your OnPlayerSpawn callback?