Errors at MYSQL Register Script
#1

Hey everyone I recenty followed a tutorial about MYSQL Register/Login Script. I still have two problems. First of all I don't get Whirlpool installed and second I got errors in the script.

Here are my PAWNO errors


And this is my script:
Код:
#include <a_samp>
#include <a_mysql>
//==============================================================================
//Password Hashing
native WP_Hash(buffer[], len, const str[]);
//==============================================================================
#define MYSQL_DATABASE "test"
#define MYSQL_HOST "127.0.0.1"
#define MYSQL_USER "u353225498"
#define MYSQL_PASSWORD ""
//==============================================================================
new mysql;
//==============================================================================
stock GetName(playerid)
{
    new Name[MAX_PLAYER_NAME];
    if(IsPlayerConnected(playerid))
    {
		GetPlayerName(playerid, Name, sizeof(Name));
    	strreplace(Name, '_', ' ');
	}
	return Name;
}
//==============================================================================
enum
{
    LoginDialog,
    RegisterDialog
};

enum PlayerData
{
    ID,
    Name[MAX_PLAYER_NAME],
    Password[129],
    IP[16],
    Admin,
    VIP,
    Money,
    Float:PosX,
    Float:PosY,
    Float:PosZ,
    Float:PosA
};
new Player[MAX_PLAYERS][PlayerData];
//==============================================================================
main()
{
	print("\n----------------------------------");
	print(" SA:WR Roleplay Scripted by Daniel");
	print(" Version 1.0.0");
	print("----------------------------------\n");
}
//==============================================================================
public OnGameModeInit()
{
    mysql_log(LOG_ALL);
    mysql = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DATABASE, MYSQL_PASSWORD);
    if(mysql_errno() != 0)
    {
        printf("[MySQL] The connection has failed.");
    }
    else
    {
        printf("[MySQL] The connection was successful.");
    }
    return true;
}
//==============================================================================
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)
{
    new
        query[128],
        playername[MAX_PLAYER_NAME];

    GetPlayerName(playerid, playername, sizeof(playername));
    mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername);
    mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
    return true;
}
//==============================================================================
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
    new
        rows,
        fields;
    cache_get_data(rows, fields, mysql);

    if(rows)
    {
        cache_get_field_content(0, "Password", Player[playerid][Password], 1, 129);
        Player[playerid][ID] = cache_get_field_content_int(0, "ID");
        ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_INPUT, "Login", "Welcome player!\nYour account has been found in our database. Please fill in your password:", "Login", "Quit");
    }
    else
    {
        ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_INPUT, "Register", "Welcome player!\nYour account has not been registered yet. Please fill in your desired password:", "Register", "Quit");
    }
    return true;
}
//==============================================================================
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
	Player[playerid][Admin] = cache_get_field_content_int(0, "Admin");
	Player[playerid][VIP] = cache_get_field_content_int(0, "VIP");
	Player[playerid][Money] = cache_get_field_content_int(0, "Money");
	Player[playerid][posX] = cache_get_field_content_float(0, "PosX");
	Player[playerid][posY] = cache_get_field_content_float(0, "PosY");
	Player[playerid][posZ] = cache_get_field_content_float(0, "PosZ");
	Player[playerid][posA] = cache_get_field_content_float(0, "PosA");

	GivePlayerMoney(playerid, Player[playerid][Money]);
	SendClientMessage(playerid, -1, "You have successfully logged in.");
    return true;
}
//==============================================================================
forward OnAccountRegister(playerid);
public OnAccountRegister(playerid)
{
    Player[playerid][ID] = cache_insert_id();
    printf("[Registration] New account registered. Database ID: [%d]", Player[playerid][ID]);
    return true;
}
//==============================================================================
public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, Player[playerid][PosX], Player[playerid][PosY], Player[playerid][PosZ]);
    SetPlayerFacingAngle(playerid, Player[playerid][PosA]);
    return true;
}
//==============================================================================
public OnPlayerDisconnect(playerid, reason)
{
    new
        query[128],
        Float:pos[4];

    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);

    mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `Money` = %d, `PosX` = %f, `PosY` = %f, `PosZ` = %f, `PosA` = %f WHERE `ID` = %d",
    GetPlayerMoney(playerid), pos[0], pos[1], pos[2], pos[3], Player[playerid][ID]);
    mysql_tquery(mysql, query, "", "");

    return true;
}
//==============================================================================
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case LoginDialog:
        {
            if(!response) Kick(playerid);

            new
                hashpass[129],
                query[100],
                playername[MAX_PLAYER_NAME];

            GetPlayerName(playerid, playername, sizeof(playername));
            WP_Hash(hashpass, sizeof(hashpass), inputtext);
            if(!strcmp(hashpass, Player[playerid][Password]))
            {
                mysql_format(mysql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername);
                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],
                playername[MAX_PLAYER_NAME],
                playerip[16];


            GetPlayerName(playerid, playername, sizeof(playername));
            GetPlayerIp(playerid, playerip, sizeof(playerip));
            WP_Hash(Player[playerid][Password], 129, inputtext);
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`) VALUES ('%e', '%e', '%e', 0, 0, 0, 0.0, 0.0, 0.0, 0.0)", playername, Player[playerid][Password], playerip);
            mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
        }
    }
    return false;
}
//==============================================================================
Further I just installed the original Whirlpool plugin and putted it in the plugins folder. At the server.config I put in the line "plugins Whirlpool". Please help me!
Reply
#2

Your enum has PosX while your loading function has posX.
Reply
#3

Thanks bro looked over it.
Reply
#4

Got another problem now.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)