Raised This Month: $ Target: $400
 0% 

Whats the expressio for something like"except"?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
maoxianxie
Member
Join Date: Aug 2011
Old 10-03-2011 , 02:41   Whats the expressio for something like"except"?
Reply With Quote #1

If I want to let a player can only own Ak47,then how to check wether a player has other weapons ?
__________________
I m really new to amxmodx
maoxianxie is offline
e12harry
Member
Join Date: Apr 2010
Old 10-03-2011 , 02:45   Re: Whats the expressio for something like"except"?
Reply With Quote #2

get_user_weapons ( index, weapons[32], &num )

http://www.amxmodx.org/funcwiki.php?go=func&id=163
e12harry is offline
maoxianxie
Member
Join Date: Aug 2011
Old 10-03-2011 , 02:52   Re: Whats the expressio for something like"except"?
Reply With Quote #3

What should I do ?Sorry, but I really dont know,thx.
__________________
I m really new to amxmodx
maoxianxie is offline
e12harry
Member
Join Date: Apr 2010
Old 10-03-2011 , 04:00   Re: Whats the expressio for something like"except"?
Reply With Quote #4

It depends on what you want to achieve.
If you want to check if player has any other weapon than AK (including knife and c4):
PHP Code:
stock bool:userHasOtherWeaponsThanAk(id)
{
    new 
weapons[32];
    new 
num;
    
get_user_weapons idweaponsnum );
    if(
num >1)
        return 
true;
    if(
num == && weapons[0] != CSW_AK47)
        return 
true;
    return 
false;

This stock will return false only if player do not have any weapons or he has got only AK.


If you want to check if player has other weapon than AK (but let him have knife and C4):

PHP Code:
stock bool:userHasOtherWeapons(idweapon)
{
    new 
weapons[32];
    new 
num;
    
get_user_weapons idweaponsnum );
    new 
weapon;
    for(new 
i=0;i<num;i++){
        
weapon weapons[i];
        if(
weapon != CSW_AK47
            
&& weapon != CSW_KNIFE     //delete this line if user can not have knife
            
&& weapon != CSW_C4    //delete this line if user can not have C4
        
)
        return 
true;
    }
    return 
false;

This will return false if player has other weapons than AK, knife and C4

Last edited by e12harry; 10-03-2011 at 04:32.
e12harry is offline
maoxianxie
Member
Join Date: Aug 2011
Old 10-03-2011 , 04:30   Re: Whats the expressio for something like"except"?
Reply With Quote #5

THX!
__________________
I m really new to amxmodx
maoxianxie is offline
maoxianxie
Member
Join Date: Aug 2011
Old 10-03-2011 , 07:52   Re: Whats the expressio for something like"except"?
Reply With Quote #6

But what dose the parameter"weapon" in the second stock bool mean?(stock : bool userHasOtherWeapons(id,weapon))And how I should use it if I want to strip weapons and give Ak47,knife and c4 when user has other weapons ? Thanks for your kindness .
__________________
I m really new to amxmodx
maoxianxie is offline
Old 10-03-2011, 08:00
Bugsy
This message has been deleted by Bugsy.
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-03-2011 , 08:09   Re: Whats the expressio for something like"except"?
Reply With Quote #7

Untested
PHP Code:
const AllowWeapons = ( << CSW_KNIFE ) | ( << CSW_C4 ) | ( << CSW_AK47 );
new 
iWeapons pevid pev_weapons );
new 
iOtherWeapons iWeapons & ~AllowWeapons;

if ( 
iOtherWeapons )
{
   
//user has weapon(s) not listed in AllowWeapons
}

//To drop other weapons and give allowed weapons
for ( new 31 p++ )
{
   if ( 
iOtherWeapons & ( << ) )
   {
       
//drop this
   
}
   else if ( ( 
AllowWeapons & ( << ) ) && !( iWeapons & ( << ) ) )
   {
       
//give this
   
}

__________________

Last edited by Bugsy; 10-03-2011 at 09:33.
Bugsy 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 19:33.


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