What's wrong with this function (Crashed server)? [Rep++]
#1

I've been using this function for a while but only recently it started crashing the server. The debug information printed by the crashdetect plugin goes as followed:

Код:
[16:49:30] [debug] The server has crashed executing 'SP.amx'
[16:49:30] [debug] [SP.amx]: Call stack (most recent call first):
[16:49:30] [debug] [SP.amx]:   File '../gamemodes/SP.pwn', line 1513
[16:49:30] [debug] [SP.amx]:     RegisterPlayer(playerid=4, password[]=@0x69abc)
[16:49:30] [debug] [SP.amx]:   File '../gamemodes/SP.pwn'
[16:49:30] [debug] [SP.amx]:     public OnDialogResponse(playerid=4, dialogid=432828, response=0, listitem=0, inputtext[]=@0x14)
The error occurs on this block of code:
pawn Код:
if(dialogid == DIALOG_REGISTER)
    {
        if(response)
        {
            if(strlen(inputtext)<3 || strlen(inputtext)>20)
            {
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "BAD PASSWORD!", "\nYour password must be between [3-20] characters\nPlease type a new password!", "REGISTER", "CANCEL");
            }
            else
            {
                RegisterPlayer(playerid, inputtext); // Line 1513, apperantly server crashes here
                return 1;
            }
        }
        if(!response)
        {
            RequireRegister(playerid);
        }
    }
RegisterPlayer:
pawn Код:
stock RegisterPlayer(playerid, password[])
{
    new query[512], pip[16], _day, _month, _year, pw_hash[129];
    getdate(_year, _month, _day);
    GetPlayerIp(playerid, pip, sizeof(pip));
    WP_Hash(pw_hash, sizeof(pw_hash), password);

    format(query, sizeof(query), "INSERT INTO users \
        (`username`, `password`, `ip`, `skin`, `score`, `timeplayed`, `adminlvl`, `weather`, `time`, `mutepm`, `nogoto`, `nospec`, `weaponset`, `wantedlvl`, `chwon`\
            , `kills`, `glassesid`, `capid`, `bbought`, `spawnx`, `spawny`, `spawnz`) \
        VALUES('%s', '%s', '%s', 1, 0, 0, 0, 17, 12, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0.0, 0.0, 0.0)"
, PlayerName(playerid), pw_hash, pip);
    mysql_query(query);
    format(query, sizeof(query), "UPDATE `users` SET ach_played = 0, ach_kills = 0, ach_wantedlvls = 0, pcolor = 0, autofix = 1, autofix_val = 700, car_nos = 1, car_wheel = 0, car_boost = 0, car_color1 = -1, car_color2 = -1, car_hydros = 0, car_jump = 1, car_rampon = 0 \
        WHERE username = '%s'"
, PlayerName(playerid));
    mysql_query(query);
    format(query, sizeof(query), "UPDATE `users` SET car_antifall = 1, car_fastenter = 0, car_fastexit = 0, car_flip = 1, car_nostype = 1, car_plate = '%s', banned = 0, banreason = '-', banadmin = '-', bantime = '-', bandate = '-', registered = '%d-%d-%d', lastlogin = '%d-%d-%d' \
        WHERE `username` = '%s'"
, SCRIPT_ABBREV, _day, _month, _year, _day, _month, _year, PlayerName(playerid));
    mysql_query(query);
    pData[playerid][registered] = 1;

    new str[128];
    format(str, sizeof(str), "You succesfully registered [Username: %s - Password: %s]", PlayerName(playerid), password);
    SendClientMessage(playerid, COLOR_GREEN, str);
    LoadPlayer(playerid);
    SetupPlayerForClassSelection(playerid);
    return 1;
}
I'll be very grateful to the person who can fix this problem.
Reply
#2

try putting '0','0' ect. around the values...
Reply
#3

Quote:
Originally Posted by Shadow-
Посмотреть сообщение
try putting '0','0' ect. around the values...
In SQL, ' tags are used to wrap a string, please only respond if you know what you're saying :/
Reply
#4

Show us your mysql log.
Reply
#5

Quote:
Originally Posted by Sinner
Посмотреть сообщение
In SQL, ' tags are used to wrap a string, please only respond if you know what you're saying :/
I use them around every variable too and it works just fine.
Reply
#6

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
Show us your mysql log.
I'll post it next restart, didn't enable mysql_debug :/

Quote:
Originally Posted by Vince
Посмотреть сообщение
I use them around every variable too and it works just fine.
' isn't the same as `
Reply
#7

Trust me, I know what I'm talking about.
PHP код:
SELECT FROM `playerstatsWHERE `SSQLID` = '%d' LIMIT 1
Works perfectly fine. And yes, SSQLID is defined as integer in the DB.
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
Trust me, I know what I'm talking about.
PHP код:
SELECT FROM `playerstatsWHERE `SSQLID` = '%d' LIMIT 1
Works perfectly fine. And yes, SSQLID is defined as integer in the DB.
That it works doesn't mean it's correct syntax :/ Anyways that's not the point of this discussion I'm not going to argue about who's right.
Reply
#9

You don't put ' or ` around integer values.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)