Ok, it works now, except that when you put in the correct name and password it says you have admin status, but you don't. Secondly if you get the password or username wrong, it crashes the HLDS. Any ideas anyone?
Code:
/* AMX-X Login Script
Commands: -
amx_login <user> <password>
MUCH Thanks to Johnny got his gun.
(c) 2003, James Romeril
This file is provided as is (no warranties).
*/
#include <amxmodx>
#include <amxmisc>
#define max_admins 64
public login(id)
{
new usercfg[64]
new linestring[255]
new linesize = 0
new i = 0
new arguser[32]
new argpass[32]
new username[32]
new password[32]
new flags[32]
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/amx_login/loginusers.ini", usercfg)
if (file_exists(usercfg)){
while(read_file(usercfg, i,linestring,254,linesize)&& i < max_admins){
if(linestring[0] == ';'){
continue
}
parse(linestring, username, 31, password, 31, flags, 31)
if((equal(username, arguser))&&(equal(password, argpass))){
set_user_flags(0, ADMIN_LEVEL_A, id)
new text[128]
format(text, 128, "[AMXX AUTH] You are now logged in, with the flags: %s.", flags)
client_print(id, print_console, text)
return PLUGIN_HANDLED
}
}
client_print(id, print_console, "[AMXX AUTH] Incorrect username and/or password.")
}
}
return PLUGIN_HANDLED
}
public plugin_init(){
register_plugin("Admin Login","1.0","James Romeril")
register_clcmd("amx_login","login",-1,"amx_login <username> <password>")
}