24.01.2015, 12:27
Hi I want to make if person have gun id 27 it automatically remove it and replace it with M4 anyone can do that?!
public OnPlayerUpdate(playerid)
{
if(GetPlayerWeapon(playerid) == 27)
{
GivePlayerWeapon(playerid,27, 0);
GivePlayerWeapon(playerid,31,5000);//amount of ammo you want replace it with 5000
}
return 1;
}
stock RemovePlayerWeapon(playerid, pweaponid)
{
new plyWeapons[12];
new plyAmmo[12];
for(new slot = 0; slot != 12; slot++)
{
new pwep, pammo;
GetPlayerWeaponData(playerid, slot, pwep, pammo);
if(pwep != pweaponid)
{
GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
}
}
ResetPlayerGuns(playerid);
for(new slot = 0; slot != 12; slot++)
{
GivePlayerGun(playerid, plyWeapons[slot], plyAmmo[slot]);
}
}
public OnPlayerUpdate(playerid)
{
new weapon, ammo;
GetPlayerWeaponData(playerid, 3, weapon, ammo);
if(weapon==27)
{
RemovePlayerWeapon(playerid, 27);
GivePlayerWeapon(playerid, WEAPON_M4, 100);
}
}
PHP код:
|