22.01.2012, 14:53
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:
The error occurs on this block of code:
RegisterPlayer:
I'll be very grateful to the person who can fix this problem.
Код:
[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)
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);
}
}
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;
}