Raised This Month: $ Target: $400
 0% 

Temporary admin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
s33k
Senior Member
Join Date: Jul 2009
Location: club420
Old 12-02-2009 , 08:49   Temporary admin
Reply With Quote #1

Is there a plugin that can give temporary admin.
Admin with access to f flag give admin to player on server.
He is the administrator while online and when he go out from the server he lose it.
When again he come back admin must give he again temporary admin.

Sry for bad english.
__________________
s33k is offline
Send a message via MSN to s33k
Toastt
BANNED
Join Date: Nov 2009
Old 12-02-2009 , 22:37   Re: Temporary admin
Reply With Quote #2

yea, go
add the flag f
go into ftp and remove it later ^^
dont be lazy
Toastt is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-02-2009 , 22:49   Re: Temporary admin
Reply With Quote #3

Should be fairly simple to do.

EDIT:

PHP Code:
#include <amxmodx>
#include <amxmisc>

new const TempAdminFlags[] = "cfu"

public plugin_init()
{
    
register_concmd("amx_tempadmin""cmdGiveAdmin"ADMIN_MAP"<name>")
}

public 
cmdGiveAdmin(idlevelcid)
{
    if( !
cmd_access(id,level,cid,2) )
    {
        return 
PLUGIN_HANDLED
    
}
    
    new 
szArg[32]
    
read_argv(1szArgcharsmax(szArg))
    
    new 
player cmd_target(idszArg)
    
    if(
player)
    {
        new 
szName[32]; get_user_name(playerszNamecharsmax(szName));
        
remove_user_flags(playerADMIN_USER)
        
set_user_flags(playerread_flags(TempAdminFlags))
        
client_print(idprint_console"Admin priveleges given to %s"szName)
    }
    
    return 
PLUGIN_HANDLED
    

I'm not sure if flags survive map change but I would guess not.
__________________

Last edited by fysiks; 12-03-2009 at 11:58.
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-03-2009 , 01:00   Re: Temporary admin
Reply With Quote #4

See set_user_flags()

You can see how this is used in my Admin Hierarchy plugin (link in my sig)

If you can't figure it out I can write it for you.
__________________
Bugsy is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-03-2009 , 01:19   Re: Temporary admin
Reply With Quote #5

Quote:
Originally Posted by Bugsy View Post
See set_user_flags()

You can see how this is used in my Admin Hierarchy plugin (link in my sig)

If you can't figure it out I can write it for you.
, you posted while I was writing the plugin lol. I thought I was still the last post.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-03-2009 , 09:07   Re: Temporary admin
Reply With Quote #6

That should work fine. The only problem is when you give a player admin flags you need to remove the user flag AMX_USER. Not doing so could restrict some commands such as amx_who.

Add remove_user_flags() above set_user_flags()
Code:
if(player) {     new szName[32]; get_user_name(player, szName, charsmax(szName));     remove_user_flags( player , ADMIN_USER );     set_user_flags(player, read_flags(TempAdminFlags) )     client_print(id, print_console, "Admin priveleges given to %s", szName) }
__________________
Bugsy is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 12-03-2009 , 09:19   Re: Temporary admin
Reply With Quote #7

Temporary admin plugin made by GHW_chronic

http://forums.alliedmods.net/showthr...ight=tempadmin
matsi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-03-2009 , 11:49   Re: Temporary admin
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
That should work fine. The only problem is when you give a player admin flags you need to remove the user flag AMX_USER. Not doing so could restrict some commands such as amx_who.

Add remove_user_flags() above set_user_flags()
Code:
if(player) {     new szName[32]; get_user_name(player, szName, charsmax(szName));     remove_user_flags( player , ADMIN_USER );     set_user_flags(player, read_flags(TempAdminFlags) )     client_print(id, print_console, "Admin priveleges given to %s", szName) }
If I set admin flags as 7 it obviously does not contain 33554432 (1<<25 aka ADMIN_USER). So, if someones flags are set at 7 how would it think it has ADMIN_USER??? If set_user_flags() doesn't actually set the flags but adds the flags it really needs to be named add_user_flags().

But, now that I think of it, "set" can be interpreted both ways, imo. Maybe it's programming lingo that I don't know about .

My code is updated with Bugsy fix.
__________________

Last edited by fysiks; 12-03-2009 at 11:59.
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-03-2009 , 21:18   Re: Temporary admin
Reply With Quote #9

Your logic is correct fysiks, it's the way set_user_flags() is coded that creates the need for removing old flags when setting new flags.

Quote:
Originally Posted by fysiks
If set_user_flags() doesn't actually set the flags but adds the flags it really needs to be named add_user_flags().
Exactly.

As you can see the in source for set_user_flags(), it uses a bit-wise OR to set flags when it should be an equals.

PHP Code:
pPlayer->flags[id] |= flag;

//should be

pPlayer->flags[id] = flag
And I don't know what this is all about
PHP Code:
    if (id 0)
        
id 0;
    
    if (
id 31)
        
id 31
PHP Code:
static cell AMX_NATIVE_CALL set_user_flags(AMX *amxcell *params/* 3 param */
{
    
int index params[1];
    
    if (
index || index gpGlobals->maxClients)
    {
        
LogError(amxAMX_ERR_NATIVE"Invalid player id %d"index);
        return 
0;
    }
    
    
CPlayerpPlayer GET_PLAYER_POINTER_I(index);
    
int flag params[2];
    
int id params[3];
    
    if (
id 0)
        
id 0;
    
    if (
id 31)
        
id 31;
    
    
pPlayer->flags[id] |= flag;
    
    return 
1;

__________________
Bugsy is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-03-2009 , 22:24   Re: Temporary admin
Reply With Quote #10

set_user_flags should be named add_user_flags.
The real set_user_flags should be like this:
Code:
real_set_user_flags( iPlayer, iFlags ) {     remove_user_flags( iPlayer, get_user_flags( iPlayer ) );     set_user_flags( iPlayer, iFlags ); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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 21:56.


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