17.06.2012, 18:51
The database gives like accounts with blank names,
and everyone who registers becomes level 5 at times for some reasons
gammode (first part)
disconnect
Dialog
connect
Spawn
Why does it do that?
and everyone who registers becomes level 5 at times for some reasons
gammode (first part)
pawn Код:
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(40), score INT(20), money INT(20), level INT(20), EXP INT(20), rank INT(20), kills INT(20), deaths INT(20), star INT(20), uc INT(20), IP VARCHAR(15) )");
mysql_debug(1);
return 1;
pawn Код:
format(query, sizeof(query), "UPDATE `playerdata` SET `score` = '%d', `kills` = '%d', `deaths` = '%d', `money` = '%d', `level` = '%d', `EXP` = '%d', `rank` = '%d', `star` = '%d', `uc` = '%d' WHERE `user` ='%s'", score, kills, deaths, money, AdminLevel[playerid], exxp, rank, Star[playerid], UC[playerid], pname);
mysql_query(query);
}
pawn Код:
//================================================================//
// MySQL part //
//================================================================//
if(dialogid == DIALOG_REGISTER)
{
if(response)
{
if(!strlen(inputtext) || strlen(inputtext) > 25)
{
SendClientMessage(playerid, COLOR_RED,"~r~Error: ~w~You must insert a password between 1-25 characters!");
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""Blue"Please register",""White"Welcome to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to register!\n\n"White"Please insert a password below:", "Register", "Cancel");
}
else if(strlen(inputtext) > 0 && strlen(inputtext) < 25)
{
new escpass[100];
mysql_real_escape_string(inputtext, escpass);
MySQL_Register(playerid, escpass);
}
}
if(!response)
{
SendClientMessage(playerid, COLOR_RED,"~r~Error: ~w~You must register before logging in!");
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""Blue"Please register",""White"Welcome to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to register!\n\n"White"Please insert a password below:", "Register", "Cancel");
}
}
if(dialogid == DIALOG_LOGIN)
{
if(!response)
{
SendClientMessage(playerid, COLOR_RED,"~r~Error: ~w~You must login before you spawn!");
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""Blue"Please log-in", ""White"Welcome back to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to log-in!\n\n"White"Please insert "Red"your"White" password below:", "Login", "Cancel");
}
if(response)
{
new query[200], pname[24], escapepass[100];
GetPlayerName(playerid, pname, 24);
mysql_real_escape_string(inputtext, escapepass);
format(query, sizeof(query), "SELECT `user` FROM `playerdata` WHERE `user` = '%s' AND password = `SHA1`('%s')", pname, escapepass);
mysql_query(query);
mysql_store_result();
new numrows = mysql_num_rows();
if(numrows == 1) MySQL_Login(playerid);
if(!numrows)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""Blue"Please log-in", ""White"Welcome back to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to log-in!\n\n"White"Please insert "Red"your"White" password below:", "Login", "Cancel");
SendClientMessage(playerid, COLOR_RED,"~r~Error: ~w~Incorrect password!");
}
mysql_free_result();
}
}
return 1;
}
pawn Код:
MoneyGiven[playerid] = -1;
JustLogged[playerid] = 0;
new query[300], 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)
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""Blue"Please register",""White"Welcome to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to register!\n\n"White"Please insert a password below:", "Register", "Cancel");
}
if(rows == 1)
{
new IP[2][15];
mysql_fetch_field_row(IP[0],"IP");
GetPlayerIp(playerid, IP[1], 15);
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, ""Blue"Please log-in", ""White"Welcome back to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to log-in!\n\n"White"Please insert "Red"your"White" password below:", "Login", "Cancel");
IsRegistered[playerid] = 1;
}
}
mysql_free_result();
return 1;
}
pawn Код:
{
//================================================================//
// MySQL part //
//================================================================//
if(!Logged[playerid])
{
if(!IsRegistered[playerid])
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""Blue"Please register",""White"Welcome to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to register!\n\n"White"Please insert a password below:", "Register", "Cancel");
return 0;
}
if(IsRegistered[playerid] == 1)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, ""Blue"Please log-in", ""White"Welcome back to "Red""SERVER_NAME""White"!\n"White"In order to start playing, you have to log-in!\n\n"White"Please insert "Red"your"White" password below:", "Login", "Cancel");
return 0;
}
}
return 1;
}
Why does it do that?