SAMP Server Crash
#1

My SAMP server crashes when I login in to my account and SELECT * from database. Here's the MySQL Login function.
Код:
stock MySQL_Login(playerid)
{
    new query[300], pname[24], savingstring[20];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname);
    mysql_query(query);
    mysql_store_result();
    while(mysql_fetch_row_format(query,"|"))
    {
        mysql_get_field("score", savingstring); SetPlayerScore(playerid, strval(savingstring));
        mysql_get_field("money", savingstring); MoneyGiven[playerid] = strval(savingstring);
    }
    mysql_free_result();
    SendClientMessage(playerid, -1, "You have been logged in!");
    Logged[playerid] = 1;
    return 1;
}
and OnPlayerConnect(playerid)
Код:
public OnPlayerConnect(playerid)
{
    MoneyGiven[playerid] = 0;
    new query[200], pname[24];
    GetPlayerName(playerid, pname, 24);
    format(query, sizeof(query), "SELECT IP FROM `playerdata` WHERE user = '%s' LIMIT 1", pname);
    mysql_query(query);
    mysql_store_result();
    new rows = mysql_num_rows();
    if(rows != 1)
    {
        ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register","Your user is {FF0000}not{FFFFFF} registered! Please {0000FF}register{FFFFFF} with a password below!","Register","Cancel");
    }
    if(rows == 1)
    {
        new IP[2][16];
        mysql_fetch_field_row(IP[0],"IP");
        GetPlayerIp(playerid, IP[1], 16);
        if(strlen(IP[0]) != 0 && !strcmp(IP[0], IP[1], true))
        {
            MySQL_Login(playerid);
        }
        else if(!strlen(IP[0]) || strcmp(IP[0], IP[1], true))
        {
            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login","Your user is {FF0000}registered{FFFFFF}! Please {0000FF}login{FFFFFF} with your password below!","Login","Cancel");
            IsRegistered[playerid] = 1;
        }
    }
    mysql_free_result();
    return 1;
}
If I change * to password it doesn't crash, but it obviously wont load my score or money. But again if I set it to password, money, score it crashes aswell.
Reply
#2

Hi,
Do this thing with selecting fields in OnDialogResponse where is the response for your login dialog also do this into auto login part. And what MySQL vesion you are using? I think is R6 but if you are starting a new project it will be easer for you to use the latest version of this plugin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)