SA-MP Forums Archive
Is there an alternative to GetPlayerWeaponData? - 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)
+---- Forum: Discussion (https://sampforum.blast.hk/forumdisplay.php?fid=84)
+---- Thread: Is there an alternative to GetPlayerWeaponData? (/showthread.php?tid=579192)



Is there an alternative to GetPlayerWeaponData? - DTV - 25.06.2015

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.


Re: Is there an alternative to GetPlayerWeaponData? - Gammix - 25.06.2015

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)


Re: Is there an alternative to GetPlayerWeaponData? - Kyle - 25.06.2015

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.


Re: Is there an alternative to GetPlayerWeaponData? - Yashas - 25.06.2015

Quote:

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

Where & Why?

The is best method I know


Re: Is there an alternative to GetPlayerWeaponData? - Kar - 26.06.2015

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.