now i have the following issue.... Any player can just type /minigundm and when they go there they get a minigun..... then they type /lvair and now they have a minigun in the LVAirport.... how do i take the players weapon upon exiting the dm area? Is there a way to set a paremeter around the dm area and when he exits the area he looses the minigun? |
ResetPlayerWeapons(playerid); //Under OnPlayerCommandText
RemovePlayerWeapon(playerid, weaponid)
{
if(!IsPlayerConnected(playerid) || weaponid < 0 || weaponid > 50)
return;
new
saveweapon[13],
saveammo[13];
// Probably could be done using one loop
for(new slot = 0; slot < 13; slot++)
GetPlayerWeaponData(playerid, slot, saveweapon[slot], saveammo[slot]);
ResetPlayerWeapons(playerid);
for(new slot; slot < 13; slot++)
{
if(saveweapon[slot] == weaponid || saveammo[slot] == 0)
continue;
GivePlayerWeapon(playerid, saveweapon[slot], saveammo[slot]);
}
// give them weapon ID 0 to reset the current armed weapon
// to a fist and not the last weapon in their inventory
GivePlayerWeapon(playerid, 0, 1);
}
RemovePlayerWeapon(playerid, 38); // Removes the Minigun.
RemovePlayerWeapon(playerid, weaponid)
{
if(!IsPlayerConnected(playerid) || weaponid < 0 || weaponid > 50)
return;
new
saveweapon[13],
saveammo[13];
// Probably could be done using one loop
for(new slot = 0; slot < 13; slot++)
GetPlayerWeaponData(playerid, slot, saveweapon[slot], saveammo[slot]);
ResetPlayerWeapons(playerid);
for(new slot; slot < 13; slot++)
{
if(saveweapon[slot] == weaponid || saveammo[slot] == 0)
continue;
GivePlayerWeapon(playerid, saveweapon[slot], saveammo[slot]);
}
// give them weapon ID 0 to reset the current armed weapon
// to a fist and not the last weapon in their inventory
GivePlayerWeapon(playerid, 0, 1);
}
@Carlton: Doesn't this gives the double amount of what he's already holding? (GivePlayerWeapon(playerid, saveweapon[slot], saveammo[slot]) < Supposed to be a positive number?)
Also, I suggest you to break the loop once you find the weapon you need to remove :P |
No, I didn't create the function, i've used it many times in the past, and have had no problems what-so-ever.
|