Password Error ??
#1

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..

Код:
#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;
}
pls help
Reply
#2

Hmm. do u have the latest includes and Whirlpool and Sscanf plugin in ur plugins folder and server.cfg?
Reply
#3

Quote:
Originally Posted by TahaAsif12
Посмотреть сообщение
Hmm. do u have the latest includes and Whirlpool and Sscanf plugin in ur plugins folder and server.cfg?
I Dont know I'll check em

EDIT : Yes, I already check em , its the lastest version . But it still wont work
Reply
#4

Are you actually sure that it loads the password to pInfo[playerid][Pass]?

If it doesn't load the password to that variable and you check with strcmp if the passwords do match, it'll return 0 (that they indeed do match) when one of them is NULL.

So, debug it to be sure:
pawn Код:
printf("hashpass: \"%s\" & pInfo[playerid][Pass]: \"%s\"", hashpass, pInfo[playerid][Pass]);
if(!strcmp(hashpass, pInfo[playerid][Pass], false))
Try to login again, what does it print?
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Are you actually sure that it loads the password to pInfo[playerid][Pass]?

If it doesn't load the password to that variable and you check with strcmp if the passwords do match, it'll return 0 (that they indeed do match) when one of them is NULL.

So, debug it to be sure:
pawn Код:
printf("hashpass: \"%s\" & pInfo[playerid][Pass]: \"%s\"", hashpass, pInfo[playerid][Pass]);
if(!strcmp(hashpass, pInfo[playerid][Pass], false))
Try to login again, what does it print?
Its Print This :

Код:
[19:00:24] Incoming connection: 25.98.199.236:62308
[19:00:24] [join] The_First has joined the server (0:25.98.199.236)
[19:00:29] hashpass: "9CE0B1A1D51019A53805DA0689A596A317511CF9642DE90A312267D8E91779AF3D20E7D596ACF185FB66839048DB7DB11639C99545A6168A2E447C3EA8F310D5" & pInfo[playerid][Pass]: ""
Reply
#6

pawn Код:
pInfo[playerid][Pass]: ""
It is NULL.

Well, I think that loadaccount_user is not called at all but I don't know why. Try following a tutorial about y_ini again: https://sampforum.blast.hk/showthread.php?tid=376424
Reply
#7

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
pInfo[playerid][Pass]: ""
It is NULL.

Well, I think that loadaccount_user is not called at all but I don't know why. Try following a tutorial about y_ini again: https://sampforum.blast.hk/showthread.php?tid=376424
I Already follow all what tutorial say

but it doesnt work


EDIT : It works now thanks, i just need to delete the old %s.ini
Reply
#8

At OnPlayerConnect, check your Register Dialog, change "dlogin" to "dregister", because at Login Dialog, they already have "dlogin", and why you need put "dlogin" at Register Dialog....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)