Raised This Month: $ Target: $400
 0% 

How to get primary weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 04-20-2012 , 14:01   How to get primary weapon
Reply With Quote #1

Hello there,

I like to learn how to get someone's primary weapon
i used this for example:
PHP Code:
if (user_has_weapon(idCSW_M4A1))
{
    
ColorChat(idBLUE"^1You already have this ^3weapon")
    return 
PLUGIN_HANDLED

But how to get all the primary weapons with one line?
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 04-20-2012 , 14:12   Re: How to get primary weapon
Reply With Quote #2

PHP Code:
static iWeapons32 ], iWeaponsCountiiWeaponsList;
iWeaponsCount iWeaponsList 0;
get_user_weaponsiPlayeriWeaponsiWeaponsCount );

for( 
0iWeaponsCounti++ )
{
  
iWeaponsList |= ( << iWeapons] );
}

if( 
iWeaponsList & ( << CSW_M4A1 ) )
{
  
/* do this */;

claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 04-20-2012 , 16:24   Re: How to get primary weapon
Reply With Quote #3

Lol i mean like:
PHP Code:
user_has_weapon(idPRIMARY_WEAPON
like that something?
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 04-20-2012 , 16:27   Re: How to get primary weapon
Reply With Quote #4

PHP Code:
const PRIMARY_WEAPONS = ( << CSW_AK47 ) | ( << CSW_AUG ) | ( << CSW_GALIL );

static 
iWeapons32 ], iWeaponsCountiboolbHasPrimary;
iWeaponsCount 0bHasPrimary false;
get_user_weaponsiPlayeriWeaponsiWeaponsCount );

for( 
0iWeaponsCounti++ )
{
  if( ( 
<< iWeapons] ) & PRIMARY_WEAPONS )
  {
    
bHasPrimary true;

    break;
  }
}

if( 
bHasPrimary )
{
  
/* do this */;

__________________

Last edited by claudiuhks; 04-20-2012 at 16:27.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 04-20-2012 , 17:31   Re: How to get primary weapon
Reply With Quote #5

thanks
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-24-2012 , 10:15   Re: How to get primary weapon
Reply With Quote #6

You can get rid of the whole loop.

Code:
if(pev(id, pev_weapons) & PRIMARY_WEAPONS) {     // has primary } else {     // does not have primary }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 04-24-2012 , 10:32   Re: How to get primary weapon
Reply With Quote #7

Quote:
Originally Posted by Exolent[jNr] View Post
You can get rid of the whole loop.

Code:
if(pev(id, pev_weapons) & PRIMARY_WEAPONS) {     // has primary } else {     // does not have primary }
simple and efficient
EpicMonkey is offline
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 04-24-2012 , 13:48   Re: How to get primary weapon
Reply With Quote #8

what is ->
PHP Code:
pev 
?
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
Bilal Pro
Senior Member
Join Date: Mar 2012
Location: Holland
Old 04-24-2012 , 14:06   Re: How to get primary weapon
Reply With Quote #9

nvm, solved
__________________
  • Point System with rank titles for sale [X] [100% private]
  • VIP Menu for sale [X] [100% private]
  • HnS shop more features for sale [X] [100% private]
Contact: Bilalzaandam1234, on steam if you are interested.
Bilal Pro is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode