Raised This Month: $ Target: $400
 0% 

Help with login/register system


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hzqst
Senior Member
Join Date: Jul 2008
Old 08-31-2009 , 07:31   Help with login/register system
Reply With Quote #1

I use :
PHP Code:
public clcmd_login_name(id){
 static 
arg[48]
 
read_args(argsizeof arg)
 
replace_all(argsizeof arg 1"login_name """)
 
replace_all(argsizeof arg 1"^"", "")
 copy(g_login_name[id], sizeof g_login_name[] - 1, arg)
 show_menu_login(id)
 return PLUGIN_HANDLED;
}
public clcmd_login_password(id){
 static arg[48]
 read_args(arg, sizeof arg)
 replace_all(arg, sizeof arg - 1, "
login_pw ", "")
 replace_all(arg, sizeof arg - 1, "
^"""")
 
copy(g_login_password[id], sizeof g_login_password[] - 1arg)
 
show_menu_login(id)
 return 
PLUGIN_HANDLED;
}
public 
clcmd_login(id){
 if(
g_login[id]){
  
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_LOGIN_LOGINED")
  return 
PLUGIN_HANDLED;
 }
 if(
containg_login_name[id], " ") != -1){
  
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_LOGIN_UNABLE")
  return 
PLUGIN_HANDLED;
 }
 if(
containg_login_password[id], " ") != -1){
  
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_LOGIN_UNABLE")
  return 
PLUGIN_HANDLED;
 }
 
 static 
key[32], data[64]
 
format(keysizeof key 1"[Data_%s]"g_login_name[id]);
 new 
valid nvault_get(g_Nvaultkeydatasizeof data 1);
 if(!
valid){
  
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_LOGIN_NOEXIST")
  return 
PLUGIN_HANDLED;
 }
 static 
pw[32], startpos
 startpos 
contain(data"#")
        
format(pwstartpos"%s"data);
 if(!
equal(g_login_password[id], pw)){
  
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_LOGIN_PWERROR")
  return 
PLUGIN_HANDLED;
 }
 
 
g_login[id] = 1
 copy
(g_username[id], sizeof g_username[] - 1g_login_name[id])
 
copy(g_password[id], sizeof g_password[] - 1g_login_password[id])
 
replace(datasizeof data 1"pw#""")
 
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_LOGIN_SUCCESS"g_login_name[id])
 
format(g_login_name[id], sizeof g_login_name[] - 1" ")
 
format(g_login_password[id], sizeof g_login_password[] - 1" ")
 return 
PLUGIN_HANDLED;

and

PHP Code:
 register_clcmd("login_name""clcmd_login_name")
 
register_clcmd("login_pw""clcmd_login_password")
 
register_clcmd("login_user""clcmd_login"
to login in

then
PHP Code:
public clcmd_register_name(id){
 static 
arg[48]
 
read_args(argsizeof arg)
 
replace_all(argsizeof arg 1"reg_name """)
 
replace_all(argsizeof arg 1"^"", "")
 copy(g_reg_name[id], sizeof g_reg_name[] - 1, arg)
 show_menu_register(id)
 return PLUGIN_HANDLED;
}
public clcmd_register_password(id){
 static arg[48]
 read_args(arg, sizeof arg)
 replace_all(arg, sizeof arg - 1, "
reg_pw ", "")
 replace_all(arg, sizeof arg - 1, "
^"""")
 
copy(g_reg_password[id], sizeof g_reg_password[] - 1arg)
 
show_menu_register(id)
 return 
PLUGIN_HANDLED;
}
public 
clcmd_register(id){
 if(
containg_reg_name[id], " ") != -1){
  
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_REG_UNABLE")
  return 
PLUGIN_HANDLED;
 }
 if(
containg_reg_password[id], " ") != -1){
  
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_REG_UNABLE")
  return 
PLUGIN_HANDLED;
 }
 static 
key[32], data[32]
 
format(keysizeof key 1"[Data_%s]"g_reg_name[id])
 new 
valid nvault_get(g_Nvaultkeydatasizeof data 1);
 if(
valid){
  
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_REG_REGISTERED")
  return 
PLUGIN_HANDLED;
 }
 static 
lenvaultkey[32], vaultdata[128]
 
format(vaultkeysizeof vaultkey 1"[Data_%s]"g_reg_name[id])
 
len += formatex(vaultdatasizeof vaultdata len 1"%s"g_reg_password[id])
 
nvault_set(g_Nvaultvaultkeyvaultdata)
 
client_print_colored(id"^x04%L^x01%L"LANG_PLAYER"MSG_TITLE"id"MSG_REG_SUCCESS"g_reg_name[id])
 
format(g_reg_name[id], sizeof g_reg_name[] - 1" ")
 
format(g_reg_password[id], sizeof g_reg_password[] - 1" ")
 return 
PLUGIN_HANDLED;

and

PHP Code:
 register_clcmd("reg_name""clcmd_register_name")
 
register_clcmd("reg_pw""clcmd_register_password")
 
register_clcmd("reg_user""clcmd_register"
to register accounts

When I use a valid username and password to login in, the server may crashs

I think the register system works fine because I found nothing wrong in Vault file:
Quote:
TLVn  枦J 8 [Data_hzqst]nmqs7456m暃J8 [Data_]nmqs7456

Last edited by hzqst; 08-31-2009 at 07:34.
hzqst is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:02.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode