Problem with SetPlayerAmmo.
#1

Hi.

For exemple:

pawn Код:
SetPlayerAmmo(playerid, 5, 0);
It's not work...

I still have the weapon in hands ...
Reply
#2

ClickHere
Look this before
Reply
#3

I already looked. I tried with the slot of the weapon, the id of the weapon, but it's not work.
Reply
#4

Where are you using this ?
Can you show mee the code ?
Reply
#5

PHP код:
SetPlayerAmmo(playerid, 5, 0); 
5 is not the weapon id, but the slotid.

You have to use the weaponid, look here:
Quote:

weaponslot The ID of the weapon to set the ammo of. The name of this parameter is wrong - the weapon ID must be passed, not the slot
Reply
#6

5 it's a weaponid lol.
https://sampwiki.blast.hk/wiki/Weapons
Reply
#7

Do you want delete your weapon or give an another weapon in the hands?
Reply
#8

delete
Reply
#9

Take this function:
PHP код:
stock RemovePlayerWeapon(playerid, weaponid, ammo = 0) //©Jeffry
{
    new 
w = GetPlayerWeapon(playerid), plyWeapons[13], plyAmmo[13];
    for(new 
slot = 0; slot <= 12; slot++)
    {
        
GetPlayerWeaponData(playerid, slot, plyWeapons[slot], plyAmmo[slot]);
        if(
plyWeapons[slot] == weaponid)
        {
            if(
ammo == 0 || plyAmmo[slot] <= ammo)
            {
                if(
w == plyWeapons[slot]) w = 0;
                
plyAmmo[slot] = 0;
                
plyWeapons[slot] = 0;
            }
            else
            {
                
plyAmmo[slot]-=ammo;
            }
        }
    }
    
ResetPlayerWeapons(playerid);
    for(new 
slot = 0; slot <= 12; slot++)
    {
        
GivePlayerWeapon(playerid, plyWeapons[slot], plyAmmo[slot]);
    }
    
SetPlayerArmedWeapon(playerid, w);
    return 
1;
} 
and write it so:
PHP код:
RemovePlayerWeapon(playerid,5); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)