Ir para conteúdo
Faça parte da equipe! (2024) ×
Conheça nossa Beta Zone! Novas áreas a caminho! ×
  • Quem está por aqui   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
  • 0

[AJUDA] - Plugin dando erro


GTSBr - ZaturN
 Compartilhar

Pergunta

Alguém pode consertar esse plugin aqui pra mim.

 

 

#include <amxmodx>

#include <celltrie>

#include <cstrike>

#include <fakemeta>

#include <hamsandwich>

#include <sqlx>

 

#define VERSION "8.0"

#define TASK_MESS 1000

#define TASK_KICK 2000

#define TASK_MENU 3000

#define TASK_TIMER 4000

#define TASK_ADVERT 5000

#define TASK_AJC 6000

#define MENU_TASK_TIME 0.5

#define AJC_TASK_TIME 0.1

#define AJC_ADMIN_FLAG ADMIN_IMMUNITY

#define SALT "8c4f4370c53e0c1e1ae9acd577dddbed"

 

//Start of CVAR pointers

new g_on;

new g_save;

new g_host;

new g_user;

new g_pass;

new g_db;

new g_setinfo_pr;

new g_regtime;

new g_logtime;

new g_pass_length;

new g_attempts;

new g_chp_time;

new g_reg_log;

new g_chp_log;

new g_aulog_log;

new g_blind;

new g_comm;

new g_logout;

new g_count

new g_advert;

new g_advert_int;

new g_ajc_team;

new g_ajc_admAnew g_ajc_team;

new g_ajc_admin;

new g_ajc_class[2];

new g_ajc_change;

new g_member;

new g_time;

new g_time_pass;

//End of CVAR pointers

 

//Start of Arrays

new configs_dir[64]

new cfg_file[256];

new reg_file[256];

new commands_file[256];

new count;

new sz_time[9];

new line = 0;

new text[512];

new params[2];

new check_name[32];

new check_pass[34];

new check_status[11];

new query[512];

new Handle:g_sqltuple;

new password[33][34];

new typedpass[32];

new new_pass[33][32];

new hash[34];

new pass_prefix[32];

new attempts[33];

new times[33];

new g_player_time[33];

new g_client_data[33][35];

new value;

new menu[512];

new keys;

new length;

new g_maxplayers;

new g_saytxt

new g_screenfade

new g_sync_hud

//End fo Arrays

 

//Start of Booleans

new bool:error = false

new bool:data_ready = false;

new bool:is_logged[33];

new bool:is_registered[33];

new bool:is_autolog[33];

new bool:cant_change_pass[33];

new bool:changing_name[33];

//End of Booleans

 

//Start of Trie handles

new Trie:g_commands;

new Trie:g_login_times;

new Trie:g_cant_login_time;

new Trie:g_pass_change_times;

new Trie:g_cant_change_pass_time;

//End of Trie handles

 

//Start of Constants

new const separator_1[] = "==============================================================================="

new const separator_2[] = "-------------------------------------------------------------------------------"

new const prefix[] = "[REGISTER SYSTEM]";

new const log_file[] = "register_system_log.txt";

new const JOIN_TEAM_MENU_FIRST[] = "#Team_Select";

new const JOIN_TEAM_MENU_FIRST_SPEC[] = "#Team_Select_Spect";

new const JOIN_TEAM_MENU_INGAME[] = "#IG_Team_Select";

new const JOIN_TEAM_MENU_INGAME_SPEC[] = "#IG_Team_Select_Spect";

new const JOIN_TEAM_VGUI_MENU = 2;

 

//Start of CVARs

new const g_cvars[29][] =

{

"rs_on",

"rs_save_type",

"rs_host",

"rs_user",

"rs_pass",

"rs_db",

"rs_password_prefix",

"rs_register_time",

"rs_login_time",

"rs_password_len",

"rs_attempts",

"rs_chngpass_times",

"rs_register_log",

"rs_chngpass_log",

"rs_autologin_log",

"rs_blind",

"rs_commands",

"rs_logout",

"rs_count",

"rs_advert",

"rs_advert_int",

"rs_ajc_team",

"rs_ajc_class_t",

"rs_ajc_class_ct",

"rs_ajc_admin",

"rs_ajc_change",

"rs_remember_punish_by",

"rs_cant_login_time",

"rs_cant_change_pass_time"

};

//End of CVARs

//End of Constants

 

/*==============================================================================

Start of Plugin Init

================================================================================*/

public plugin_init()

{

register_plugin("Register System", VERSION, "m0skVi4a ;]")

 

g_on = register_cvar(g_cvars[0], "1")

g_save = register_cvar(g_cvars[1], "0")

g_host = register_cvar(g_cvars[2], "127.0.0.1")

g_user = register_cvar(g_cvars[3], "root")

g_pass = register_cvar(g_cvars[4], "123456")

g_db = register_cvar(g_cvars[5], "registersystem")

g_setinfo_pr = register_cvar(g_cvars[6], "_rspass")

g_regtime = register_cvar(g_cvars[7], "0")

g_logtime = register_cvar(g_cvars[8], "60.0")

g_pass_length = register_cvar(g_cvars[9], "6")

g_attempts = register_cvar(g_cvars[10], "3")

g_chp_time = register_cvar(g_cvars[11], "3")

g_reg_log = register_cvar(g_cvars[12], "1")

g_chp_log = register_cvar(g_cvars[13], "1")

g_aulog_log = register_cvar(g_cvars[14], "1")

g_blind = register_cvar(g_cvars[15], "1")

g_comm = register_cvar(g_cvars[16], "1")

g_logout = register_cvar(g_cvars[17], "0")

g_count = register_cvar(g_cvars[18], "1")

g_advert = register_cvar(g_cvars[19], "1")

g_advert_int = register_cvar(g_cvars[20], "60")

g_ajc_team = register_cvar(g_cvars[21], "0")

g_ajc_class[0] = register_cvar(g_cvars[22], "5")

g_ajc_class[1] = register_cvar(g_cvars[23], "5")

g_ajc_admin = register_cvar(g_cvars[24], "1")

g_ajc_change = register_cvar(g_cvars[25], "0")

g_member = register_cvar(g_cvars[26], "0")

g_time = register_cvar(g_cvars[27], "300")

g_time_pass = register_cvar(g_cvars[28], "300")

 

get_localinfo("amxx_configsdir", configs_dir, charsmax(configs_dir))

formatex(cfg_file, charsmax(cfg_file), "%s/registersystem.cfg", configs_dir)

formatex(reg_file, charsmax(reg_file), "%s/regusers.ini", configs_dir)

formatex(commands_file, charsmax(commands_file), "%s/registersystem_commands.ini", configs_dir)

 

register_message(get_user_msgid("ShowMenu"), "TextMenu")

register_message(get_user_msgid("VGUIMenu"), "VGUIMenu")

register_menucmd(register_menuid("Register System Main Menu"), 1023, "HandlerMainMenu")

register_menucmd(register_menuid("Password Menu"), 1023, "HandlerConfirmPasswordMenu")

register_clcmd("jointeam", "HookTeamCommands")

register_clcmd("chooseteam", "HookTeamCommands")

register_clcmd("LOGIN_PASS", "Login")

register_clcmd("REGISTER_PASS", "Register")

register_clcmd("CHANGE_PASS_NEW", "ChangePasswordNew")

register_clcmd("CHANGE_PASS_OLD", "ChangePasswordOld")

register_clcmd("AUTO_LOGIN_PASS", "AutoLoginPassword")

RegisterHam(Ham_Spawn, "player", "HookPlayerSpawn", 1)

register_forward(FM_PlayerPreThink, "PlayerPreThink")

register_forward(FM_ClientUserInfoChanged, "ClientInfoChanged")

 

register_dictionary("register_system.txt")

g_maxplayers = get_maxplayers()

g_saytxt = get_user_msgid("SayText")

g_screenfade = get_user_msgid("ScreenFade")

g_sync_hud = CreateHudSyncObj()

g_commands = TrieCreate()

g_login_times = TrieCreate()

g_cant_login_time = TrieCreate()

g_pass_change_times = TrieCreate()

g_cant_change_pass_time = TrieCreate()

}

/*==============================================================================

End of Plugin Init

================================================================================*/

 

/*==============================================================================

Start of Plugin Natives

================================================================================*/

public plugin_natives()

{

register_library("register_system")

register_native("is_registered", "_is_registered")

register_native("is_logged", "_is_logged")

register_native("is_autologged", "_is_autologged")

register_native("get_cant_login_time", "_get_cant_login_time")

register_native("get_cant_change_pass_time", "_get_cant_change_pass_time")

}

 

public _is_registered(plugin, parameters)

{

if(parameters != 1)

return false

 

new id = get_param(1)

 

if(!id)

return false

 

if(is_registered[id])

{

return true

}

 

return false

}

 

public _is_logged(plugin, parameters)

{

if(parameters != 1)

return false

 

new id = get_param(1)

 

if(!id)

return false

 

if(is_logged[id])

{

return true

}

 

return false

}

 

public _is_autologged(plugin, parameters)

{

if(parameters != 1)

return -1

 

new id = get_param(1)

 

if(!id)

return -1

 

if(is_autolog[id])

{

return true

}

 

return false

}

 

public _get_cant_login_time(plugin, parameters)

{

if(parameters != 1)

return -1

 

new id = get_param(1)

 

if(!id)

return -1

 

new data[35];

 

switch(get_pcvar_num(g_member))

{

case 0:

{

get_user_name(id, data, charsmax(data))

}

case 1:

{

get_user_ip(id, data, charsmax(data))

}

case 2:

{

get_user_authid(id, data, charsmax(data))

}

default:

{

get_user_name(id, data, charsmax(data))

}

}

 

if(TrieGetCell(g_cant_login_time, data, value))

{

new cal_time = get_pcvar_num(g_time) - (time() - value)

return cal_time

}

 

return -1

}

 

public _get_cant_change_pass_time(plugin, parameters)

{

if(parameters != 1)

return -1

 

new id = get_param(1)

 

if(!id)

return -1

 

new data[35];

 

switch(get_pcvar_num(g_member))

{

case 0:

{

get_user_name(id, data, charsmax(data))

}

case 1:

{

get_user_ip(id, data, charsmax(data))

}

case 2:

{

get_user_authid(id, data, charsmax(data))

}

default:

{

get_user_name(id, data, charsmax(data))

}

}

 

if(TrieGetCell(g_cant_change_pass_time, data, value))

{

new cal_time = get_pcvar_num(g_time_pass) - (time() - value)

return cal_time

}

 

return -1

}

/*==============================================================================

End of Plugin Natives

================================================================================*/

 

/*==============================================================================

Start of Executing plugin's config and choose the save mode

================================================================================*/

public plugin_cfg()

{

if(!get_pcvar_num(g_on))

return PLUGIN_HANDLED

 

server_print(" ")

server_print(separator_1)

server_print("Title : Register System")

server_print("Version : %s", VERSION)

server_print("Author : m0skVi4a ;]")

server_print("Site :

É necessário se cadastrar para acessar o conteúdo.
)

server_print(separator_2)

 

get_time("%H:%M:%S", sz_time, charsmax(sz_time))

 

if(!file_exists(cfg_file))

{

server_print("[%s] [ERROR] > File registersystem.cfg not found!", sz_time)

}

else

{

server_print("[%s] > Loading settings from registersystem.cfg", sz_time)

 

line = 0, length = 0, count = 0;

 

while(read_file(cfg_file, line++ , text, charsmax(text), length))

{

if(!text[0] || text[0] == '^n' || text[0] == ';' || (text[0] == '/' && text[1] == '/'))

continue

 

new cvar[32], param[32], bool:error_1 = true, bool:error_2 = true

 

trim(text)

parse(text, cvar, charsmax(cvar), param, charsmax(param))

 

for(new i = 0; i <= 28; i++)

{

if(equal(cvar, g_cvars))

{

error_1 = false

}

}

 

if(param[0] && !(equali(param, " ")))

{

error_2 = false

}

 

if(error_1)

{

server_print("[%s] [ERROR] > Unknown CVAR ^"%s^"", sz_time, cvar)

error = true

}

else

{

if(error_2)

{

server_print("[%s] [ERROR] > Bad value for ^"%s^"", sz_time, cvar)

error = true

}

else

{

server_print("[%s] [OK] > Read cvar ^"%s^" ^"%s^"", sz_time, cvar, param)

server_cmd("%s %s", cvar, param)

count++

}

}

}

 

if(!count)

{

server_print("[%s] [ERROR] > There were no CVARs in registersystem.cfg", sz_time)

error = true

}

}

 

server_print(separator_2)

 

if(error)

{

server_print("[%s] [WARNING] > Reading some data from configuration file failed!", sz_time)

server_print("> Please check [ERROR] messages above for solving this problem!")

}

else

{

server_print("[%s] [OK] > All settings loaded successfully!", sz_time)

}

 

server_print(separator_1)

server_print(" ")

 

set_task(1.0, "LoadData")

 

return PLUGIN_CONTINUE

}

 

public LoadData()

{

if(get_pcvar_num(g_save))

{

Init_MYSQL()

}

else

{

if(!file_exists(reg_file))

{

write_file(reg_file,";Register System file^n;Modifying may cause the clients to can not Login!^n^n")

server_print("%s Could not find Register System file - %s Creating new...", prefix, reg_file)

}

 

data_ready = true

 

for(new i = 1 ; i <= g_maxplayers ; i++)

{

if(!is_user_connecting(i) && !is_user_connected(i))

continue

 

CheckClient(i)

}

}

 

if(get_pcvar_num(g_comm))

{

line = 0, length = 0, count = 0, error = false;

get_time("%H:%M:%S", sz_time, charsmax(sz_time))

 

server_print(" ")

server_print(separator_1)

server_print(prefix)

server_print(separator_2)

 

if(!file_exists(commands_file))

{

server_print("[%s] [ERROR] > File registersystem_commands.ini not found!", sz_time)

error = true

}

else

{

server_print("[%s] > Loading settings from registersystem_commands.ini", sz_time)

 

line = 0, length = 0, count = 0;

 

while(read_file(commands_file, line++ , text, charsmax(text), length))

{

if(!text[0] || text[0] == '^n' || text[0] == ';' || (text[0] == '/' && text[1] == '/'))

continue

 

trim(text)

parse(text, text, charsmax(text))

 

TrieSetCell(g_commands, text, 1)

count++

}

 

if(count)

{

server_print("[%s] [OK] > %d command%s loaded!", sz_time, count, count > 1 ? "s" : "")

}

else

{

server_print("[%s] [ERROR] > There were no commands in registersystem_commands.ini", sz_time)

error = true

}

}

 

server_print(separator_2)

 

if(error)

{

server_print("[%s] [WARNING] > Reading some data from commands file failed!", sz_time)

server_print("> Please check [ERROR] messages above for solving this problem!")

}

else

{

server_print("[%s] [OK] > Commands file loaded successfully!", sz_time)

}

 

server_print(separator_1)

server_print(" ")

}

}

 

public Init_MYSQL()

{

new host[64], user[32], pass[32], db[128];

 

get_pcvar_string(g_host, host, charsmax(host))

get_pcvar_string(g_user, user, charsmax(user))

get_pcvar_string(g_pass, pass, charsmax(pass))

get_pcvar_string(g_db, db, charsmax(db))

 

g_sqltuple = SQL_MakeDbTuple(host, user, pass, db)

formatex(query, charsmax(query), "CREATE TABLE IF NOT EXISTS registersystem (Name VARCHAR(32), Password VARCHAR(34), Status VARCHAR(10))")

SQL_ThreadQuery(g_sqltuple, "QueryCreateTable", query)

}

 

public QueryCreateTable(failstate, Handle:query, error[], errcode, data[], datasize, Float:queuetime)

{

if(failstate == TQUERY_CONNECT_FAILED)

{

set_fail_state("[REGISTER SYSTEM] Could not connect to database!")

}

else if(failstate == TQUERY_QUERY_FAILED)

{

set_fail_state("[REGISTER SYSTEM] Query failed!")

}

else if(errcode)

{

server_print("%s Error on query: %s", prefix, error)

}

else

{

server_print("%s MYSQL connection succesful!", prefix)

 

data_ready = true

 

for(new i = 1 ; i <= g_maxplayers ; i++)

{

if(!is_user_connecting(i) && !is_user_connected(i))

continue

 

CheckClient(i)

}

}

}

/*==============================================================================

End of Executing plugin's config and choose the save mode

================================================================================*/

 

/*==============================================================================

Start of plugin's end function

================================================================================*/

public plugin_end()

{

TrieDestroy(g_commands)

TrieDestroy(g_login_times)

TrieDestroy(g_cant_login_time)

TrieDestroy(g_pass_change_times)

TrieDestroy(g_cant_change_pass_time)

}

/*==============================================================================

End of plugin's end function

================================================================================*/

 

/*==============================================================================

Start of Client's connect and disconenct functions

================================================================================*/

public client_authorized(id)

{

is_logged[id] = false

is_registered[id] = false

is_autolog[id] = false

cant_change_pass[id] = false

changing_name[id] = false

attempts[id] = 0

times[id] = 0

remove_tasks(id)

 

switch(get_pcvar_num(g_member))

{

case 0:

{

get_user_name(id, g_client_data[id], charsmax(g_client_data))

}

case 1:

{

get_user_ip(id, g_client_data[id], charsmax(g_client_data))

}

case 2:

{

get_user_authid(id, g_client_data[id], charsmax(g_client_data))

}

default:

{

get_user_name(id, g_client_data[id], charsmax(g_client_data))

}

}

 

if(TrieGetCell(g_login_times, g_client_data[id], value))

{

attempts[id] = value

 

if(attempts[id] >= get_pcvar_num(g_attempts))

{

params[0] = id

params[1] = 2

set_task(1.0, "KickPlayer", id+TASK_KICK, params, sizeof params)

}

}

 

if(TrieGetCell(g_pass_change_times, g_client_data[id], value))

{

times[id] = value

 

if(times[id] >= get_pcvar_num(g_chp_time))

{

cant_change_pass[id] = true

}

}

 

if(data_ready)

{

CheckClient(id)

}

}

 

public client_putinserver(id)

{

if(data_ready)

{

ShowMsg(id)

 

if(get_pcvar_num(g_advert) && get_pcvar_num(g_advert_int))

{

set_task(get_pcvar_float(g_advert_int), "ShowAdvert", id+TASK_ADVERT)

}

}

}

 

public client_disconnect(id)

{

is_logged[id] = false

is_registered[id] = false

is_autolog[id] = false

cant_change_pass[id] = false

changing_name[id] = false

attempts[id] = 0

times[id] = 0

remove_tasks(id)

}

/*==============================================================================

End of Client's connect and disconenct functions

================================================================================*/

 

/*==============================================================================

Start of Check Client functions

================================================================================*/

public CheckClient(id)

{

if(!get_pcvar_num(g_on) || is_user_bot(id) || is_user_hltv(id) || !data_ready)

return PLUGIN_HANDLED

 

remove_tasks(id)

is_registered[id] = false

is_logged[id] = false

is_autolog[id] = false

 

new name[32];

get_user_name(id, name, charsmax(name))

 

if(get_pcvar_num(g_save))

{

new data[1]

data[0] = id

 

formatex(query, charsmax(query), "SELECT `Password`, `Status` FROM `registersystem` WHERE Name = ^"%s^";", name)

 

SQL_ThreadQuery(g_sqltuple, "QuerySelectData", query, data, 1)

}

else

{

line = 0, length = 0;

 

while(read_file(reg_file, line++ , text, charsmax(text), length))

{

if(!text[0] || text[0] == '^n' || text[0] == ';' || (text[0] == '/' && text[1] == '/'))

continue

 

parse(text, check_name, charsmax(check_name), check_pass, charsmax(check_pass), check_status, charsmax(check_status))

 

if(!(equal(check_name, name)))

continue

 

is_registered[id] = true

password[id] = check_pass

 

if(equal(check_status, "LOGGED_IN"))

{

is_autolog[id] = true

CheckAutoLogin(id)

}

 

if(is_user_connected(id))

{

user_silentkill(id)

cs_set_user_team(id, CS_TEAM_UNASSIGNED)

ShowMsg(id)

 

if(get_pcvar_num(g_advert) && get_pcvar_num(g_advert_int))

{

set_task(get_pcvar_float(g_advert_int), "ShowAdvert", id+TASK_ADVERT)

}

}

 

break

}

}

return PLUGIN_CONTINUE

}

 

public QuerySelectData(FailState, Handle:Query, error[], errorcode, data[], datasize, Float:fQueueTime)

{

if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)

{

log_amx("%s", error)

return

}

else

{

new id = data[0];

new col_pass = SQL_FieldNameToNum(Query, "Password")

new col_status = SQL_FieldNameToNum(Query, "Status")

 

while(SQL_MoreResults(Query))

{

SQL_ReadResult(Query, col_pass, check_pass, charsmax(check_pass))

SQL_ReadResult(Query, col_status, check_status, charsmax(check_status))

is_registered[id] = true

password[id] = check_pass

 

if(equal(check_status, "LOGGED_IN"))

{

is_autolog[id] = true

CheckAutoLogin(id)

}

 

if(is_user_connected(id))

{

user_silentkill(id)

cs_set_user_team(id, CS_TEAM_UNASSIGNED)

ShowMsg(id)

 

if(get_pcvar_num(g_advert) && get_pcvar_num(g_advert_int))

{

set_task(get_pcvar_float(g_advert_int), "ShowAdvert", id+TASK_ADVERT)

}

}

 

SQL_NextRow(Query)

}

}

}

 

public CheckAutoLogin(id)

{

new client_password[32];

 

get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))

get_user_info(id, pass_prefix, client_password, charsmax(client_password))

hash = convert_password(client_password)

 

if(equal(hash, password[id]))

{

is_logged[id] = true

}

else

{

is_autolog[id] = false

}

}

/*==============================================================================

End of Check Client functions

================================================================================*/

 

/*==============================================================================

Start of Show Client's informative messages

================================================================================*/

public ShowMsg(id)

{

if(!get_pcvar_num(g_on))

return PLUGIN_HANDLED

 

remove_tasks(id)

 

set_task(5.0, "Messages", id+TASK_MESS)

 

params[0] = id

 

if(!is_registered[id])

{

if(get_pcvar_float(g_regtime) != 0)

{

if(!changing_name[id])

{

CreateMainMenuTask(id+TASK_MENU)

 

if(get_pcvar_num(g_count))

{

g_player_time[id] = get_pcvar_num(g_regtime)

ShowTimer(id+TASK_TIMER)

}

params[1] = 1

set_task(get_pcvar_float(g_regtime) + 3, "KickPlayer", id+TASK_KICK, params, sizeof params)

return PLUGIN_HANDLED

}

else

{

g_player_time[id] = -1

set_task(1.0, "ShowTimer", id+TASK_TIMER)

}

}

}

else if(!is_logged[id])

{

if(!changing_name[id])

{

CreateMainMenuTask(id+TASK_MENU)

 

if(get_pcvar_num(g_count))

{

g_player_time[id] = get_pcvar_num(g_logtime)

ShowTimer(id+TASK_TIMER)

}

params[1] = 2

set_task(get_pcvar_float(g_logtime) + 3, "KickPlayer", id+TASK_KICK, params, sizeof params)

return PLUGIN_HANDLED

}

else

{

g_player_time[id] = -1

set_task(1.0, "ShowTimer", id+TASK_TIMER)

}

}

return PLUGIN_CONTINUE

}

 

public ShowTimer(id)

{

id -= TASK_TIMER

 

if(!is_user_connected(id))

return PLUGIN_HANDLED

 

switch(g_player_time[id])

{

case 10..19:

{

set_hudmessage(255, 255, 0, -1.0, -1.0, 0, 0.02, 1.0,_,_, -1)

}

case 0..9:

{

set_hudmessage(255, 0, 0, -1.0, -1.0, 1, 0.02, 1.0,_,_, -1)

}

case -1:

{

set_hudmessage(255, 255, 255, -1.0, -1.0, 1, 0.02, 1.0,_,_, -1)

}

default:

{

set_hudmessage(0, 255, 0, -1.0, -1.0, 0, 0.02, 1.0,_,_, -1)

}

}

 

if(g_player_time[id] == 0)

{

ShowSyncHudMsg(id, g_sync_hud, "%L", LANG_SERVER, "KICK_HUD")

return PLUGIN_CONTINUE

}

else if(!is_registered[id] && get_pcvar_float(g_regtime))

{

if(g_player_time[id] == -1)

{

ShowSyncHudMsg(id, g_sync_hud, "%L", LANG_SERVER, "REGISTER_AFTER")

set_task(1.0, "ShowTimer", id+TASK_TIMER)

return PLUGIN_HANDLED

}

 

ShowSyncHudMsg(id, g_sync_hud, "%L", LANG_SERVER, g_player_time[id] > 1 ? "REGISTER_HUD" : "REGISTER_HUD_SEC", g_player_time[id])

}

else if(is_registered[id] && !is_logged[id])

{

if(g_player_time[id] == -1)

{

ShowSyncHudMsg(id, g_sync_hud, "%L", LANG_SERVER, "LOGIN_AFTER")

set_task(1.0, "ShowTimer", id+TASK_TIMER)

return PLUGIN_HANDLED

}

 

ShowSyncHudMsg(id, g_sync_hud, "%L ", LANG_SERVER, g_player_time[id] > 1 ? "LOGIN_HUD" : "LOGIN_HUD_SEC", g_player_time[id])

}

else return PLUGIN_HANDLED

 

g_player_time[id]--

 

set_task(1.0, "ShowTimer", id+TASK_TIMER)

 

return PLUGIN_CONTINUE

}

 

public Messages(id)

{

id -= TASK_MESS

 

if(!is_registered[id])

{

if(get_pcvar_float(g_regtime) != 0)

{

client_printcolor(id, "%L", LANG_SERVER, "REGISTER_CHAT", prefix, get_pcvar_num(g_regtime))

}

else

{

client_printcolor(id, "%L", LANG_SERVER, "YOUCANREG_CHAT", prefix)

}

}

else if(!is_logged[id])

{

client_printcolor(id, "%L", LANG_SERVER, "LOGIN_CHAT", prefix, get_pcvar_num(g_logtime))

}

else if(is_autolog[id])

{

client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_CHAT", prefix)

}

}

/*==============================================================================

End of Show Client's informative messages

================================================================================*/

 

/*==============================================================================

Start of Client's Auto Login Changer function

================================================================================*/

public AutoLoginPassword(id)

{

if(!get_pcvar_num(g_on))

return PLUGIN_HANDLED

 

read_args(typedpass, charsmax(typedpass))

remove_quotes(typedpass)

 

hash = convert_password(typedpass)

 

if(!equal(hash, password[id]))

{

TrieSetCell(g_login_times, g_client_data[id], ++attempts[id])

client_printcolor(id, "%L", LANG_SERVER, "LOG_PASS_INVALID", prefix, attempts[id], get_pcvar_num(g_attempts))

 

if(attempts[id] >= get_pcvar_num(g_attempts))

{

if(get_pcvar_num(g_count))

{

g_player_time[id] = 0

ShowTimer(id+TASK_TIMER)

}

 

if(get_pcvar_num(g_time))

{

TrieSetCell(g_cant_login_time, g_client_data[id], time())

}

else

{

TrieSetCell(g_cant_login_time, g_client_data[id], 0)

}

params[0] = id

params[1] = 3

set_task(2.0, "KickPlayer", id+TASK_KICK, params, sizeof params)

 

if(get_pcvar_num(g_time))

{

set_task(get_pcvar_float(g_time), "RemoveCantLogin", 0, g_client_data[id], sizeof g_client_data)

}

return PLUGIN_HANDLED

}

else

{

client_cmd(id, "messagemode AUTO_LOGIN_PASS")

}

 

return PLUGIN_HANDLED

}

else

{

get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))

client_cmd(id, "setinfo %s %s", pass_prefix, typedpass)

AutoLogin(id, true)

MainMenu(id)

}

return PLUGIN_CONTINUE

}

 

AutoLogin(id, bool:enabled = true)

{

if(!is_registered[id] || !is_logged[id])

return PLUGIN_HANDLED

 

new name[32];

get_user_name(id, name, charsmax(name))

 

if(get_pcvar_num(g_save))

{

formatex(query, charsmax(query), "UPDATE registersystem SET Status = ^"%s^" WHERE Name = ^"%s^";", enabled ? "LOGGED_IN" : "LOGGED_OUT", name)

SQL_ThreadQuery(g_sqltuple, "QuerySetData", query)

}

else

{

line = 0, length = 0;

 

while(read_file(reg_file, line++ , text, charsmax(text), length))

{

parse(text, text, charsmax(text))

 

if(!(equal(text, name)))

continue

 

formatex(text, charsmax(text), "^"%s^" ^"%s^" ^"%s^"", name, password[id], enabled ? "LOGGED_IN" : "LOGGED_OUT")

write_file(reg_file, text, line - 1)

 

break

}

}

 

if(enabled)

{

is_autolog[id] = true

client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_ON", prefix)

 

if(get_pcvar_num(g_aulog_log))

{

log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_AUTO_ON", name)

}

}

else

{

is_autolog[id] = false

client_printcolor(id, "%L", LANG_SERVER, "AUTO_LOGIN_OFF", prefix)

get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))

client_cmd(id, "setinfo %s ^"^"", pass_prefix)

 

if(get_pcvar_num(g_aulog_log))

{

log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_AUTO_OFF", name)

}

}

 

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Client's Auto Login Changer function

================================================================================*/

 

/*==============================================================================

Start of the Main Menu function

================================================================================*/

public CreateMainMenuTask(id)

{

id -= TASK_MENU

 

if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))

{

MainMenu(id)

set_task(MENU_TASK_TIME, "CreateMainMenuTask", id+TASK_MENU)

}

}

 

public MainMenu(id)

{

if(!get_pcvar_num(g_on) || !is_user_connected(id) || !data_ready)

return PLUGIN_HANDLED

 

length = 0

 

if(is_registered[id])

{

if(is_logged[id])

{

length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_LOG", LANG_SERVER, is_autolog[id] ? "AUTO_LOG_DIS" : "AUTO_LOG_EN")

keys = MENU_KEY_1|MENU_KEY_4|MENU_KEY_5|MENU_KEY_9|MENU_KEY_0

}

else

{

length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_REG")

keys = MENU_KEY_1|MENU_KEY_9

}

}

else

{

if(get_pcvar_float(g_regtime) == 0)

{

length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_NOTREG")

keys = MENU_KEY_2|MENU_KEY_9|MENU_KEY_0

}

else

{

length += formatex(menu[length], charsmax(menu) - length, "%L", LANG_SERVER, "MAIN_MENU_NOTREG_FORCE")

keys = MENU_KEY_2|MENU_KEY_9

}

}

show_menu(id, keys, menu, -1, "Register System Main Menu")

 

return PLUGIN_CONTINUE

}

 

public HandlerMainMenu(id, key)

{

switch(key)

{

case 0:

{

if(!is_logged[id])

{

client_cmd(id, "messagemode LOGIN_PASS")

}

else

{

AutoLogin(id, false)

 

if(get_pcvar_num(g_logout))

{

CheckClient(id)

CreateMainMenuTask(id+TASK_MENU)

}

else

{

if(get_pcvar_num(g_count))

{

g_player_time[id] = 0

ShowTimer(id+TASK_TIMER)

}

 

params[0] = id

params[1] = 4

set_task(2.0, "KickPlayer", id+TASK_KICK, params, sizeof params)

}

client_printcolor(id, "%L", LANG_SERVER, "LOG_OUT", prefix)

is_logged[id] = false

}

}

case 1:

{

client_cmd(id, "messagemode REGISTER_PASS")

}

case 3:

{

if(!is_logged[id])

return PLUGIN_HANDLED

 

if(cant_change_pass[id])

{

client_printcolor(id, "%L", LANG_SERVER, "CHANGE_TIMES", prefix, get_pcvar_num(g_chp_time))

MainMenu(id)

return PLUGIN_HANDLED

}

else

{

client_cmd(id, "messagemode CHANGE_PASS_NEW")

MainMenu(id)

}

}

case 4:

{

if(!is_logged[id])

{

MainMenu(id)

return PLUGIN_HANDLED

}

 

if(is_autolog[id])

{

AutoLogin(id, false)

}

else

{

client_cmd(id, "messagemode AUTO_LOGIN_PASS")

}

MainMenu(id)

}

case 8:

{

Info(id)

MainMenu(id)

}

case 9:

{

return PLUGIN_HANDLED

}

}

return PLUGIN_HANDLED

}

/*==============================================================================

End of the Main Menu function

================================================================================*/

 

/*==============================================================================

Start of Login function

================================================================================*/

public Login(id)

{

if(!get_pcvar_num(g_on) || !data_ready)

return PLUGIN_HANDLED

 

if(changing_name[id])

{

client_printcolor(id, "%L", LANG_SERVER, "LOGIN_AFTER")

return PLUGIN_HANDLED

}

 

if(!is_registered[id])

{

client_printcolor(id, "%L", LANG_SERVER, "LOG_NOTREG", prefix)

return PLUGIN_HANDLED

}

 

if(is_logged[id])

{

client_printcolor(id, "%L", LANG_SERVER, "LOG_LOGGED", prefix);

return PLUGIN_HANDLED

}

 

read_args(typedpass, charsmax(typedpass))

remove_quotes(typedpass)

 

if(equal(typedpass, ""))

return PLUGIN_HANDLED

 

hash = convert_password(typedpass)

 

if(!equal(hash, password[id]))

{

TrieSetCell(g_login_times, g_client_data[id], ++attempts[id])

client_printcolor(id, "%L", LANG_SERVER, "LOG_PASS_INVALID", prefix, attempts[id], get_pcvar_num(g_attempts))

 

if(attempts[id] >= get_pcvar_num(g_attempts))

{

if(get_pcvar_num(g_count))

{

g_player_time[id] = 0

ShowTimer(id+TASK_TIMER)

}

 

if(get_pcvar_num(g_time))

{

TrieSetCell(g_cant_login_time, g_client_data[id], time())

}

else

{

TrieSetCell(g_cant_login_time, g_client_data[id], 0)

}

params[0] = id

params[1] = 3

set_task(2.0, "KickPlayer", id+TASK_KICK, params, sizeof params)

 

if(get_pcvar_num(g_time))

{

set_task(get_pcvar_float(g_time), "RemoveCantLogin", 0, g_client_data[id], sizeof g_client_data)

}

return PLUGIN_HANDLED

}

else

{

client_cmd(id, "messagemode LOGIN_PASS")

}

return PLUGIN_HANDLED

}

else

{

is_logged[id] = true

attempts[id] = 0

remove_task(id+TASK_KICK)

client_printcolor(id, "%L", LANG_SERVER, "LOG_LOGING", prefix)

MainMenu(id)

client_cmd(id, "jointeam")

}

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Login function

================================================================================*/

 

/*==============================================================================

Start of Register function

================================================================================*/

public Register(id)

{

if(!get_pcvar_num(g_on) || !data_ready)

return PLUGIN_HANDLED

 

if(changing_name[id])

{

client_printcolor(id, "%L", LANG_SERVER, "REGISTER_AFTER")

return PLUGIN_HANDLED

}

 

read_args(typedpass, charsmax(typedpass))

remove_quotes(typedpass)

 

new passlength = strlen(typedpass)

 

if(equal(typedpass, ""))

return PLUGIN_HANDLED

 

if(is_registered[id])

{

client_printcolor(id, "%L", LANG_SERVER, "REG_EXISTS", prefix)

return PLUGIN_HANDLED

}

 

if(passlength < get_pcvar_num(g_pass_length))

{

client_printcolor(id, "%L", LANG_SERVER, "REG_LEN", prefix, get_pcvar_num(g_pass_length))

client_cmd(id, "messagemode REGISTER_PASS")

return PLUGIN_HANDLED

}

 

new_pass[id] = typedpass

remove_task(id+TASK_MENU)

ConfirmPassword(id)

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Register function

================================================================================*/

 

/*==============================================================================

Start of Change Password function

================================================================================*/

public ChangePasswordNew(id)

{

if(!get_pcvar_num(g_on) || !is_registered[id] || !is_logged[id] || changing_name[id] || !data_ready)

return PLUGIN_HANDLED

 

if(cant_change_pass[id])

{

client_printcolor(id, "%L", LANG_SERVER, "CHANGE_TIMES", prefix, get_pcvar_num(g_chp_time))

return PLUGIN_HANDLED

}

 

read_args(typedpass, charsmax(typedpass))

remove_quotes(typedpass)

 

new passlenght = strlen(typedpass)

 

if(equal(typedpass, ""))

return PLUGIN_HANDLED

 

if(passlenght < get_pcvar_num(g_pass_length))

{

client_printcolor(id, "%L", LANG_SERVER, "REG_LEN", prefix, get_pcvar_num(g_pass_length))

client_cmd(id, "messagemode CHANGE_PASS_NEW")

return PLUGIN_HANDLED

}

 

new_pass[id] = typedpass

client_cmd(id, "messagemode CHANGE_PASS_OLD")

return PLUGIN_CONTINUE

}

 

public ChangePasswordOld(id)

{

if(!get_pcvar_num(g_on) || !is_registered[id] || !is_logged[id] || changing_name[id] || !data_ready)

return PLUGIN_HANDLED

 

if(cant_change_pass[id])

{

client_printcolor(id, "%L", LANG_SERVER, "CHANGE_TIMES", prefix, get_pcvar_num(g_chp_time))

return PLUGIN_HANDLED

}

 

read_args(typedpass, charsmax(typedpass))

remove_quotes(typedpass)

 

if(equal(typedpass, "") || equal(new_pass[id], ""))

return PLUGIN_HANDLED

 

hash = convert_password(typedpass)

 

if(!equali(hash, password[id]))

{

TrieSetCell(g_login_times, g_client_data[id], ++attempts[id])

client_printcolor(id, "%L", LANG_SERVER, "LOG_PASS_INVALID", prefix, attempts[id], get_pcvar_num(g_attempts))

 

if(attempts[id] >= get_pcvar_num(g_attempts))

{

if(get_pcvar_num(g_count))

{

g_player_time[id] = 0

ShowTimer(id+TASK_TIMER)

}

 

if(get_pcvar_num(g_time))

{

TrieSetCell(g_cant_login_time, g_client_data[id], time())

}

else

{

TrieSetCell(g_cant_login_time, g_client_data[id], 0)

}

params[0] = id

params[1] = 3

set_task(2.0, "KickPlayer", id+TASK_KICK, params, sizeof params)

 

if(get_pcvar_num(g_time))

{

set_task(get_pcvar_float(g_time), "RemoveCantLogin", 0, g_client_data[id], sizeof g_client_data)

}

return PLUGIN_HANDLED

}

else

{

client_cmd(id, "messagemode CHANGE_PASS_OLD")

}

return PLUGIN_HANDLED

}

 

ConfirmPassword(id)

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Change Password function

================================================================================*/

 

/*==============================================================================

Start of Confirming Register's or Change Password's password function

================================================================================*/

public ConfirmPassword(id)

{

if(!get_pcvar_num(g_on) || !is_user_connected(id))

return PLUGIN_HANDLED

 

length = 0

 

formatex(menu, charsmax(menu) - length, "%L", LANG_SERVER, "MENU_PASS", new_pass[id])

keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_0

 

show_menu(id, keys, menu, -1, "Password Menu")

return PLUGIN_CONTINUE

}

 

public HandlerConfirmPasswordMenu(id, key)

{

switch(key)

{

case 0:

{

hash = convert_password(new_pass[id])

new name[32];

get_user_name(id, name, charsmax(name))

 

if(is_registered[id])

{

if(get_pcvar_num(g_save))

{

formatex(text, charsmax(text), "UPDATE `registersystem` SET Password = ^"%s^", Status = ^"%s^" WHERE Name = ^"%s^";", hash, is_autolog[id] == true ? "LOGGED_IN" : "LOGGED_OUT", name)

SQL_ThreadQuery(g_sqltuple, "QuerySetData", text)

}

else

{

line = 0, length = 0;

 

while(read_file(reg_file, line++ , text, charsmax(text), length))

{

parse(text, text, charsmax(text))

 

if(!(equal(text, name)))

continue

 

formatex(text, charsmax(text), "^"%s^" ^"%s^" ^"%s^"", name, hash, is_autolog[id] == true ? "LOGGED_IN" : "LOGGED_OUT")

write_file(reg_file, text, line - 1)

 

break

}

}

 

password[id] = hash

TrieSetCell(g_pass_change_times, g_client_data[id], ++times[id])

client_printcolor(id, "%L", LANG_SERVER, "CHANGE_NEW", prefix, new_pass[id])

 

if(is_autolog[id])

{

get_pcvar_string(g_setinfo_pr, pass_prefix, charsmax(pass_prefix))

client_cmd(id, "setinfo %s %s", pass_prefix, new_pass[id])

}

 

if(times[id] >= get_pcvar_num(g_chp_time))

{

cant_change_pass[id] = true

 

if(get_pcvar_num(g_time_pass))

{

TrieSetCell(g_cant_change_pass_time, g_client_data[id], time())

}

else

{

TrieSetCell(g_cant_change_pass_time, g_client_data[id], 0)

}

 

if(get_pcvar_num(g_time_pass))

{

set_task(get_pcvar_float(g_time), "RemoveCantChangePass", 0, g_client_data[id], sizeof g_client_data)

}

}

 

if(get_pcvar_num(g_chp_log))

{

log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_CHNG_PASS", name)

}

 

MainMenu(id)

}

else

{

if(get_pcvar_num(g_save))

{

formatex(text, charsmax(text), "INSERT INTO `registersystem` (`Name`, `Password`, `Status`) VALUES (^"%s^", ^"%s^", ^"LOGGED_OUT^");", name, hash)

SQL_ThreadQuery(g_sqltuple, "QuerySetData", text)

}

else

{

new file_pointer = fopen(reg_file, "a")

format(text, charsmax(text), "^n^"%s^" ^"%s^" ^"^"", name, hash)

fprintf(file_pointer, text)

fclose(file_pointer)

}

 

is_registered[id] = true

password[id] = hash

new_pass[id] = ""

 

if(get_pcvar_num(g_reg_log))

{

log_to_file(log_file, "%L", LANG_SERVER, "LOGFILE_REG", name)

}

 

if(is_user_connected(id))

{

user_silentkill(id)

cs_set_user_team(id, CS_TEAM_UNASSIGNED)

ShowMsg(id)

}

}

}

case 1:

{

if(is_registered[id])

{

client_cmd(id, "messagemode CHANGE_PASS_NEW")

}

else

{

client_cmd(id, "messagemode REGISTER_PASS")

CreateMainMenuTask(id+TASK_MENU)

}

}

case 9:

{

MainMenu(id)

CreateMainMenuTask(id+TASK_MENU)

return PLUGIN_HANDLED

}

}

return PLUGIN_HANDLED

}

 

public QuerySetData(FailState, Handle:Query, error[],errcode, data[], datasize)

{

if(FailState == TQUERY_CONNECT_FAILED || FailState == TQUERY_QUERY_FAILED)

{

log_amx("%s", error)

return

}

}

/*==============================================================================

End of Confirming Register's or Change Password's password function

================================================================================*/

 

/*==============================================================================

Start of Jointeam menus and commands functions

================================================================================*/

public HookTeamCommands(id)

{

if(!get_pcvar_num(g_on) || !is_user_connected(id))

return PLUGIN_CONTINUE

 

if(!data_ready)

return PLUGIN_HANDLED

 

if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))

{

MainMenu(id)

return PLUGIN_HANDLED

}

else if(get_pcvar_num(g_ajc_change) && cs_get_user_team(id) != CS_TEAM_UNASSIGNED && (!get_pcvar_num(g_ajc_admin) || !(get_user_flags(id) & AJC_ADMIN_FLAG)))

{

return PLUGIN_HANDLED

}

return PLUGIN_CONTINUE

}

 

public TextMenu(msgid, dest, id)

{

if(!get_pcvar_num(g_on) || !is_user_connected(id))

return PLUGIN_CONTINUE

 

if(!data_ready)

return PLUGIN_HANDLED

 

new menu_text[64];

 

get_msg_arg_string(4, menu_text, charsmax(menu_text))

 

if(equal(menu_text, JOIN_TEAM_MENU_FIRST) || equal(menu_text, JOIN_TEAM_MENU_FIRST_SPEC))

{

if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))

{

MainMenu(id)

return PLUGIN_HANDLED

}

else if((get_pcvar_num(g_ajc_team) && cs_get_user_team(id) == CS_TEAM_UNASSIGNED) && !task_exists(TASK_AJC) && (!get_pcvar_num(g_ajc_admin) || !(get_user_flags(id) & AJC_ADMIN_FLAG)))

{

SetAutoJoinTask(id, msgid)

return PLUGIN_HANDLED

}

}

else if(equal(menu_text, JOIN_TEAM_MENU_INGAME) || equal(menu_text, JOIN_TEAM_MENU_INGAME_SPEC))

{

if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))

{

MainMenu(id)

return PLUGIN_HANDLED

}

else if(get_pcvar_num(g_ajc_change) && (!get_pcvar_num(g_ajc_admin) || !(get_user_flags(id) & AJC_ADMIN_FLAG)))

{

return PLUGIN_HANDLED

}

}

return PLUGIN_CONTINUE

}

 

public VGUIMenu(msgid, dest, id)

{

if(!get_pcvar_num(g_on) || get_msg_arg_int(1) != JOIN_TEAM_VGUI_MENU || !is_user_connected(id))

return PLUGIN_CONTINUE

 

if(!data_ready)

return PLUGIN_HANDLED

 

if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))

{

MainMenu(id)

return PLUGIN_HANDLED

}

else if(get_pcvar_num(g_ajc_team))

{

if((!get_pcvar_num(g_ajc_admin) || !(get_user_flags(id) & AJC_ADMIN_FLAG)))

{

if(cs_get_user_team(id) == CS_TEAM_UNASSIGNED && !task_exists(TASK_AJC))

{

SetAutoJoinTask(id, msgid)

return PLUGIN_HANDLED

}

else if(get_pcvar_num(g_ajc_change))

{

return PLUGIN_HANDLED

}

}

}

else if(get_pcvar_num(g_ajc_change) && (!get_pcvar_num(g_ajc_admin) || !(get_user_flags(id) & AJC_ADMIN_FLAG)))

{

return PLUGIN_HANDLED

}

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Jointeam menus and commands functions

================================================================================*/

 

/*==============================================================================

Start of Auto Join function

================================================================================*/

public AutoJoin(parameters[])

{

new id = parameters[0]

 

if(!is_user_connected(id))

return PLUGIN_HANDLED

 

if(cs_get_user_team(id) != CS_TEAM_UNASSIGNED)

return PLUGIN_HANDLED

 

new g_team[2], g_team_num = get_pcvar_num(g_ajc_team)

 

if(g_team_num == 6)

{

num_to_str(g_team_num, g_team, charsmax(g_team))

engclient_cmd(id, "jointeam", g_team)

return PLUGIN_CONTINUE

}

 

if(g_team_num == 5)

{

g_team_num = random_num(1, 2)

}

else if(g_team_num != 1 && g_team_num != 2)

return PLUGIN_HANDLED

 

new g_class_num = get_pcvar_num(g_ajc_class[g_team_num - 1])

num_to_str(g_team_num, g_team, charsmax(g_team))

 

if(g_class_num == 5)

{

g_class_num = random_num(1, 4)

}

 

if(g_class_num == 0 || (g_class_num != 1 && g_class_num != 2 && g_class_num != 3 && g_class_num != 4))

{

engclient_cmd(id, "jointeam", g_team)

return PLUGIN_CONTINUE

}

 

new g_class[2], msg_block = get_msg_block(parameters[1])

 

num_to_str(g_class_num, g_class, charsmax(g_class))

 

set_msg_block(parameters[1], BLOCK_SET)

engclient_cmd(id, "jointeam", g_team)

engclient_cmd(id, "joinclass", g_class)

set_msg_block(parameters[1], msg_block)

 

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Auto Join functions

================================================================================*/

 

/*==============================================================================

Start of Hook Client's commands

================================================================================*/

public client_command(id)

{

if(!get_pcvar_num(g_on) || !data_ready)

return PLUGIN_HANDLED

 

new command[64], arg[16];

 

read_argv(0, command, charsmax(command))

read_argv(1, arg, charsmax(arg))

 

if((equali(command, "say") || equali(command, "say_team")) && equali(arg, "/reg"))

{

MainMenu(id)

return PLUGIN_CONTINUE

}

 

if(get_pcvar_num(g_comm))

{

if(TrieKeyExists(g_commands, command))

{

if(!is_registered[id] && get_pcvar_float(g_regtime))

{

console_print(id, "%s %L", prefix, LANG_SERVER, "COMMAND_REG")

client_printcolor(id, "!g%s!t %L", prefix, LANG_SERVER, "COMMAND_REG")

return PLUGIN_HANDLED

}

else if(is_registered[id] && !is_logged[id])

{

console_print(id, "%s %L", prefix, LANG_SERVER, "COMMAND_LOG")

client_printcolor(id, "!g%s!t %L", prefix, LANG_SERVER, "COMMAND_LOG")

return PLUGIN_HANDLED

}

}

}

 

return PLUGIN_CONTINUE

}

 

/*==============================================================================

End of Hook Client's commands

================================================================================*/

 

/*==============================================================================

Start of Info/Help MOTD function

================================================================================*/

public Info(id)

{

show_motd(id, "rshelpmotd.txt", "Register System Help")

}

/*==============================================================================

End of Info/Help MOTD function

================================================================================*/

 

/*==============================================================================

Start of Advret function

================================================================================*/

public ShowAdvert(id)

{

id -= TASK_ADVERT

 

if(!get_pcvar_num(g_on) || !get_pcvar_num(g_advert) || !is_user_connected(id) || is_registered[id])

return PLUGIN_HANDLED

 

client_printcolor(id, "%L", LANG_SERVER, "YOUCANREG_CHAT", prefix)

set_task(get_pcvar_float(g_advert_int), "ShowAdvert", id+TASK_ADVERT)

 

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Advret function

================================================================================*/

 

/*==============================================================================

Start of Player Spawn function

================================================================================*/

public HookPlayerSpawn(id)

{

if(get_pcvar_num(g_on) && is_user_connected(id))

{

show_menu(id, 0, "^n", 1)

}

}

/*==============================================================================

End of Player Spawn function

================================================================================*/

 

/*==============================================================================

Start of Player PreThink function for the blind function

================================================================================*/

public PlayerPreThink(id)

{

if(!get_pcvar_num(g_on) || !get_pcvar_num(g_blind) || !is_user_connected(id) || changing_name[id])

return PLUGIN_HANDLED

 

if((!is_registered[id] && get_pcvar_float(g_regtime)) || (is_registered[id] && !is_logged[id]))

{

message_begin(MSG_ONE_UNRELIABLE, g_screenfade, {0,0,0}, id)

write_short(1<<12)

write_short(1<<12)

write_short(0x0000)

write_byte(0)

write_byte(0)

write_byte(0)

write_byte(255)

message_end()

}

 

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Player PreThink function for the blind function

================================================================================*/

 

/*==============================================================================

Start of Client Info Change function for hooking name change of clients

================================================================================*/

public ClientInfoChanged(id)

{

if(!get_pcvar_num(g_on) || !is_user_connected(id))

return FMRES_IGNORED

 

new oldname[32], newname[32];

 

get_user_name(id, oldname, charsmax(oldname))

get_user_info(id, "name", newname, charsmax(newname))

 

if(!equal(oldname, newname))

{

replace_all(newname, charsmax(newname), "%", " ")

 

changing_name[id] = false

 

if(!is_user_alive(id))

{

changing_name[id] = true

}

else

{

if(is_logged[id])

{

set_user_info(id, "name", oldname)

client_printcolor(id, "%L", LANG_SERVER, "NAME_CHANGE_LOG", prefix)

return FMRES_HANDLED

}

 

set_task(1.0, "CheckClient", id)

}

}

return FMRES_IGNORED

}

/*==============================================================================

End of Client Info Change function for hooking name change of clients

================================================================================*/

 

/*==============================================================================

Start of Kick Player function

================================================================================*/

public KickPlayer(parameters[])

{

new id = parameters[0]

new reason = parameters[1]

 

if(!is_user_connecting(id) && !is_user_connected(id))

return PLUGIN_HANDLED

 

new userid = get_user_userid(id)

 

switch(reason)

{

case 1:

{

if(is_registered[id])

return PLUGIN_HANDLED

 

console_print(id, "%L", LANG_SERVER, "KICK_INFO")

server_cmd("kick #%i ^"%L^"", userid, LANG_PLAYER, "KICK_REG")

}

case 2:

{

if(is_logged[id])

return PLUGIN_HANDLED

 

console_print(id, "%L", LANG_SERVER, "KICK_INFO")

server_cmd("kick #%i ^"%L^"", userid, LANG_PLAYER, "KICK_LOGIN")

}

case 3:

{

if(TrieGetCell(g_cant_login_time, g_client_data[id], value))

{

console_print(id, "%L", LANG_SERVER, "KICK_INFO")

 

if(!value)

{

server_cmd("kick #%i ^"%s^"", userid, LANG_PLAYER, "KICK_ATMP_MAP", get_pcvar_num(g_attempts))

}

else

{

new cal_time = get_pcvar_num(g_time) - (time() - value)

server_cmd("kick #%i ^"%s^"", userid, LANG_PLAYER, "KICK_ATMP_TIME", get_pcvar_num(g_attempts), cal_time)

}

}

}

case 4:

{

console_print(id, "%L", LANG_SERVER, "KICK_INFO")

server_cmd("kick #%i ^"%L^"", userid, LANG_SERVER, "KICK_LOGOUT")

}

}

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Kick Player function

================================================================================*/

 

/*==============================================================================

Start of Removing Punishes function

================================================================================*/

public RemoveCantLogin(data[])

{

TrieDeleteKey(g_login_times, data)

TrieDeleteKey(g_cant_login_time, data)

}

 

public RemoveCantChangePass(data[])

{

TrieDeleteKey(g_cant_change_pass_time, data)

TrieDeleteKey(g_pass_change_times, data)

 

new target;

 

switch(get_pcvar_num(g_member))

{

case 0:

{

target = find_player("a", data)

}

case 1:

{

target = find_player("d", data)

}

case 2:

{

target = find_player("c", data)

}

default:

{

target = find_player("a", data)

}

}

 

if(!target)

return PLUGIN_HANDLED

 

cant_change_pass[target] = false

client_printcolor(target, "%L", LANG_SERVER, "CHANGE_CAN", prefix)

return PLUGIN_CONTINUE

}

/*==============================================================================

End of Removing Punish function

================================================================================*/

 

/*==============================================================================

Start of Plugin's stocks

================================================================================*/

stock client_printcolor(const id, const message[], any:...)

{

new g_message[191];

 

vformat(g_message, charsmax(g_message), message, 3)

 

replace_all(g_message, charsmax(g_message), "!g", "^4")

replace_all(g_message, charsmax(g_message), "!n", "^1")

replace_all(g_message, charsmax(g_message), "!t", "^3")

 

if(is_user_connected(id))

{

message_begin(MSG_ONE_UNRELIABLE, g_saytxt,_, id)

write_byte(id)

write_string(g_message)

message_end()

}

}

 

stock convert_password(const password[])

{

new pass_salt[64], converted_password[34];

 

formatex(pass_salt, charsmax(pass_salt), "%s%s", password, SALT)

md5(pass_salt, converted_password)

 

return converted_password

}

 

stock SetAutoJoinTask(id, menu_msgid)

{

params[0] = id

params[1] = menu_msgid

 

set_task(AJC_TASK_TIME, "AutoJoin", id+TASK_AJC, params, sizeof params)

}

 

stock remove_tasks(const id)

{

remove_task(id+TASK_MESS)

remove_task(id+TASK_KICK)

remove_task(id+TASK_MENU)

remove_task(id+TASK_TIMER)

remove_task(id+TASK_ADVERT)

remove_task(id+TASK_AJC)

remove_task(id)

}

/*==============================================================================

End of Plugin's stocks

================================================================================*/

 

 

 

 

Dou +REP.

bz9v.jpg
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Este tópico está impedido de receber novos posts.
 Compartilhar

×
×
  • Criar Novo...

Informação Importante

Nós fazemos uso de cookies no seu dispositivo para ajudar a tornar este site melhor. Você pode ajustar suas configurações de cookies , caso contrário, vamos supor que você está bem para continuar.