Commands not working [UNSOLVED] -
Ironboy500 - 27.04.2010
Hello, i need help with my commands [register/login]
Here are they!
Код:
dcmd_register(playerid, params[])
{
new password, ip[60], string[256];
GetPlayerIp(playerid, ip, sizeof(ip));
if(sscanf(params, "s", password)) return SendClientMessage(playerid, RED, "Error: Wrong usage of command!");
if(IsPlayerRegistered(Name(playerid))) return SendClientMessage(playerid,RED,"Error: This account already exists!");
if(password < 3 || password > 20) return SendClientMessage(playerid,RED,"Error: Invalid password size! [PASSWORD MUST BE 6+ and -20]");
SendClientMessage(playerid, ORANGE, "Server: Your account have been succesfully registered!");
SendClientMessage(playerid, ORANGE, "Server: You have been automatically logged in!");
GivePlayerMoney(playerid, 20000);
format(string,sizeof(string),"INSERT INTO `users` (`IP`, `Username`, `Password`, `Kills`, `Deaths`, `Finished Races`, `Money`,`AdminLevel`, `VIP`) VALUES ('%s', '%s', '%s', '0', '0', '0', '0', '0', '0');",ip,Name(playerid),password);
query(string);
if(!query(string)) return SendClientMessage(playerid, RED, "Error: System is busy processing our new users! Please try again later!");
IsLogged[playerid] = 1;
Info[playerid][Kills] = 0;
Info[playerid][Deaths] = 0;
Info[playerid][FinishedRaces] = 0;
Info[playerid][AdminLevel] = 0;
Info[playerid][VIP] = 0;
return 1;
}
Код:
dcmd_login(playerid, params[])
{
new password, PlayerPassword, string[256];
if(IsLogged[playerid] == 1) return SendClientMessage(playerid, RED, "Error: You are already logged in!");
if(!IsPlayerRegistered(Name(playerid))) return SendClientMessage(playerid, RED, "Error: This account doesn't exist!");
if(sscanf(params, "s", password)) return SendClientMessage(playerid, RED, "Error: Wrong usage of command!");
format(string, sizeof(string), "SELECT `Password`,`Kills`,`Deaths`,`Finished Races`,`Money`, `AdminLevel`, `VIP` FROM `users` WHERE `Username` = '%s'", Name(playerid));
query(string);
mysql_store_result();
new index, line[256];
mysql_fetch_row_format(line, "|");
PlayerPassword = strval(strtokm(line, index, '|'));
if(PlayerPassword != password)
{
SendClientMessage(playerid, RED, "Error: Wrong user password!");
return 1;
}
else
{
SendClientMessage(playerid, ORANGE, "Server. You have been succesfully logged in!");
Info[playerid][Kills] = strval(strtokm(line, index, '|'));
Info[playerid][Deaths] = strval(strtokm(line, index, '|'));
Info[playerid][FinishedRaces] = strval(strtokm(line, index, '|'));
Info[playerid][Money] = strval(strtokm(line, index, '|'));
Info[playerid][AdminLevel] = strval(strtokm(line, index, '|'));
Info[playerid][VIP] = strval(strtokm(line, index, '|'));
SetPlayerMoney(playerid, Info[playerid][Money]);
if(Info[playerid][VIP] == 1)
{
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
new login[256];
format(login, sizeof(login), "VIP %s has logged in!", Name(playerid));
TextDrawSetString(Textdraw0, login);
TextDrawShowForAll(Textdraw0);
SetTimer("Destroy", 2000, false);
vip[playerid] = Create3DTextLabel("Premium Player",ORANGE,0,0,0,40,0);
Attach3DTextLabelToPlayer(vip[playerid],playerid,0.0,0.0,0.0);
}
return 1;
}
}
After i type one of this commands server crash "Lost connection to server...".
Any help in solving this?
Re: Commands not working [UNSOLVED] -
dice7 - 27.04.2010
I suppose you don't have the sql plugin ?
Re: Commands not working [UNSOLVED] -
[MWR]Blood - 27.04.2010
You're missing some plugin, or some folder in scriptfiles.
Re: Commands not working [UNSOLVED] -
Ironboy500 - 27.04.2010
No, everything is good, plugin - mysql.dll
Re: Commands not working [UNSOLVED] -
Ironboy500 - 27.04.2010
bump*
Re: Commands not working [UNSOLVED] -
dice7 - 27.04.2010
Debug your code to see at which point it crashes the server
Re: Commands not working [UNSOLVED] -
Ironboy500 - 27.04.2010
Last thing in debug is following:
Код:
[20:58:11] mysql_query("SELECT * FROM `users` WHERE `Username` = ''"); Return: 1
[20:58:11] mysql_store_result();
[20:58:11] mysql_num_rows(); Return: 0
Thanks for any help!