Raised This Month: $32 Target: $400
 8% 

Solved primary weapon detect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
man_s_our
Senior Member
Join Date: Jul 2017
Location: aim_taliban
Old 04-07-2018 , 03:33   primary weapon detect
Reply With Quote #1

I used this function to detect if the player have a primary weapon exept for m249.
but it look like it's allways return true.
what's the error?
PHP Code:
stock bool:has_weapon(id) {
    
    new 
modelName[32], weapon
    pev
(idpev_weaponsweapon)
    
entity_get_string(idEV_SZ_viewmodelmodelName31)
    if(
containi(modelName"v_weapon_") != -1) return true;
    if(
weapon & (<< CSW_AWP) || weapon & (<< CSW_SCOUT) || weapon & (<< CSW_XM1014) || weapon & (<< CSW_MAC10) || weapon & (<< CSW_AUG) || weapon & (<< CSW_UMP45) || weapon & (<< CSW_GALIL) || weapon & (<< CSW_FAMAS) || weapon & (<< CSW_M3) || weapon & (<< CSW_TMP) || weapon & (<< CSW_G3SG1) || weapon & (<< CSW_SG552) || weapon & (<< CSW_AK47) || weapon & (<< CSW_P90))
        return 
true

    
return false

__________________

Last edited by man_s_our; 04-07-2018 at 08:24.
man_s_our is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-07-2018 , 05:16   Re: primary weapon detect
Reply With Quote #2

1 << weapon
__________________
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-07-2018 , 05:23   Re: primary weapon detect
Reply With Quote #3

Why are you checking if weapon viewmodel contains v_weapon_

Hamlet weapons is already a bitsum value

You can use cstrike natives to check if user has prim weapon
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-07-2018 at 05:26.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
man_s_our
Senior Member
Join Date: Jul 2017
Location: aim_taliban
Old 04-07-2018 , 05:36   Re: primary weapon detect
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
Why are you checking if weapon viewmodel contains v_weapon_

Hamlet weapons is already a bitsum value

You can use cstrike natives to check if user has prim weapon
that part made by can't shot to check if player have shield
__________________
man_s_our is offline
man_s_our
Senior Member
Join Date: Jul 2017
Location: aim_taliban
Old 04-07-2018 , 05:44   Re: primary weapon detect
Reply With Quote #5

I've find out I was accidently replaced "v_shield_" with "v_weapon_"
__________________
man_s_our is offline
man_s_our
Senior Member
Join Date: Jul 2017
Location: aim_taliban
Old 04-07-2018 , 05:49   Re: primary weapon detect
Reply With Quote #6

Quote:
Originally Posted by HamletEagle View Post
1 << weapon
how?
__________________
man_s_our is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-07-2018 , 06:34   Re: primary weapon detect
Reply With Quote #7

Quote:
Originally Posted by man_s_our View Post
how?
PHP Code:
/**
 * Returns if the client has a primary weapon or a shield in the inventory.
 *
 * @param index     Client index
 *
 * @return          1 if the client has a primary weapon or shield in the
 *                  inventory, 0 otherwise
 * @error           If the client index is not within the range of 1 to
 *                  MaxClients, or the client is not connected, an error will be
 *                  thrown.
 */
native cs_get_user_hasprim(index); 
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-07-2018 at 06:35.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
man_s_our
Senior Member
Join Date: Jul 2017
Location: aim_taliban
Old 04-07-2018 , 08:23   Re: primary weapon detect
Reply With Quote #8

Quote:
Originally Posted by Natsheh View Post
PHP Code:
/**
 * Returns if the client has a primary weapon or a shield in the inventory.
 *
 * @param index     Client index
 *
 * @return          1 if the client has a primary weapon or shield in the
 *                  inventory, 0 otherwise
 * @error           If the client index is not within the range of 1 to
 *                  MaxClients, or the client is not connected, an error will be
 *                  thrown.
 */
native cs_get_user_hasprim(index); 
thanks
__________________
man_s_our is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-08-2018 , 05:32   Re: primary weapon detect
Reply With Quote #9

Quote:
Originally Posted by Natsheh View Post
Why are you checking if weapon viewmodel contains v_weapon_

Hamlet weapons is already a bitsum value

You can use cstrike natives to check if user has prim weapon
I just assumed he's using get_user_weapon, my bad.
__________________
HamletEagle 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 08:38.


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