Raised This Month: $ Target: $400
 0% 

Checking Primary/Secondary Weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jim_yang
Veteran Member
Join Date: Aug 2006
Old 02-07-2009 , 01:39   Re: Checking Primary/Secondary Weapons
Reply With Quote #1

paste from csdm.inc
Code:
//Weapon slot lookup table
stock g_WeaponSlots[] = {
  0,
  2, //CSW_P228
  0,
  1, //CSW_SCOUT
  4, //CSW_HEGRENADE
  1, //CSW_XM1014
  5, //CSW_C4
  1, //CSW_MAC10
  1, //CSW_AUG
  4, //CSW_SMOKEGRENADE
  2, //CSW_ELITE
  2, //CSW_FIVESEVEN
  1, //CSW_UMP45
  1, //CSW_SG550
  1, //CSW_GALIL
  1, //CSW_FAMAS
  2, //CSW_USP
  2, //CSW_GLOCK18
  1, //CSW_AWP
  1, //CSW_MP5NAVY
  1, //CSW_M249
  1, //CSW_M3
  1, //CSW_M4A1
  1, //CSW_TMP
  1, //CSW_G3SG1
  4, //CSW_FLASHBANG
  2, //CSW_DEAGLE
  1, //CSW_SG552
  1, //CSW_AK47
  3, //CSW_KNIFE
  1 //CSW_P90
 };
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 02-07-2009 , 14:11   Re: Checking Primary/Secondary Weapons
Reply With Quote #2

Try this:

PHP Code:
#include <amxmodx>

#define SECONDARY_WEAPONS_BITSUM    ((1<<CSW_DEAGLE) | (1<<CSW_ELITE) | (1<<CSW_FIVESEVEN) | (1<<CSW_GLOCK18) | (1<<CSW_USP) | (1<<CSW_P228))
#define GRENADES_BITSUM    ((1<<CSW_HEGRENADE) | (1<<CSW_SMOKEGRENADE) | (1<<CSW_FLASHBANG) | (1<<CSW_C4))

enum
{
    
IS_PRIMARY,
    
IS_SECONDARY
}

bool:CheckWeaponType(weaponIDtype IS_PRIMARY)
{
    if(!(
GRENADES_BITSUM & (1<<weaponID)))
    {
        if(
type == IS_PRIMARY ? !(SECONDARY_WEAPONS_BITSUM & (1<<weaponID)) : (SECONDARY_WEAPONS_BITSUM & (1<<weaponID)))
        {
            return 
true;
        }
    }
    
    return 
false;

Usage:
PHP Code:
if(CheckWeaponType(get_user_weapon(id), IS_SECONDARY))
{
    
// player's weapon is secondary.

__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
cs1.7
Senior Member
Join Date: Oct 2008
Old 04-04-2010 , 22:39   Re: Checking Primary/Secondary Weapons
Reply With Quote #3

wow..very nice!

which way is the best. The way by Dores?

And i also wonder if there is really no built in function somewhere to check if user has primary or secondary.


edit


i get a "tag missmatch" at this line:

PHP Code:
if(type == IS_PRIMARY ? !(SECONDARY_WEAPONS_BITSUM & (1<<weaponID)) : (SECONDARY_WEAPONS_BITSUM & (1<<weaponID))) 
__________________
_____________
/_____\
[° ||| °]
./..............\▓

Last edited by cs1.7; 04-04-2010 at 23:51.
cs1.7 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 01:37.


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