20.11.2013, 09:21
Hello guys.
So, i have the Register system everything works perfect, but when a play joins, and he's registered he needs to enter password. The problem is that the player is registered, but if the password is "123456789" and he enters "wrong", he'll get logged it. So the password don't match, you can any password you want and you're logged in..
pls help
So, i have the Register system everything works perfect, but when a play joins, and he's registered he needs to enter password. The problem is that the player is registered, but if the password is "123456789" and he enters "wrong", he'll get logged it. So the password don't match, you can any password you want and you're logged in..
Код:
#include <a_samp> #include <YSI\y_ini> #define dregister 1 #define dlogin 2 #define UserPath "RokuAdmin/Users/%s.ini" new Text:SM; native WP_Hash(buffer[],len,const str[]); enum PlayerInfo { Pass[129], Adminlevel, VIPlevel, Money, Scores, Kills, Deaths } new pInfo[MAX_PLAYERS][PlayerInfo]; stock Path(playerid) { new str[128],name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name)); format(str,sizeof(str),UserPath,name); return str; } forward loadaccount_user(playerid, name[], value[]); public loadaccount_user(playerid, name[], value[]) { INI_String("Password", pInfo[playerid][Pass],129); INI_Int("AdminLevel",pInfo[playerid][Adminlevel]); INI_Int("VIPLevel",pInfo[playerid][VIPlevel]); INI_Int("Money",pInfo[playerid][Money]); INI_Int("Scores",pInfo[playerid][Scores]); INI_Int("Kills",pInfo[playerid][Kills]); INI_Int("Deaths",pInfo[playerid][Deaths]); return 1; } public OnFilterScriptInit() { SM = TextDrawCreate(490.5 ,392 , "~h~~b~10000+"); TextDrawFont(SM , 3); TextDrawLetterSize(SM , 0.6, 4.2); TextDrawSetOutline(SM , false); TextDrawSetProportional(SM , true); TextDrawSetShadow(SM , 2); print("RokuAdmin Filescript Loaded ..."); return 1; } public OnPlayerConnect(playerid) { new name[MAX_PLAYER_NAME]; GetPlayerName(playerid,name,sizeof(name)); if(fexist(Path(playerid))) { INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"{FEFEFE}Welcome Back %s To {FF5000}X{F5FF00}F{0000FF}S {FEFEFE}!!","{FEFEFE}This {FFD200}Account {FEFEFE}Has Been {B400FF}Registered\n{FEFEFE}Please Enter Your {FF0037}Password {FEFEFE}Below","Login","Quit"); } else { ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"{FEFEFE}Welcome %s To {FF5000}X{F5FF00}F{0000FF}S {FEFEFE}!!","{FEFEFE}This {FFD200}Account {FEFEFE}is Not {B400FF}Registered{FEFEFE} Yet\n{FEFEFE}Please Enter Your {FF0037}Password {FEFEFE}Below","Register","Quit"); GivePlayerMoney(playerid,10000); TextDrawShowForPlayer(playerid, SM); return 1; } return 1; } public OnPlayerDisconnect(playerid, reason) { new INI:file = INI_Open(Path(playerid)); INI_SetTag(file,"Player's Data"); INI_WriteInt(file,"AdminLevel",pInfo[playerid][Adminlevel]); INI_WriteInt(file,"VIPLevel",pInfo[playerid][VIPlevel]); INI_WriteInt(file,"Money",GetPlayerMoney(playerid)); INI_WriteInt(file,"Scores",GetPlayerScore(playerid)); INI_WriteInt(file,"Kills",pInfo[playerid][Kills]); INI_WriteInt(file,"Deaths",pInfo[playerid][Deaths]); INI_Close(file); return 1; } public OnPlayerDeath(playerid, killerid, reason) { pInfo[killerid][Kills]++; pInfo[playerid][Deaths]++; return 1; } stock GetPlayerNameEx(playerid) { new Name[MAX_PLAYER_NAME]; GetPlayerName(playerid, Name, MAX_PLAYER_NAME); return Name; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == dregister) { if(!response) return Kick(playerid); if(response) { if(!strlen(inputtext)) { ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"{FEFEFE}Welcome %s To {FF5000}X{F5FF00}F{0000FF}S {FEFEFE}!!","{FEFEFE}This {FFD200}Account {FEFEFE}is Not {B400FF}Registered{FEFEFE} Yet{FEFEFE}\nPlease Enter Your {FF0037}Password {FEFEFE}Below","Register","Quit"); return 1; } new hashpass[129]; WP_Hash(hashpass,sizeof(hashpass),inputtext); new INI:file = INI_Open(Path(playerid)); INI_SetTag(file,"Player's Data"); INI_WriteString(file,"Password",hashpass); INI_WriteInt(file,"AdminLevel",0); INI_WriteInt(file,"VIPLevel",0); INI_WriteInt(file,"Money",10000); INI_WriteInt(file,"Scores",0); INI_WriteInt(file,"Kills",0); INI_WriteInt(file,"Deaths",0); INI_Close(file); SendClientMessage(playerid,0xFFFF00AA,"You have been successfully registered"); return 1; } } if(dialogid == dlogin) { if(!response) return Kick(playerid); if(response) { new hashpass[129]; WP_Hash(hashpass,sizeof(hashpass),inputtext); if(!strcmp(hashpass, pInfo[playerid][Pass], false)) { INI_ParseFile(Path(playerid),"loadaccount_%s",.bExtra = true, .extra = playerid); SetPlayerScore(playerid,pInfo[playerid][Scores]); GivePlayerMoney(playerid,pInfo[playerid][Money]); SendClientMessage(playerid,0x99FF00AA,"Welcome back ! You have successfully logged in"); } else { ShowPlayerDialog(playerid,dlogin,DIALOG_STYLE_PASSWORD,"{FEFEFE}Welcome Back %s To {FF5000}X{F5FF00}F{0000FF}S {FEFEFE}!!","{FEFEFE}This {FFD200}Account {FEFEFE}Has Been {B400FF}Registered\n{FEFEFE}Please Enter Your {FF0037}Password {FEFEFE}Below","Login","Quit"); } } } return 1; }