Weird Error
#1

It gives me an error..

pawn Код:
case DIALOG_LOGIN:
        {
            if(response)
            {
                new query[210], pname[24], escapepass[100];//
                GetPlayerName(playerid, pname, 24); //Gets the players name
                mysql_real_escape_string(inputtext, escapepass); //We escape the inputtext to avoid SQL injections.
                format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s' AND password = SHA1('%s')", pname, escapepass);
                mysql_function_query(dbHandle, query, true, "LoadPlayerData", "i", playerid);
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You have chosen to quit Domination Roleplay, please visit us again soon!");
                Kick(playerid);
            }
            return 1;
        }
pawn Код:
forward LoadPlayerData(playerid);
public LoadPlayerData(playerid)
{
    new string[210];
    new rows, fields;
    cache_get_data(rows, fields);

    if(rows)
    {
        new savingstring[20];
        cache_get_field_content(0, "Level",savingstring);SetPlayerScore(playerid, strval(savingstring));
        cache_get_field_content(0, "Money",savingstring);MoneyGiven[playerid] = strval(savingstring);
        cache_get_field_content(0, "PlayerPosX",savingstring);PlayerVar[playerid][pPosX] = floatstr(savingstring);
        cache_get_field_content(0, "PlayerPosY",savingstring);PlayerVar[playerid][pPosY] = floatstr(savingstring);
        cache_get_field_content(0, "PlayerPosZ",savingstring);PlayerVar[playerid][pPosZ] = floatstr(savingstring);
        cache_get_field_content(0, "InteriorID",savingstring); PlayerVar[playerid][InteriorID] = strval(savingstring);
        cache_get_field_content(0, "SkinID",savingstring);PlayerVar[playerid][SkinID] = strval(savingstring);
        SetPlayerHealth(playerid, 100);
        TextDrawHideForPlayer(playerid, WIDESCREEN_TOP);
        TextDrawHideForPlayer(playerid, WIDESCREEN_BOTTOM);
        TextDrawHideForPlayer(playerid, WelcomeTD);
        TogglePlayerSpectating(playerid, 0);
        SetPVarInt(playerid, "prelogin", 0);
        SetPlayerWeapons(playerid);
        SetPlayerWeaponsEx(playerid);
        SendClientMessage(playerid, -1, "You have been logged in!"); //Sends the client a message.
        Logged[playerid] = 1; //Sets our logged in variable to one
        SetPlayerInterior(playerid, PlayerVar[playerid][InteriorID]);
        SetSpawnInfo(playerid, 0, PlayerVar[playerid][SkinID], PlayerVar[playerid][pPosX], PlayerVar[playerid][pPosY], PlayerVar[playerid][pPosZ], 0, 0, 0, 0, 0, 0, 0);
        SpawnPlayer(playerid);
    }
    else
    {
        //This means that the password that the player
        //typed was incorrect and we will resend the dialog.
        format(string, sizeof(string), "Welcome back, %s. Please enter your password below to log in.", GetName(playerid));
        ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login", string, "Confirm", "Quit");
        SendClientMessage(playerid, COLOR_LIGHTRED, "Error{FFFFFF}: You have entered an incorrect password."); //Sends the client a error message
    }
    return 1;
}
Error:

pawn Код:
C:\Documents and Settings\Aphex\Desktop\DRP\gamemodes\dominationrp.pwn(9706) : error 017: undefined symbol "dbHandle"
Reply
#2

new dbHandle; - Global var
dbHandle = mysql_connect(...) - In OnGamemodeInt
Reply
#3

Hmm, I was thinking this but I have:

pawn Код:
#define mysql_host "127.0.0.1" //Has to be a string
    #define mysql_user "<removed>" //Has to be a string
    #define mysql_password "<removed>" //There is none for wamp unless you set one.
    #define mysql_database "<removed>" //Has to be a string
This is what I use to connect to the database. I understand how the cacheing works now, just not the dbHandle part of it.
Reply
#4

Ah sorry, I get you, thanks!
Reply
#5

dbHandle = mysql_connect("127.0.0.1","root","sa-mp",""); - put it into OnGamemodeInt() callback.
Reply
#6

+rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)