Incorrect Password.
#1

i saw a tutorial and made register login system for my new server all done no warnings and errors are durring compiling..
when i register it workds fine but when i relog and enter pass it says incorrect pass and im 100% sure im entering the correct password.

pawn Код:
#include <a_samp>
#include <sscanf2>
#include <foreach>
#include <YSI\y_ini>

#define COLOR_ERROR 0xFF0000FF

#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define PATH "/Users/%s.ini"

enum pInfo
{
    pPass,
    pRegistered
}
new PlayerInfo[MAX_PLAYERS][pInfo];

forward LoadUser_data(playerid,name[],value[]);
public  LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Registered",PlayerInfo[playerid][pRegistered]);
    return 1;
}

stock UserPath(playerid)
{
    new string[128],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),PATH,name);
    return string;
}

stock udb_hash(buf[])
{
    new length = strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n = 0; n < length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}

main() {}
public OnGameModeInit()
{
    SetGameModeText("Cops And Robbers");
    AddPlayerClass(1, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
       
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Type your password below to login.","Login","Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,"Registering...","Type your password below to register a new account.","Register","Quit");
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
        SavePlayerStats(playerid);
    return 1;
}

stock SavePlayerStats(playerid)
{
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"DATA");
    INI_WriteInt(File,"Registered",PlayerInfo[playerid][pRegistered]);
    INI_Close(File);
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response)
            {
                Kick(playerid);
                return 1;
            }
           
            if (response)
            {
                if(strlen(inputtext) < 6)
                {
                SendClientMessage(playerid, COLOR_ERROR, "Your Password Is Too Short, Enter a Long Password.");
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                return 1;
                }

                if(strlen(inputtext) > 12)
                {
                SendClientMessage(playerid, COLOR_ERROR, "Your Password Is Too Long, Enter a Short Password.");
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
                return 1;
                }

                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"DATA");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Registered",1);
                INI_Close(File);
            }
        }

        case DIALOG_LOGIN:
        {
            if (!response)
            {
            Kick(playerid);
            return 1;
            }
           
            if (response)
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass] && strlen(inputtext) > 0)
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    SendClientMessage(playerid, -1, "You Have Been Succesfully Logged In.");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
Reply


Messages In This Thread
Incorrect Password. - by danish007 - 11.07.2015, 22:40
Re: Incorrect Password. - by SilentSoul - 11.07.2015, 22:45
Re: Incorrect Password. - by danish007 - 11.07.2015, 22:58
Re: Incorrect Password. - by SilentSoul - 11.07.2015, 23:09
Re: Incorrect Password. - by danish007 - 11.07.2015, 23:13
Re: Incorrect Password. - by SilentSoul - 11.07.2015, 23:24
Re: Incorrect Password. - by danish007 - 11.07.2015, 23:31
Re: Incorrect Password. - by Threshold - 11.07.2015, 23:37
Re: Incorrect Password. - by SilentSoul - 11.07.2015, 23:38
Re: Incorrect Password. - by danish007 - 12.07.2015, 13:16

Forum Jump:


Users browsing this thread: 4 Guest(s)