Mysql Won't Create Account (R41-2)
#3

OnDialogResponse:
Код:
switch(dialogid)
    {
        case LoginDialog:
        {
            if(!response) Kick(playerid);

            new hashpass[129], query[100];

            WP_Hash(hashpass, sizeof(hashpass), inputtext);
            if(!strcmp(hashpass, PlayerInfo[playerid][Password]))
            {
                mysql_format(mysql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1", Name[playerid]);
                mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
            }
            else
            {
                SendClientMessage(playerid, -1, "You have specified an incorrect password!");
                ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT, "Login", "Welcome player!\nYour account has been found in our database. Please fill in your password:", "Login", "Quit");
            }
        }
        case RegisterDialog:
        {
            if(!response) return Kick(playerid);
            if(strlen(inputtext) < 5)
            {
                SendClientMessage(playerid, -1, "Your password must at least contain more than 4 characters.");
                return ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_INPUT, "Register", "Welcome player!\nYour account has not been registered yet. Please fill in your desired password:", "Register", "Quit");
            }
            new query[512], playerip[16];

            GetPlayerIp(playerid, playerip, sizeof(playerip));
            WP_Hash(PlayerInfo[playerid][Password], 129, inputtext);
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`) VALUES ('%e', '%e', '%e', 0, 0, 0)", Name[playerid], PlayerInfo[playerid][Password], playerip);
            mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
        }
    }
Funtion:

Код:
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
    cache_get_value_name_int(0, "Admin", PlayerInfo[playerid][pAdmin]);
    cache_get_value_name_int(0, "VIP", PlayerInfo[playerid][pVIP]);
    cache_get_value_name_int(0, "Score", PlayerInfo[playerid][Score]);
    cache_get_value_name_int(0, "Money", PlayerInfo[playerid][Money]);


    GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);

    SendClientMessage(playerid, -1, "You have successfully logged in.");
    return true;
}
forward OnAccountRegister(playerid);
public OnAccountRegister(playerid)
{
    PlayerInfo[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered.
    printf("TW Account ID: %d", PlayerInfo[playerid][ID]); //just for debugging.
    return 1;
}
Reply


Messages In This Thread
Mysql Won't Create Account (R41-2) - by DerickClark - 22.01.2017, 01:36
Re: Mysql Won't Create Account (R41-2) - by X337 - 22.01.2017, 02:22
Re: Mysql Won't Create Account (R41-2) - by DerickClark - 22.01.2017, 02:35
Re: Mysql Won't Create Account (R41-2) - by Logic_ - 22.01.2017, 04:18
Re: Mysql Won't Create Account (R41-2) - by DerickClark - 22.01.2017, 04:23
Re: Mysql Won't Create Account (R41-2) - by Logic_ - 22.01.2017, 04:25
Re: Mysql Won't Create Account (R41-2) - by X337 - 22.01.2017, 04:30
Re: Mysql Won't Create Account (R41-2) - by DerickClark - 22.01.2017, 04:31
Re: Mysql Won't Create Account (R41-2) - by Logic_ - 22.01.2017, 04:35
Re: Mysql Won't Create Account (R41-2) - by X337 - 22.01.2017, 04:39

Forum Jump:


Users browsing this thread: 1 Guest(s)