AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   if weapon isnt knife, do stuff (https://forums.alliedmods.net/showthread.php?t=147790)

Pantheon 01-14-2011 06:27

if weapon isnt knife, do stuff
 
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.

JocAnis 01-14-2011 06:59

Re: if weapon isnt knife, do stuff
 
maybe
PHP Code:

if ( user_has_weaponplayer"weapon_knife" )
//do stuff 


reinert 01-14-2011 07:03

Re: if weapon isnt knife, do stuff
 
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
}

caffeine 01-14-2011 07:43

Re: if weapon isnt knife, do stuff
 
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")
}

Vechta 01-14-2011 08:04

Re: if weapon isnt knife, do stuff
 
PHP Code:

 if (user_has_weapon(idCSW_KNIFE) && get_user_weapon(id) != CSW_KNIFE


Bugsy 01-14-2011 09:19

Re: if weapon isnt knife, do stuff
 
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 ) ) 



All times are GMT -4. The time now is 02:13.

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