Code:
#include <amxmodx>
#include <amxmisc>
#define max_admins 64
public login(id)
{
new usercfg[64]
new arguser[32], argpass[32], password[32]
new line = 0
new flags
new strflags[32]
new linetext[255], linetextlength
read_argv(1,arguser,31)
read_argv(2,argpass,31)
{
if((arguser[0] > 0)&&(argpass[0] > 0))
{
get_customdir(usercfg, 63)
format(usercfg, 63, "%s/amxmodx_login/admins.ini", usercfg)
if (file_exists(usercfg))
{
while ((line = read_file(usercfg, line, linetext, 256, linetextlength)))
{
if(linetext[0] == ';')
{
continue
}
parse(linetext, 31, password, 31, strflags, 31)
flags = read_flags(strflags)
if((equal(arguser))&&(equal(password, argpass)))
{
set_user_flags(id, flags)
new text[128]
format(text, 128, "[AMXX AUTH] You are now logged in, with the flags: %s.", strflags)
client_print(id, print_console, text)
return PLUGIN_HANDLED
}
}
client_print(id, print_console, "[AMXX AUTH] Incorrect password.")
}
}
return PLUGIN_HANDLED
}
public logout(id)
{
remove_user_flags(id, -1)
client_print(id, print_console, "[AMXX AUTH] You are now logged out of administrator status")
return PLUGIN_HANDLED
}
public plugin_init()
{
///////////gonna fix later
register_clcmd("amx_login","login",-1,"amx_login - <password> - Logs a player in as admin")
register_clcmd("amx_logout","logout",-1,"amx_logout - Logs a player out of admin")
}