SA-MP Forums Archive
RemovePlayerWeapon - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: RemovePlayerWeapon (/showthread.php?tid=564718)



RemovePlayerWeapon - Trevor Gin - 22.02.2015

I have guns on my server don't have ammo now how i can fix this, how to make it without ammo

Код:
stock RemovePlayerWeapon(playerid, weaponid)
{ // Not mine :3
	new plyWeapons[12] = 0;
	new plyAmmo[12] = 0;
	for(new sslot = 0; sslot != 12; sslot++)
	{
		new wep, ammo;
		GetPlayerWeaponData(playerid, sslot, wep, ammo);
		if(wep != weaponid && ammo != 0) GetPlayerWeaponData(playerid, sslot, plyWeapons[sslot], plyAmmo[sslot]);
	}
	ResetPlayerWeapons(playerid);
	for(new sslot = 0; sslot != 12; sslot++) if(plyAmmo[sslot] != 0) GivePlayerWeapon(playerid, plyWeapons[sslot], plyAmmo[sslot]);
	return 1;
}



Re: RemovePlayerWeapon - bigboy81 - 22.02.2015

Код:
stock RemovePlayerWeapon(playerid, weaponid)
{ // Not mine :3
	new plyWeapons[12] = 0;
	for(new sslot = 0; sslot != 12; sslot++)
	{
		GetPlayerWeaponData(playerid, sslot, wep);
		if(wep != weaponid != 0) GetPlayerWeaponData(playerid, sslot, plyWeapons[sslot]);
	}
	ResetPlayerWeapons(playerid);
	for(new sslot = 0; sslot != 12; sslot++) GivePlayerWeapon(playerid, plyWeapons[sslot]);
	return 1;
}
You think for this ?


AW: RemovePlayerWeapon - Nero_3D - 23.02.2015

If the weapon has no ammo how is the player supposed to use it ?


Re: RemovePlayerWeapon - Teh0wnz0r - 23.02.2015

I think he just want to see the weapon imagen without ammo.


Re: RemovePlayerWeapon - NinjahZ - 23.02.2015

At the top of your script with all the #defines add this....
pawn Код:
#define AMMO 0x7FFFFFFF
then just for your script do this
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid)
{
    if(GetPlayerWeapon(playerid) == WEAPON_GRENADE)
    {
        SetPlayerAmmo(playerid, WEAPON_GRENADE, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_TEARGAS)
    {
        SetPlayerAmmo(playerid, WEAPON_TEARGAS, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_MOLTOV)
    {
        SetPlayerAmmo(playerid, WEAPON_MOLTOV, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_COLT45)
    {
        SetPlayerAmmo(playerid, WEAPON_COLT45, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_SILENCED)
    {
        SetPlayerAmmo(playerid, WEAPON_SILENCED, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_DEAGLE)
    {
        SetPlayerAmmo(playerid, WEAPON_DEAGLE, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_SHOTGUN)
    {
        SetPlayerAmmo(playerid, WEAPON_SHOTGUN, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_SAWEDOFF)
    {
        SetPlayerAmmo(playerid, WEAPON_SHOTGSPA, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_UZI)
    {
        SetPlayerAmmo(playerid, WEAPON_UZI, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_MP5)
    {
        SetPlayerAmmo(playerid, WEAPON_MP5, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_AK47)
    {
        SetPlayerAmmo(playerid, WEAPON_AK47, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_M4)
    {
        SetPlayerAmmo(playerid, WEAPON_M4, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_TEC9)
    {
        SetPlayerAmmo(playerid, WEAPON_TEC9, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_RIFLE)
    {
        SetPlayerAmmo(playerid, WEAPON_RIFLE, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_SNIPER)
    {
        SetPlayerAmmo(playerid, WEAPON_SNIPER, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_ROCKETLAUNCHER)
    {
        SetPlayerAmmo(playerid, WEAPON_ROCKETLAUNCHER, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_HEATSEEKER)
    {
        SetPlayerAmmo(playerid, WEAPON_HEATSEEKER, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_FLAMETHROWER)
    {
        SetPlayerAmmo(playerid, WEAPON_FLAMETHROWER, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN)
    {
        SetPlayerAmmo(playerid, WEAPON_MINIGUN, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_SATCHEL)
    {
        SetPlayerAmmo(playerid, WEAPON_SATCHEL, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_BOMB)
    {
        SetPlayerAmmo(playerid, WEAPON_BOMB, AMMO);
    }
    else if(GetPlayerWeapon(playerid) == WEAPON_SPRAYCAN)
    {
        SetPlayerAmmo(playerid, WEAPON_SPRAYCAN, AMMO);
    }
    return 1;
}



Re: RemovePlayerWeapon - Gammix - 23.02.2015

A much better way of doing this:
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid)
{
       return SetPlayerAmmo(playerid, weaponid, 0);
}
Actually if there is no ammo, the weapon gets removed from the slot automatically!


Re: RemovePlayerWeapon - NinjahZ - 23.02.2015

Quote:
Originally Posted by Gammix
Посмотреть сообщение
A much better way of doing this:
pawn Код:
stock RemovePlayerWeapon(playerid, weaponid)
{
       return SetPlayerAmmo(playerid, weaponid, 0);
}
Actually if there is no ammo, the weapon gets removed from the slot automatically!
Exactly, but your way can still be used...

pawn Код:
#define AMMO 0x7FFFFFFF

stock RemovePlayerWeapon(playerid, weaponid)
{
       return SetPlayerAmmo(playerid, weaponid, AMMO);
}



Re: RemovePlayerWeapon - Qu3esL - 23.02.2015

Quote:
Originally Posted by NinjahZ
Посмотреть сообщение
Exactly, but your way can still be used...

pawn Код:
#define AMMO 0x7FFFFFFF

stock RemovePlayerWeapon(playerid, weaponid)
{
       return SetPlayerAmmo(playerid, weaponid, AMMO);
}
Why in the world you would ever need dat macro "AMMO" just paste it directly. And if you dont want remove weapons then simply use SetPlayerAmmo!