SA-MP Forums Archive
GetPlayerWeapon - 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: GetPlayerWeapon (/showthread.php?tid=466943)



GetPlayerWeapon - Champ - 30.09.2013

Do anybody knows why this is not working?

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(GetPlayerWeapon(playerid) == 24 || 25 || 34)
    {
        if (RELEASED(KEY_FIRE))
        {
            new Float:X;
            new Float:Y;
            new Float:Z;
            GetPlayerPos(playerid, X, Y, Z);
            SetPlayerPos(playerid, X, Y, Z+0.0001);
        }
    }
    return 1;
}
i have enabled this code for only three weapons but it is automatically being enabled to other weapons too.


Re: GetPlayerWeapon - Konstantinos - 30.09.2013

Method 1:
pawn Код:
new weaponid = GetPlayerWeapon(playerid);
if(weaponid  == 24 || weaponid == 25 || weaponid  == 34)
Method 2:
pawn Код:
switch(GetPlayerWeapon(playerid))
{
    case 24, 25, 34:
    {
        // code
    }
}
Method 3:
pawn Код:
if(GetPlayerWeapon(playerid) == 24 || GetPlayerWeapon(playerid) == 25 || GetPlayerWeapon(playerid) == 34)



Re: GetPlayerWeapon - Champ - 30.09.2013

Last one helped.
Thank You


Re: GetPlayerWeapon - Konstantinos - 30.09.2013

Actually the first and the second are recommended because they call GetPlayerWeapon function only once compared to the last one which calls it 3 times.