AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Admin flags are being ignored (https://forums.alliedmods.net/showthread.php?t=329711)

SaBBa 01-04-2021 14:32

Admin flags are being ignored
 
This is the only place in my code, where g_iKills and g_iInfections increase.
In mostly it works good, but, sometimes admin player is getting his kills increased, what could be a reason ?

Code:

public EventDeathMsg()
{
    if(!(tournament))
        return PLUGIN_HANDLED

    new killer = read_data(1)
    new victim = read_data(2)

    if(!(is_user_valide(victim)) || !(is_user_valide(killer)))
        return PLUGIN_HANDLED

    if(killer == victim)
        return PLUGIN_HANDLED

    if(~get_user_flags(killer) & ADMIN_USER)
        return PLUGIN_HANDLED

    if(zp_get_user_zombie(killer)) {
        g_iInfections[killer]++
        return PLUGIN_HANDLED
    }

    g_iKills[killer]++
    return PLUGIN_HANDLED
}


Natsheh 01-04-2021 14:37

Re: Admin flags are being ignored
 
Code:
    if(~get_user_flags(killer) & ADMIN_USER)         return PLUGIN_HANDLED

simple don't give them admin flags with the flag z....

SaBBa 01-04-2021 14:42

Re: Admin flags are being ignored
 
Quote:

Originally Posted by Natsheh (Post 2731330)
Code:
    if(~get_user_flags(killer) & ADMIN_USER)         return PLUGIN_HANDLED

simple don't give them admin flags with the flag z....

that guy had "bceijmprst" flags, he got 2 of his kills counted, others got ignore, how is this even possible?

Natsheh 01-04-2021 14:47

Re: Admin flags are being ignored
 
post the full code....

and post what the ADMIN_USER is defined for you...

SaBBa 01-04-2021 14:49

Re: Admin flags are being ignored
 
### Censored ###

Natsheh 01-04-2021 15:01

Re: Admin flags are being ignored
 
i don't know the code seems to be fine, but i'd recommend resetting those player-variables on client putinserver.

Code:
public client_putinserver(id) {     get_user_name(id, Name[id], charsmax(Name[]))     get_user_authid(id, SteamID[id], charsmax(SteamID[]))     g_iKills[id] = 0;                    // <-----------     g_iInfections[id] = 0;            // <----------- }


if you're still experiencing some issues try changing the logic of this code.

PHP Code:

    if(~get_user_flags(killer) & ADMIN_USER)
        return 
PLUGIN_HANDLED 

into this :arrow:

PHP Code:

    if((~get_user_flags(killer) & ADMIN_USER) > 0)
        return 
PLUGIN_HANDLED 


SaBBa 01-04-2021 15:15

Re: Admin flags are being ignored
 
hhhh, I will try to following:

replace client_putinserver with client_connect add client_disconnected and set values to 0
probably he joined with same ID, after someone left and he got his score, dunno, maybe, I will try
like

PHP Code:

public client_connect(id)
{
    
get_user_name(idName[id], charsmax(Name[]))
    
get_user_authid(idSteamID[id], charsmax(SteamID[]))
    
g_iKills[id] = 0;
    
g_iInfections[id] = 0;
}
public 
client_disconnected(id)
{
    
g_iKills[id] = 0;
    
g_iInfections[id] = 0;


PHP Code:

 if((~get_user_flags(killer) & ADMIN_USER) > 0

I don't think that changing this will affect anything

Natsheh 01-04-2021 15:33

Re: Admin flags are being ignored
 
there's no need to use client_disconnect and client_putinserver, either just use on of them, you're just going to reset them twice when there's no need to.

client_putinserver should work fine there're no problems with using it..



Quote:

I don't think that changing this will affect anything
well it depends on the logic that the compiler is using.

you're returning bitsum values and not 1 or 0 the logic values, which it might fails , it will be safer to just use the logic operators instead of just using the bitsum operators.

SaBBa 01-04-2021 15:55

Re: Admin flags are being ignored
 
ok, thanks for your help

Bugsy 01-04-2021 22:04

Re: Admin flags are being ignored
 
Maybe use simpler bit conditions (IMO) if this is the root of your problem

PHP Code:

//To check for 1 flag
if ( get_user_flags(killer) & ADMIN_SLAY 
{
     
//User has ADMIN_SLAY 
}

if ( !( 
get_user_flags(killer) & ADMIN_SLAY ) ) 
{
     
//User does not have ADMIN_SLAY 
}

//To check for 1 or more flags
const FlagsToCheck ADMIN_SLAY ADMIN_KICK ADMIN_BAN;

if ( ( 
get_user_flags(killer) & FlagsToCheck ) == FlagsToCheck 
{
     
//User has all flags
}

if ( 
get_user_flags(killer) & FlagsToCheck 
{
     
//User has at least one of the flags... they could also have all of the flags.




All times are GMT -4. The time now is 14:07.

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