Raised This Month: $ Target: $400
 0% 

Need verify addadmin if already exists


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
daNzEt
Senior Member
Join Date: Sep 2010
Location: Romania
Old 01-06-2014 , 07:06   Need verify addadmin if already exists
Reply With Quote #1

Hello,

As i wrote in tittle can someone help me with this modify

PHP Code:
public cmdAddAdmin(idlevelcid)
{
    if(!(
get_user_flags(id) & ADMIN_IMMUNITY))
    {
        
console_print(id"Nu ai primit access la aceasta comanda")

        
client_cmd(id"spk ^"vox/access is denied^"")        
   
        return 
PLUGIN_HANDLED;
    }
        
    new 
idtype ADMIN_STEAM ADMIN_LOOKUP

    
if (read_argc() >= 5)
    {
        new 
t_arg[16]
        
read_argv(4t_arg15)
        
        if (
equali(t_arg"steam"))
        {
            
idtype ADMIN_STEAM
        
}
        
        else if (
equali(t_arg"ip"))
        {
            
idtype ADMIN_IPADDR
        
}
        
        else if (
equali(t_arg"name"))
        {
            
idtype ADMIN_NAME
            
            
if (equali(t_arg"name"))
            {
                
idtype |= ADMIN_LOOKUP
            
}
        }
        
        else
        {
            
console_print(id"Acest nume sau authid: ^"%s^" nu poate fi gasit"t_arg)
            
            return 
PLUGIN_HANDLED;
        }
    }

    new 
arg[33]
    
read_argv(1arg32)
    new 
player = -1
    
    
if (idtype ADMIN_NAME)
    {
        
player cmd_target(idargCMDTARGET_ALLOW_SELF CMDTARGET_NO_BOTS)
        
        if (
player)
        {
            
idtype |= ADMIN_LOOKUP
        
}
        
        else
        {
            
idtype &= ~ADMIN_LOOKUP
        
}
    }    
    
    else if (
idtype ADMIN_STEAM)
    {
        if (
containi(arg"STEAM_0:") == -1)
        {
            
idtype |= ADMIN_LOOKUP
            
            player 
cmd_target(idargCMDTARGET_ALLOW_SELF CMDTARGET_NO_BOTS)
        }
        
        else
        {
            new 
_steamid[44]
            static 
_players[32], _num_pv
            get_players
(_players_num)
            
            for (new 
_i=0_i<_num_i++)
            {
                
_pv _players[_i]
                
get_user_authid(_pv_steamidsizeof(_steamid)-1)
                
                if (!
_steamid[0])
                {
                    continue
                }
                
                if (
equal(_steamidarg))
                {
                    
player _pv
                    
break
                }
            }    
            
            if (
player 1)
            {
                
idtype &= ~ADMIN_LOOKUP
            
}        
        }
    }
    
    else if (
idtype ADMIN_IPADDR)
    {
        new 
len strlen(arg)
        new 
dotschars
        
        
for (new 0leni++)
        {
            if (
arg[i] == '.')
            {
                if (!
chars || chars 3)
                {
                    break
                }
                
                if (++
dots 3)
                {
                    break
                }
                
                
chars 0
            
}
            
            else
            {
                
chars++
            }
            
            if (
dots != || !chars || chars 3)
            {
                
idtype |= ADMIN_LOOKUP
                
                player 
find_player("dh"arg)
            }
        }
    }
    
    if (
idtype ADMIN_LOOKUP && !player)
    {
        
console_print(id"Jucatorul cu acest nume / ip nu este conectat sau exista deja")
        
        return 
PLUGIN_HANDLED;
    }    
    
    new 
flags[64];
    
read_argv(2flags63)

    new 
password[64];
    
    if (
read_argc() >= 4)
    {
        
read_argv(3password63)
    }
    
    new 
auth[33];
    new 
Comment[33];
    
    if (
idtype ADMIN_LOOKUP)
    {
        
get_user_name(playerCommentsizeof(Comment)-1)
        
        if (
idtype ADMIN_STEAM)
        {
            
get_user_authid(playerauth32)
        }
        
        else if (
idtype ADMIN_IPADDR)
        {
            
get_user_ip(playerauth32)
        }
        
        else if (
idtype ADMIN_NAME)
        {
            
get_user_name(playerauth32)
        }
    }
    
    else
    {
        
copy(auth32arg)
    }
    
    new 
type[16], len
    
    
if (idtype ADMIN_STEAM)
    {
        
len += format(type[len], 15-len"c")
    }
    
    else if (
idtype ADMIN_IPADDR)
    {
        
len += format(type[len], 15-len"d")
    }
    
    if (
strlen(password) > 0)
    {
        
len += format(type[len], 15-len"a")
    }
    
    else
    {
        
len += format(type[len], 15-len"e")
    }
    
    
AddAdmin(idauthflagspasswordtypeComment)

    if (
player 0)
    {
        new 
name[32]
        
get_user_info(player"name"name31)
        
        
accessUser(playername)
    }
    
    
client_cmd(id"spk ^"vox/access granted for user^"")
    
    
cmdReloadAdmins(idADMIN_CFG0)

    return 
PLUGIN_HANDLED;
}

AddAdmin(idauth[], accessflags[], password[], flags[], comment[]="")
{
    new 
configsDir[64]
    
get_configsdir(configsDir63)
    
    
format(configsDir63"%s/users.ini"configsDir)
    
    if (!
file_exists(configsDir))
    {
        
console_print(id"Fisierul ^"%s^" nu exista"configsDir)
        
        return
    }

    new 
line 0textline[256], len
    
const SIZE 63
    
    
new line_steamid[SIZE 1], line_password[SIZE 1], line_accessflags[SIZE 1], line_flags[SIZE 1], parsedParams
        
    
while ((line read_file(configsDirlinetextline255len)))
    {
        if (
len == || equal(textline";"1))
            continue

        
parsedParams parse(textlineline_steamidSIZEline_passwordSIZEline_accessflagsSIZEline_flagsSIZE)
            
        if (
parsedParams != 4)
            continue
            
        if (
containi(line_flagsflags) != -&& equal(line_steamidauth))
        {
            
console_print(id"Adminul cu SteamID: ^"%s^" exista deja"auth)
            
            return
        }
    }

    new 
linetoadd[512]
        
    if (
comment[0]==0)
    {
        
formatex(linetoadd511"^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^""authpasswordaccessflagsflags)
    }
        
    else
    {
        
formatex(linetoadd511"^r^n^"%s^" ^"%s^" ^"%s^" ^"%s^""authpasswordaccessflagsflags)
    }
    
    
console_print(id"Ai adaugat cu succes adminul ^"%s^""auth)

    if (!
write_file(configsDirlinetoadd))
    {
        
console_print(id"Nu s-a putut adauga adminul in %s"configsDir)
    }
    
    new 
name[32];
    
get_user_name(idname31)
    
    
chat_color(0"!nADMIN !t%s!n: adauga admin (!g%s!n) acces (!g%s!n)"nameauthaccessflags)
    
    
console_print(id"Admin ^"%s^" cu acces ^"%s^" a fost adaugat in baza de date"authaccessflags)
    
    
log_to_file("admin.log""ADMIN %s: adauga admin (%s) acces (%s)"nameauthaccessflags)

I need to verify when someone add an admin and if his IP/name already exists to print a message

I see it's only for adding on steam id:

PHP Code:
if (containi(line_flagsflags) != -&& equal(line_steamidauth))
{
    
console_print(id"Adminul cu SteamID: ^"%s^" exista deja"auth)
            
    return

Also is for this message:

PHP Code:
if (idtype ADMIN_LOOKUP && !player)
    {
        
console_print(id"Jucatorul cu acest nume / ip nu este conectat sau exista deja")
        
        return 
PLUGIN_HANDLED;
    } 
But server print this message in both case (if ip/name already exists, ori ip/name is not connect to server)

Can someone help?

Last edited by daNzEt; 01-06-2014 at 07:09.
daNzEt is offline
Send a message via Yahoo to daNzEt Send a message via Skype™ to daNzEt
 


Thread Tools
Display Modes

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 20:24.


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