Is there an alternative to GetPlayerWeaponData?
#1

Sorry if this issue was discussed before, but I've heard that GetPlayerWeaponData is a bad way of getting player's weapon data, so I was wondering if there was something else someone made that works better.
Reply
#2

No, it works perfect.

Actually there are few tricks or ways to do some stuff instead of using GetPlayerWeaponData. For example, you want to get the ammo of a weapon player is having, so people probably use GetPlayerWeaponData but there are alternatives such as this code:
pawn Code:
stock GetPlayerWeaponAmmo(playerid, weaponid)
{
    new current_weapon = GetPlayerWeapon(playerid);

    new ammo = 0;

    SetPlayerArmedWeapon(playerid, weaponid);
    if(GetPlayerWeapon(playerid) == weaponid)
    {
        ammo = GetPlayerAmmo(playerid);
        SetPlayerArmedWeapon(playerid, current_weapon);
    }
    return ammo;
}
And many functions can be build... (checkout playerfuncs.inc: https://sampforum.blast.hk/showthread.php?tid=573961, got afew functions)
Reply
#3

I suppose you could loop through all the player weapon slots, set their armed weapon to that slot and then report it back. It'd do the same as GetPlayerWeaponData but it'd be more accurate.
Reply
#4

Quote:

I've heard that GetPlayerWeaponData is a bad way of getting player's weapon data

Where & Why?

The is best method I know
Reply
#5

GetPlayerAmmo used to be said to be buggy, I have experienced bugs with it before but I haven't exprienced any in recent times. All the weapon functions seem good.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)