Raised This Month: $ Target: $400
 0% 

if weapon isnt knife, do stuff


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pantheon
Member
Join Date: Jan 2011
Old 01-14-2011 , 06:27   if weapon isnt knife, do stuff
Reply With Quote #1

PHP Code:
public WeaponCheck(id) {
    new 
players[32], playernum
    get_players
playersnum"e""TERRORIST" )
    
    for( new 
inumi++ )    {
        
player players[i]
        if(
is_user_connected(player) == && is_user_alive(player) == 1){
            
strip_user_weapons player )
            new 
weapknife[24]
            new 
knifename[32] = "knife"
            
format(weapknife 23"weapon_%s"knifename)
            
//Weapon Checker
            
give_item(playerweapknife)
        }
    }
    
    
get_playersplayersnum"e""CT" )
    for( new 
inumi++ )    {
        
player players[i]
        if(
is_user_connected(player) == && is_user_alive(player) == 1){
            
strip_user_weapons player )
            new 
weapknife[24]
            new 
knifename[32] = "knife"
            
format(weapknife 23"weapon_%s"knifename)
            
//Weapon Checker
            
give_item(playerweapknife)
        }
    }
    
set_task(0.1"WeaponCheck")

i want to check if the player has a knife.

Last edited by Pantheon; 01-14-2011 at 06:31.
Pantheon is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 01-14-2011 , 06:59   Re: if weapon isnt knife, do stuff
Reply With Quote #2

maybe
PHP Code:
if ( user_has_weaponplayer"weapon_knife" )
//do stuff 
JocAnis is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 01-14-2011 , 07:03   Re: if weapon isnt knife, do stuff
Reply With Quote #3

I'm almost sure that weapon_knife should be CSW_KNIFE

u also could use that:

new weapon = get_user_weapon(id, _, _);

if(weapon == CSW_AWP)
{
//code
}
reinert is offline
caffeine
Member
Join Date: Apr 2008
Old 01-14-2011 , 07:43   Re: if weapon isnt knife, do stuff
Reply With Quote #4

http://www.amxmodx.org/funcwiki.php?go=func&id=156

Note that since amxmox 1.8.xxx, clip and ammo are optional. You can now simply do :
new weapon = get_user_weapon(id)



//Here is how it works
//Returns the number of the weapon, according to the cstrike CSW_ constants

new iwpn, wclip, wammo
switch(get_user_weapon(id,wclip,wammo))
{
case CSW_AWP:
client_print(id,print_chat,"awp")

case CSW_SCOUT:
client_print(id,print_chat,"scout")
}
caffeine is offline
Vechta
Veteran Member
Join Date: Jun 2010
Old 01-14-2011 , 08:04   Re: if weapon isnt knife, do stuff
Reply With Quote #5

PHP Code:
 if (user_has_weapon(idCSW_KNIFE) && get_user_weapon(id) != CSW_KNIFE

Last edited by Vechta; 01-14-2011 at 12:41.
Vechta is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-14-2011 , 09:19   Re: if weapon isnt knife, do stuff
Reply With Quote #6

Player holding knife (current weapon)
PHP Code:
 if ( get_user_weaponid ) == CSW_KNIFE 
Player has knife (player has the weapon, doesnt have to be holding)
PHP Code:
if ( user_has_weaponid CSW_KNIFE ) )

or

if ( 
pevid pev_weapons ) & ( << CSW_KNIFE ) ) 
__________________
Bugsy is offline
Reply


Thread Tools
Display Modes

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 02:13.


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