AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Spy admin error? (https://forums.alliedmods.net/showthread.php?t=153011)

bibu 03-17-2011 13:49

Spy admin error?
 
Can this plugin fuck my users.ini or interfer with the is_user_admin native? I know it does (hide) remove the admins flag and set it after back. This is the plugin ( http://forums.alliedmods.net/showthread.php?t=28034 ) :

PHP Code:

#include <amxmodx>
#include <amxmisc>

//USAGE: say /spyadmin, toggles your admin on/off
// by Smokey485

new spy[33]; // is the user a spy
new oldflags[33]; // the users old flags for admin

public plugin_init()
{
    
register_plugin("SpyAdmin v1""1.01""Smokey485")
    
register_clcmd("say /spy""spy_toggle", -1)
    
register_clcmd("amx_spyadmin""spy_toggle", -1)
}
public 
spy_toggle(id)
{
    
//although people who aren't admin can use this, its okay because they will just get the z flag anyway
    
    
if(spy[id] == 1)
    {
        
set_user_flags(id,oldflags[id],0)
        
client_print(id,print_chat,"[SPYADMIN] You are now back to your previous admin state.")
        new 
zflag read_flags("z")
        if(
containi(oldflags[id], "a") || containi(oldflags[id], "c") || containi(oldflags[id], "d") || containi(oldflags[id], "j"))
        
remove_user_flags(id,zflag,0)
        
spy[id] = 0
        
return PLUGIN_HANDLED;
    }
    if(
spy[id] == 0)
    {
        
oldflags[id] = get_user_flags(id)
        
client_print(id,print_chat"[SPYADMIN] You are now hidden as an admin.")
        
spy[id] = 1
        remove_user_flags
(id,oldflags[id],0)
        new 
zflag read_flags("z")
        
set_user_flags(idzflag0)
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_HANDLED;
}
public 
client_putinserver(id)
{
    
spy[id] = 0
    oldflags
[id] = 0



fysiks 03-17-2011 18:55

Re: Spy admin error?
 
1.
Code:

if(containi(oldflags[id], "a") || containi(oldflags[id], "c") || containi(oldflags[id], "d") || containi(oldflags[id], "j"))
Won't work because oldflags[id] is not a string. I'm amazed it compiles.

When restoring admin access do:
Code:

set_user_flags(id, -1) // Remove all flags.
set_user_flags(id, oldflags[id])

And similarly when removing admin access flags.
2. users.ini is not affected.
3. Yes, it will affect the return value of is_user_admin(). See the function:

PHP Code:

stock is_user_admin(id)
{
    new 
__flags=get_user_flags(id);
    return (
__flags>&& !(__flags&ADMIN_USER));




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

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