Raised This Month: $51 Target: $400
 12% 

Benefits


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NooTy
Member
Join Date: Sep 2019
Old 02-25-2020 , 10:42   Benefits
Reply With Quote #1

When Any Admin access kill he Got +80hp and 80ap and 8k$ Why ??

PHP Code:
#include <amxmodx>
#include <fun>
#include <cstrike>

static const
    
PLUGIN[] = "Beneficii Playeri",
    
VERSION[] = "1.1",
    
AUTHOR[] = "NooTy";
    
public 
plugin_init(){
    
register_plugin(PLUGIN,VERSION,AUTHOR);
    
register_event("DeathMsg","ev_death_msg","a")
}
public 
ev_death_msg( ) {
    new 
id read_data(1)
    new 
victim read_data(2)

    if(!
is_user_alive(id) || id == victim) return
    
    if(
get_user_flags(id) & read_flags("abcdefghijklmnopqrsux")) {
        
cs_set_user_money(id,cs_get_user_money(id) + 8000)
        
set_user_health(id,get_user_health(id) + 80)
        
set_user_armor(id,get_user_armor(id) + 80)
    }
     else if(
get_user_flags(id) & read_flags("abcdefghijklmnopqrsu")) {
        
cs_set_user_money(id,cs_get_user_money(id) + 7000)
        
set_user_health(id,get_user_health(id) + 70)
        
set_user_armor(id,get_user_armor(id) + 70)
    }
     else if(
get_user_flags(id) & read_flags("bcdefimnjo")) {
        
cs_set_user_money(id,cs_get_user_money(id) + 6000)
        
set_user_health(id,get_user_health(id) + 60)
        
set_user_armor(id,get_user_armor(id) + 60)
    }
    else if(
get_user_flags(id) & read_flags("bcdefimnjp")) {
        
cs_set_user_money(id,cs_get_user_money(id) + 5000)
        
set_user_health(id,get_user_health(id) + 50)
        
set_user_armor(id,get_user_armor(id) + 50)
    }
     else if(
get_user_flags(id) & read_flags("bcdefimnjs")) {
        
cs_set_user_money(id,cs_get_user_money(id) + 3500)
        
set_user_health(id,get_user_health(id) + 35)
        
set_user_armor(id,get_user_armor(id) + 35)
    }
    else  if(
get_user_flags(id) & read_flags("bcdefimnjt")) {
        
cs_set_user_money(id,cs_get_user_money(id) + 2000)
        
set_user_health(id,get_user_health(id) + 20)
        
set_user_armor(id,get_user_armor(id) + 20)
    }
    
    else if(
get_user_flags(id) & read_flags("z")) {
        
set_user_health(id,get_user_health(id) + 10)
        
set_user_armor(id,get_user_armor(id) + 5)
    }


Last edited by NooTy; 02-25-2020 at 10:53.
NooTy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 02-25-2020 , 14:11   Re: Benefits
Reply With Quote #2

Because "get_user_flags & flag" checks if the user has AT LEAST ONE of the specified admin flags.
Check the "has_all_flags" function from "amxmisc".
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
4ever16
Veteran Member
Join Date: Apr 2015
Old 02-25-2020 , 17:39   Re: Benefits
Reply With Quote #3

Because.

PHP Code:
if(get_user_flags(id) & read_flags("abcdefghijklmnopqrsux")) 
Change all
PHP Code:
if(get_user_flags(id) & read_flags 
To
PHP Code:
    else if(get_user_flags(id) & read_flags("z")) {
        
set_user_health(id,get_user_health(id) + 10)
        
set_user_armor(id,get_user_armor(id) + 5)
    } 
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-25-2020 , 18:23   Re: Benefits
Reply With Quote #4

Quote:
Originally Posted by 4ever16 View Post
Because.

PHP Code:
if(get_user_flags(id) & read_flags("abcdefghijklmnopqrsux")) 
Change all
PHP Code:
if(get_user_flags(id) & read_flags 
To
PHP Code:
    else if(get_user_flags(id) & read_flags("z")) {
        
set_user_health(id,get_user_health(id) + 10)
        
set_user_armor(id,get_user_armor(id) + 5)
    } 
That makes no sense..OciXCrom correctly identified his problem. The & operator will result in all bits that match, but the if () condition only checks for non-zero so if any single flags exists, the condition will return true. OP wants the player to have all flags.

@OP, I reduced/organized your code and fixed your issue. My code does the same as has_all_flags(), just manually to avoid the native call. Though it's a lightweight native so there really is no issue using it.
PHP Code:

#include <amxmodx>
#include <fun>
#include <cstrike>

static const
    
PLUGIN[] = "Beneficii Playeri",
    
VERSION[] = "1.1",
    
AUTHOR[] = "NooTy";

enum BenefitsLevels
{
    
Level1 ,
    
Level2 ,
    
Level3 ,
    
Level4 ,
    
Level5 ,
    
Level6 ,
    
Level7
}

enum Benefits
{
    
Flags26 ] ,
    
FlagBits 
    
Money ,
    
Health ,
    
Armor
}

new 
BenefitsDataBenefitsLevels ][ Benefits ] = 
{
    { 
"abcdefghijklmnopqrsux" 8000 80 80 },
    { 
"abcdefghijklmnopqrsu" 7000 70 70 },
    { 
"bcdefimnjo" 6000 60 60 },
    { 
"bcdefimnjp" 5000 50 50 },
    { 
"bcdefimnjs" 3500 35 35 },
    { 
"bcdefimnjt" 2000 20 20 },
    { 
"z" 10 }
};

public 
plugin_init()
{
    
register_plugin(PLUGIN,VERSION,AUTHOR);
    
register_event("DeathMsg","ev_death_msg","a")
    
    for ( new 
BenefitsLevels:blIndex Level1 blIndex BenefitsLevels blIndex++ )
    {
        
BenefitsDatablIndex ][ FlagBits ] = read_flagsBenefitsDatablIndex ][ Flags ] );
    }
}

public 
ev_death_msg( ) 
{
    new 
id read_data(1)
    new 
victim read_data(2)
    new 
iFlags;
    
    if(!
is_user_alive(id) || id == victim
        return
    
    
iFlags get_user_flagsid );
    
    for ( new 
BenefitsLevels:blIndex Level1 blIndex BenefitsLevels blIndex++ )
    {
        if ( ( 
iFlags BenefitsDatablIndex ][ FlagBits ] ) == BenefitsDatablIndex ][ FlagBits ] ) 
        {
            if ( 
BenefitsDatablIndex ][ Money ] )
                
cs_set_user_moneyid cs_get_user_moneyid ) + BenefitsDatablIndex ][ Money ] )
                
            if ( 
BenefitsDatablIndex ][ Health ] )    
                
set_user_healthid get_user_healthid ) + BenefitsDatablIndex ][ Health ] )
                
            if ( 
BenefitsDatablIndex ][ Armor ] )    
                
set_user_armorid get_user_armorid ) + BenefitsDatablIndex ][ Armor ] )
                
            break;
        }
    }    

__________________

Last edited by Bugsy; 02-25-2020 at 19:42.
Bugsy is offline
NooTy
Member
Join Date: Sep 2019
Old 02-27-2020 , 13:19   Re: Benefits
Reply With Quote #5

Quote:
Originally Posted by OciXCrom View Post
Because "get_user_flags & flag" checks if the user has AT LEAST ONE of the specified admin flags.
Check the "has_all_flags" function from "amxmisc".
like this : if(has_all_flags((Attacker) , "abcdefghijklmnopqrsux")) ??

Thank You All For Help
NooTy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-27-2020 , 17:46   Re: Benefits
Reply With Quote #6

Yes .. use this to lookup anything: http://www.amxmodx.org/api/

I recommend using the new code I wrote.
__________________
Bugsy is offline
NooTy
Member
Join Date: Sep 2019
Old 02-28-2020 , 03:24   Re: Benefits
Reply With Quote #7

Thank You bro
NooTy is offline
NooTy
Member
Join Date: Sep 2019
Old 02-28-2020 , 03:24   Re: Benefits
Reply With Quote #8

You joined in 2005 ? I borned in 2005 xD
NooTy 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 13:59.


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