GetPlayerWeapon
#1

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.
Reply
#2

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)
Reply
#3

Last one helped.
Thank You
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)