Well I have put my War plugin on hold, and I decided to make this plugin. What it does is when someone types amx_login <username> <password>into console it checks with the file custom\amx_login\loginusers.ini and sees if they user and pass are correct, then sets them as admin.
Code:
/* AMX-X Login Script
Commands: -
amx_login <user> <password>
(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]
get_customdir(usercfg, 63)
format(usercfg, 63, "%s/amx_login/loginusers.ini", usercfg)
if (file_exists(usercfg)){
while(read_file(usercfg,i,linestring,255,linesize)&&i < max_admins){
if(linestring[0] == ';'){
continue
}
parse(linestring, username[31], 31, password[31], 31, flags[31], 31)
read_argv(1,arguser,31)
read_argv(2,argpass,31)
if((equal(username, arguser))&&(equal(password, argpass))){
set_user_flags(id, 1, id)
new text[64]
format(text, 128, "[AMXX AUTH] You are now logged in, with the flags: s%.", flags)
client_print(id, print_chat, text)
return PLUGIN_CONTINUE
}
if(!(equal(username, arguser))&&(equal(password, argpass))){
client_print(id, print_chat, "[AMXX AUTH] Incorrect username and/or password.")
return PLUGIN_CONTINUE
}
}
}
return PLUGIN_CONTINUE
}
public plugin_init(){
register_plugin("Admin Login","1.0","James Romeril")
register_clcmd("amx_login","login",-1,"amx_login <username> <password>")
}
This is what I have in my loginusers.ini
Code:
"pxl" "password" "abcdefghijklmnopqrstuz"
So I start my dedicated and join it. Then I type into console amx_login and it says Unknown Command: amx_login.
Then I type into console amx_login pxl password and it freezes my server! I get connection lost and I can't see any error code because the Steam HLDS is screwed. So can someone just check over my code /methinks there is something wrong with the looping.
__________________