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

Your own Admin System


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 03-14-2009 , 18:36   Your own Admin System
Reply With Quote #1

Hi, this is my first tutorial that I do in English. So sorry my bad words. xD

In this tutorial I will explain how to make your own "Admin System"
You need prior knowledge.

PHP Code:
#include <amxmodx>

// Arrays, Then we add the Dimensions.
new Array:g_steamid
new Array:g_password
new Array:g_flags
new Array:g_mode

// Array of player flags
new Array:g_playerflags

// We need to create a cvar por setinfo & for default flag.
new cvar_setinfo
new cvar_defaultflag

// Here are the flags for loggins types.
enum
{
    
KZ_JOIN_PASS = (1<<0),
    
KZ_JOIN_TAGS = (1<<1),
    
KZ_JOIN_STEAM = (1<<2),
    
KZ_JOIN_IP = (1<<3),
    
KZ_JOIN_NOPASS = (1<<4)
}

public 
plugin_precache() 
{
    
register_plugin("Admins Loggin""1.0""ReymonARG")
    
    
// Now create the 2 cvars for custom somethings.
    
cvar_setinfo register_cvar("fakeadmin_setinfo""_pw")
    
cvar_defaultflag register_cvar("fakeadmin_defaultflag""z")
    
    
register_concmd("fakeadmin_reload""fakereload"ADMIN_RCON)
    
    
// We need to create the dimensions for the Arrays
    
g_steamid ArrayCreate(321)
    
g_password ArrayCreate(321)
    
g_flags ArrayCreate(11)
    
g_mode ArrayCreate(11)
    
g_playerflags ArrayCreate(11)
    
    for( new 
0<= 32i++)
        
ArrayPushCell(g_playerflags0)
    
    
// Well now we need to get the list of admins
    
fake_get_admins("addons/amxmodx/configs/newusers.ini")
}

public 
fakereload(idlevel)
{
    if( 
get_user_flags(id) & level )
    {
        
fake_get_admins("addons/amxmodx/configs/newusers.ini")
        
        for( new 
1<= 32i++)
        {
            if( !
is_user_connected(i) ) continue
            
fakeadmin_authplayer(i)
        }
    }
    
    return 
PLUGIN_HANDLED
}

public 
fake_get_admins(const filename[])
{
    
// First we have to create some static collet the info.
    
static data[192], steamid[32], password[32], flags[32], mode[10]
    
    
// For reload admins. We need to clean all information and get again.
    
ArrayClear(g_steamid)
    
ArrayClear(g_password)
    
ArrayClear(g_flags)
    
ArrayClear(g_mode)
    
    
// Now we need to open the file and read, line per line.
    
new fopen(filename"rt" )
    while( !
feof(f) )
    {
        
fgetsfdata191)
        
// With continue if dont is the data that we want.
        
if( data[0] == '/' && data[1] == '/' || data[0] == ';' || data[0] == ' ' || data[0] == '^n') continue
        
        
// If dont are all param go to next line.
        
if( parsedatasteamid31password31flags31mode9) != ) continue
        
        
// Push the information into Arrays items.
        
ArrayPushString(g_steamidsteamid)
        
ArrayPushString(g_passwordpassword)
        
ArrayPushCell(g_flagsread_flags(flags))
        
ArrayPushCell(g_moderead_flags(flags))
    }
    
// This is very important. We need to close the file.
    
fclose(f)
    
    
// We print the num of items that SteamId Array have.
    // Why dont is -1, Because array have item 0 to.
    
server_print("%i Admin from %s"ArraySize(g_steamid), filename)
    
    return 
1
}

public 
client_connect(id)
{
    static 
defaultflags[32]
    
get_pcvar_string(cvar_defaultflagdefaultflags31)
    
    
// First of all. We set player the defaults flags. Then if is admin we edit.
    
ArraySetCell(g_playerflagsidread_flags(defaultflags) )
}

public 
client_authorized(id)
{
    
fakeadmin_authplayer(id)
}

// Player change name?
public client_infochanged(id)
{
    static 
oldname[32], newname[32]
    
get_user_name(idoldname31)
    
get_user_info(id"name"newname31)
    
    if( !
equal(oldnamenewname) )
        
fakeadmin_authplayer(idnewname)
}

// Auth Player
stock fakeadmin_authplayer(id, const newname[] = "")
{
    static 
name[32], authid[32], ip[32]
    
    
// If is seted name copy to new array, ifnot get the name.
    
if( equal(newname"") )
        
get_user_name(idname31)
    else
        
copy(name31newname)
    
    static 
plr_steamid[32], plr_password[32], plr_flagsplr_mode
    
static setinfo[32], setinfo_tag[32// If needed password
    
get_pcvar_string(cvar_setinfosetinfo_tag31)
    
    
// Now we get player steamid & ip
    
get_user_authid(idauthid31)
    
get_user_ip(idip311// Very important this. Without ip port.
    
get_user_info(idsetinfo_tagsetinfo31)
    
    for( new 
0sizeof(g_steamid); i++)
    {    
        
// First of all, we need to get the information.
        
ArrayGetString(g_steamidiplr_steamid31)
        
ArrayGetString(g_passwordiplr_password31)
        
plr_flags ArrayGetCell(g_flagsi)
        
plr_mode ArrayGetCell(g_modei)
        
        
// Now. select the login mode.
        
if( plr_mode KZ_JOIN_STEAM )
        {
            
// If equal the steamid of the list cotinue.
            
if( equal(plr_steamidauthid) )
            {
                
// Now we need to check if password required or not.
                
if( plr_mode KZ_JOIN_NOPASS )
                {
                    return 
ArraySetCell(g_playerflagsidplr_flags)
                }
                else
                {
                    
// If equal the password, Set flags
                    
if( equal(plr_passwordsetinfo) )
                    {
                        return 
ArraySetCell(g_playerflagsidplr_flags)
                    }
                    else
                    {
                        
// If is seted kick player con bad password. Kick with reason..
                        
if( plr_mode KZ_JOIN_PASS )
                        {
                            return 
server_cmd("kick #%d  You dont have Access to this Server"get_user_userid(id))
                        }
                    }
                }
            }
        }
        else if( 
plr_mode KZ_JOIN_IP )
        {            
            if( 
equal(plr_steamidip) )
            {
                if( 
plr_mode KZ_JOIN_NOPASS )
                {
                    return 
ArraySetCell(g_playerflagsidplr_flags)
                }
                else
                {
                    if( 
equal(plr_passwordsetinfo) )
                    {
                        return 
ArraySetCell(g_playerflagsidplr_flags)
                    }
                    else
                    {
                        if( 
plr_mode KZ_JOIN_PASS )
                        {
                            return 
server_cmd("kick #%d  You dont have Access to this Server"get_user_userid(id))
                        }
                    }
                }
            }
        }
        else
        {
            static 
is_tag_flag = -1
            
if( plr_mode KZ_JOIN_TAGS )
            {
                
is_tag_flag containi(nameplr_steamid)
            }
            
            if( 
is_tag_flag != -||  equal(plr_steamidname) )
            {
                if( 
plr_mode KZ_JOIN_NOPASS )
                {
                    return 
ArraySetCell(g_playerflagsidplr_flags)
                }
                else
                {
                    if( 
equal(plr_passwordsetinfo) )
                    {
                        return 
ArraySetCell(g_playerflagsidplr_flags)
                    }
                    else
                    {
                        if( 
plr_mode KZ_JOIN_PASS )
                        {
                            return 
server_cmd("kick #%d  You dont have Access to this Server"get_user_userid(id))
                        }
                    }
                }
            }            
        }    
    }
    
    return 
1

For example I use this flags in my kz plugin.

PHP Code:
enum
{
    
KZ_USER_NONE 0,
    
KZ_USER_KICK = (1<<0),
    
KZ_USER_BAN = (1<<1),
    
KZ_USER_REWARDS = (1<<2),
    
KZ_USER_GIVEREWARDS = (1<<3),
    
KZ_USER_SETSTART = (1<<4),
    
KZ_USER_COLORCHAT = (1<<5),
    
KZ_USER_RCON = (1<<6),
    
KZ_USER_RESERVATION = (1<<7),
    
KZ_USER_IMMUNITY = (1<<8),
    
KZ_USER_SETC4 = (1<<9),
    
KZ_USER_MODEL = (1<<10),
    
KZ_USER_SCOREBOARD = (1<<11),
    
KZ_USER_LEVEL_A = (1<<12),
    
KZ_USER_LEVEL_B = (1<<13),
    
KZ_USER_LEVEL_C = (1<<14),
    
KZ_USER_LEVEL_D = (1<<15),
    
KZ_USER_LEVEL_E = (1<<16),
    
KZ_USER_ADMIN = (1<<17),
    
KZ_USER_PLAYER = (1<<25)

TODO:
Add like a fakeadmin_addadmin.
SQLx Version
A Example to use flags.

Thanks for reading. I will complete with yours opinions.


__________________

Last edited by AntiBots; 03-14-2009 at 21:51.
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 03-14-2009 , 23:47   Re: Your own Admin System
Reply With Quote #2

What's wrong with AMXX's admin system? O_o
Spunky is offline
Send a message via AIM to Spunky
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 03-15-2009 , 00:11   Re: Your own Admin System
Reply With Quote #3

Quote:
Originally Posted by Spunky View Post
What's wrong with AMXX's admin system? O_o
Anything. But if you want a more custom mod. This can be a good option.
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 03-15-2009 , 00:16   Re: Your own Admin System
Reply With Quote #4

Quote:
Originally Posted by AntiBots View Post
Anything. But if you want a more custom mod. This can be a good option.
Or you need to tie admin privilleges to something else, like a player registration system.
__________________

Community / No support through PM
danielkza is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 03-15-2009 , 00:28   Re: Your own Admin System
Reply With Quote #5

Don't hardcode your paths
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 03-15-2009 , 01:20   Re: Your own Admin System
Reply With Quote #6

Quote:
Originally Posted by YamiKaitou View Post
Don't hardcode your paths
And just noticed: use 'else if', it exists for a reason.
__________________

Community / No support through PM
danielkza is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-15-2009 , 01:49   Re: Your own Admin System
Reply With Quote #7

PHP Code:
    if( equal(newname"") ) 

PHP Code:
    if( !newname[0] ) 
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
beckham9224
Senior Member
Join Date: Feb 2009
Location: Asia, Mongolia
Old 03-15-2009 , 04:27   Re: Your own Admin System
Reply With Quote #8

Pretty hard to learn it... cuz imma n00b :[
beckham9224 is offline
TheDS1337
Veteran Member
Join Date: Jun 2012
Old 02-12-2013 , 17:39   Re: Your own Admin System
Reply With Quote #9

Reaaaaaaaaaaly Thank's, finaly i found it
TheDS1337 is offline
hLiaS
Senior Member
Join Date: Aug 2011
Location: In My Holly Dreams
Old 03-11-2013 , 16:31   Re: Your own Admin System
Reply With Quote #10

can anyone create natives for this??
hLiaS is offline
Send a message via Skype™ to hLiaS
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 12:27.


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