SA-MP Forums Archive
Getting the weapon slot of the armed weapon - 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: Getting the weapon slot of the armed weapon (/showthread.php?tid=315761)



Getting the weapon slot of the armed weapon - milanosie - 04.02.2012

hi there, is there any function to get the weapon slot of the weapon that the player is currently holding?


Re: Getting the weapon slot of the armed weapon - Konstantinos - 04.02.2012

Is it so difficult to search?
Look this function


Re: Getting the weapon slot of the armed weapon - milanosie - 04.02.2012

well that is getplayerweapondata, but how do I know what slot the weapon is,
I mean the weapon the player holds


Re: Getting the weapon slot of the armed weapon - Konstantinos - 04.02.2012

pawn Код:
new
    Weapons = 0, Ammo, Msg[ 64 ];
   
for( new i = 0; i < 13; i ++ )
{
    GetPlayerWeaponData( playerid, i, Weapons, Ammo );
    if( Weapons != 0 )
    {
        format( Msg, sizeof( Msg ), "%d: %d (%d)", i, Weapons, Ammo );
        SendClientMessage( playerid, -1, Msg );
    }
}



Re: Getting the weapon slot of the armed weapon - milanosie - 04.02.2012

Quote:
Originally Posted by Dwane
Посмотреть сообщение
pawn Код:
new
    Weapons = 0, Ammo, Msg[ 64 ];
   
for( new i = 0; i < 13; i ++ )
{
    GetPlayerWeaponData( playerid, i, Weapons, Ammo );
    if( Weapons != 0 )
    {
        format( Msg, sizeof( Msg ), "%d: %d (%d)", i, Weapons, Ammo );
        SendClientMessage( playerid, -1, Msg );
    }
}
You don't get it,
this is for all weapons,

I want to know the Weapon Slot of the weapon the player is currently holding in his hands, not all of his weapons


Re: Getting the weapon slot of the armed weapon - Universal - 04.02.2012

pawn Код:
new
    Weapons = 0, Ammo;
   
for( new i = 0; i < 13; i ++ )
{
    GetPlayerWeaponData( playerid, i, Weapons, Ammo );
    if(Weapons == GetPlayerWeapon(playerid))
    {
        printf("The slot is: %d", i);
    }
}



Re: Getting the weapon slot of the armed weapon - milanosie - 04.02.2012

Quote:
Originally Posted by Universal
Посмотреть сообщение
pawn Код:
new
    Weapons = 0, Ammo;
   
for( new i = 0; i < 13; i ++ )
{
    GetPlayerWeaponData( playerid, i, Weapons, Ammo );
    if(Weapons == GetPlayerWeapon(playerid))
    {
        printf("The slot is: %d", i);
    }
}
thanks