Ok im usinng the y_ini saving system but for some reason i can login with any password:
pawn Код:
native WP_Hash(buffer[],len,const str[]);
enum iDetails {
pPass,
pCash,
pScore,
pAdmin,
pBanned,
pKicked,
pMuted,
pWarned,
pCaged,
pFrozen,
pJailed,
pDeaths,
pKills,
pSkin,
pVIP,
};
new pInfo[MAX_PLAYERS][iDetails];
#if defined AUTOLOGIN
new pIP[MAX_PLAYERS][16];
#endif
new pLogged[MAX_PLAYERS];
public UserDataLoad_data(playerid,name[],value[]) {
INI_Int("Pass",pInfo[playerid][pPass]);
#if defined AUTOLOGIN
INI_String("IP",pIP[playerid],16);
#endif
INI_Int("Cash",pInfo[playerid][pCash]);
INI_Int("Score",pInfo[playerid][pScore]);
INI_Int("Admin",pInfo[playerid][pAdmin]);
INI_Int("Banned",pInfo[playerid][pBanned]);
INI_Int("Kicked",pInfo[playerid][pKicked]);
INI_Int("Muted",pInfo[playerid][pMuted]);
INI_Int("Caged",pInfo[playerid][pCaged]);
INI_Int("Warned",pInfo[playerid][pWarned]);
INI_Int("Frozen",pInfo[playerid][pFrozen]);
INI_Int("Jailed",pInfo[playerid][pJailed]);
INI_Int("Deaths",pInfo[playerid][pDeaths]);
INI_Int("Kills",pInfo[playerid][pKills]);
INI_Int("Skin",pInfo[playerid][pSkin]);
return 1;
}
public OnPlayerConnect(playerid)
{
new pname[MAX_PLAYER_NAME], string[500 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
if(pInfo[playerid][pAdmin] >= 0)
format(string, sizeof(string), "* %s (%i) Has Joined The Server.", pname, playerid);
SendClientMessageToAll(COLOR_GREY, string);
pLogged[playerid] = 0;
#if defined AUTOLOGIN
new tmpIP[16];
GetPlayerIp(playerid,tmpIP,sizeof(tmpIP));
#endif
if(fexist(PlayerPath(playerid))) {
INI_ParseFile(PlayerPath(playerid), "UserDataLoad_%s", .bExtra = true, .extra = playerid);
#if defined AUTOLOGIN
if(strcmp(tmpIP,pIP[playerid],true) == 0) {
pLogged[playerid] = 1;
SetPlayerScore(playerid,pInfo[playerid][pScore]);
GivePlayerMoney(playerid,pInfo[playerid][pCash]);
SendClientMessage(playerid,-1,"[IP]Login {6EF83C}Successful.{FFFFFF}You've Been {6EF83C}Automatically {FFFFFF}Logged-In.");
return 1;
}
#endif
format(string, sizeof(string),"{FFFFFF}Welcome back {0049FF}{6EF83C}%s\n{FFFFFF}Please type your {6EF83C}password {FFFFFF}bellow to login!",pname);
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Please Login",string,"Login","Quit");
} else {
format(string, sizeof(string),"{FFFFFF}Welcome {0049FF} {6EF83C}%s\n{FFFFFF}Please type a {6EF83C}password {FFFFFF}bellow to register a new account!",pname);
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Please Register",string,"Register","Quit");
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(pLogged[playerid] == 1) {
new iStr[300], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
new INI:iFile = INI_Open(PlayerPath(playerid));
format(iStr, sizeof(iStr),"%s's Data", pName);
INI_SetTag(iFile,iStr);
INI_WriteInt(iFile,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(iFile,"Score",GetPlayerScore(playerid));
INI_WriteInt(iFile,"Skin",GetPlayerSkin(playerid));
INI_WriteInt(iFile,"Kills",pInfo[playerid][pKills]);
INI_WriteInt(iFile,"Deaths",pInfo[playerid][pDeaths]);
INI_WriteInt(iFile,"Admin",pInfo[playerid][pAdmin]);
INI_WriteInt(iFile,"Warned",pInfo[playerid][pWarned]);
INI_WriteInt(iFile,"Muted",pInfo[playerid][pMuted]);
INI_WriteInt(iFile,"Jailed",pInfo[playerid][pJailed]);
INI_WriteInt(iFile,"Frozen",pInfo[playerid][pFrozen]);
INI_WriteInt(iFile,"Caged",pInfo[playerid][pCaged]);
INI_WriteInt(iFile,"Banned",pInfo[playerid][pBanned]);
INI_WriteInt(iFile,"Kicked",pInfo[playerid][pKicked]);
INI_Close(iFile);
}
pLogged[playerid] = 0;
new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
switch(reason)
{
case 0: format(string, sizeof(string), "* %s (%i) has left the server.(Lost Connection)", pname, playerid);
case 1: format(string, sizeof(string), "* %s (%i) has left the server.(Quit)", pname, playerid);
case 2: format(string, sizeof(string), "* %s (%i) has left the server.(Kicked/Banned)", pname, playerid);
}
SendClientMessageToAll(COLOR_GREY, string);
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_REGISTER) {
GetPlayerIp(playerid,pIP[playerid],16);
new iStr[500],pName[MAX_PLAYER_NAME],hashpass[129];
GetPlayerName(playerid,pName,sizeof(pName));
if(!response) Kick(playerid);
format(iStr, sizeof(iStr),"{FFFFFF}Welcome{6EF83C}%s\n{FFFFFF}Please type a {6EF83C}password {FFFFFF}bellow to register a new account!",pName);
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Please Register",iStr,"Register","Quit");
if(!strlen(inputtext))return 1;
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:iFile = INI_Open(PlayerPath(playerid));
format(iStr, sizeof(iStr),"%s's Data", pName);
INI_SetTag(iFile,iStr);
INI_WriteString(iFile,"Pass",hashpass);
#if defined AUTOLOGIN
INI_WriteString(iFile,"IP",pIP[playerid]);
#endif
INI_WriteInt(iFile,"Cash",5000);
INI_WriteInt(iFile,"Score",0);
INI_WriteInt(iFile,"Admin",0);
INI_WriteInt(iFile,"Banned",0);
INI_WriteInt(iFile,"Kicked",0);
INI_WriteInt(iFile,"Muted",0);
INI_WriteInt(iFile,"Warned",0);
INI_WriteInt(iFile,"Frozen",0);
INI_WriteInt(iFile,"Jailed",0);
INI_WriteInt(iFile,"Deaths",0);
INI_WriteInt(iFile,"Kills",0);
INI_WriteInt(iFile,"Skin",0);
INI_Close(iFile);
pLogged[playerid] = 1;
format(iStr,sizeof(iStr),"{FFFFFF}You've {6EF83C}Successfully {FFFFFF}Registered!\n{FFFFFF}Your Typed Password: {6EF83C}%s",inputtext);
ShowPlayerDialog(playerid,DIALOG_SUCCESS,DIALOG_STYLE_MSGBOX,"Register Success",iStr,"OK","");
}
if(dialogid == DIALOG_LOGIN) {
if(!response) Kick(playerid);
new iStr[300],pName[MAX_PLAYER_NAME],hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
SetPVarInt(playerid,"passfails",GetPVarInt(playerid,"passfails")+1);
if(GetPVarInt(playerid,"passfails") == 3) {
GetPlayerName(playerid,pName,sizeof(pName));
format(iStr,sizeof(iStr),"*** SERVER KICK: %s (%i) - Failed Login!",pName, playerid);
SendClientMessageToAll(red,iStr);
return Kick(playerid);
}
if(!strlen(inputtext)) {
return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",iStr,"Login","Quit");
}
if(!strcmp(hashpass,pInfo[playerid][pPass])){
pLogged[playerid] = 1;
SendClientMessage(playerid,-1,"{FFFFFF}You've {6EF83C}Successfuly {FFFFFF}Logged-In.");
SetPlayerScore(playerid,pInfo[playerid][pScore]);
GivePlayerMoney(playerid,pInfo[playerid][pCash]);
SetPlayerSkin(playerid,pInfo[playerid][pSkin]);
} else {
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","You've typed an incorrect password.\nWARNING: If you type a wrong password\nTHREE TIMES you will be kicked! Try Again:","Login","Quit");
return 1;
}
return 1;
}
return 1;
}