Yes Actually, anyone could run that command, because you forgot to restrict it with:
Code:
if( !cmd_access( id, lvl, cid, 2 ) )
return PLUGIN_HANDLED
And you forgot to register a client command to remove admins (you have the function for it)..
And the following just wont work, you need to read the file contents line by line, and compare each line.. not the file name..
Code:
if(containi(gFileLocation,adminid)
You have alot of errors, both syntax and logic, and you need to think it through alot more... mainly your file access commands and logic.. look at some examples from other plugins which do this...
I could fix you plugin for you, but that basically means rewriting the entire thing myself, and that would spoil the fun for you.. Keep trying tho, and study!!
Edit: here, I removed the syntax errors, but the logic is still wrong, and I can GUARANTEE this wont work still even tho it compiles fine.. it is logically incorrect...
Code:
#include <amxmodx>
#include <amxmisc>
new gFileLocation[] = "addons/amxmodx/configs/users.ini"
new gTextName[32]
public plugin_init()
{
register_plugin("Admin Access","1.1","JoeCaprini")
register_clcmd("amx_addadmin","addadmin",ADMIN_BAN," <steamid> <access levels>")
}
public addadmin(id,lvl,cid)
{
if( !cmd_access( id, lvl, cid, 2 ) )
return PLUGIN_HANDLED
new adminid[32]
new accesslvls[32]
read_argv(1,adminid,31)
read_argv(2,accesslvls,31)
if( containi(gFileLocation,adminid) > -1 )
{
client_print(id,print_console,"[AMX] User is already an admin")
return PLUGIN_HANDLED
}
format(gTextName,31,"^"%s^" ^"^" ^"%s^"",adminid,accesslvls)
write_file(gFileLocation,gTextName,-1)
return PLUGIN_CONTINUE
}
public removeadmin(id)
{
new adminremove[32]
new len, getline = 0
new adminlook[32]
read_argv(1,adminremove,31)
if(read_argc() == 0)
{
client_print(id,print_console,"[AMX] Must specify a user")
return PLUGIN_HANDLED
}
format(gTextName,31,";")
read_file(gFileLocation,getline,adminlook,31,len)
if(equali(adminlook,adminremove))
{
write_file(gFileLocation,gTextName,getline)
return PLUGIN_CONTINUE
}
return PLUGIN_CONTINUE
}