REGISTER SYS'
#1

Hey all, i want to make a simple register sys', here the code
Код:
//Credits to ******, Dracoblue and Kush.

#include <a_samp>
#include <YSI\y_ini>

#define PATH "/Users/%s.ini"

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

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

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

main()
{
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}
i want to add to here a dialogs when i register/login, and is good the code?!
Reply
#2

OnPlayerConnect

pawn Код:
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
Edit the colors to your defines etc

OnDialogResponse

pawn Код:
switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok","");
            }
        }

        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Again edit to your needs, More needed to do but you've probably already scripted it from what i see
Reply
#3

BUT, The password hashed!!!, i dont want it hashed!
How to unhash it
Reply
#4

A registration system for a good server should always use hashed password for secure. Otherwise, they can steal the passwords and that's really bad!
Here's a good tutorial about how to use y_ini with dialogs for register/login. However, it uses Whirlpool (that I personally recomment to you!). In case you don't want to use it, just replace hashpass with inputtext, and don't use this native.
pawn Код:
native WP_Hash(buffer[],len,const str[]);
Reply
#5

Quote:
Originally Posted by Bug.
Посмотреть сообщение
BUT, The password hashed!!!, i dont want it hashed!
How to unhash it
According to the code provided by LZ, you don't need to unhash the password.
Reply
#6

Quote:
Originally Posted by deb014
Посмотреть сообщение
According to the code provided by LZ, you don't need to unhash the password.
Its just an extract from my script, I didn't give you the native but tbh i think if you just don't add the native it won't hash anyway.
Reply
#7

Quote:
Originally Posted by Lz
Посмотреть сообщение
Its just an extract from my script, I didn't give you the native but tbh i think if you just don't add the native it won't hash anyway.
That's true, udb_hash(params[]) isn't a native function, in this way, if you try to compile without the include which defines this function, the IDE will throw an error.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)