stock PlayerLogin(playerid, password)
{
new str[128];
format(str, sizeof(str),"SELECT * FROM users WHERE username = '%s' AND password = md5('%s')",pName(playerid),password);
mysql_query(str);
mysql_store_result();
if(!mysql_num_rows())
{
SendInfoMessage(playerid,"Wrong {a9c4e4}password{ffffff}! Kicked due to security reasons!");
Kick(playerid);
mysql_free_result();
return 1;
}
else
{
SendInfoMessage(playerid,"Successfully logged in. Welcome back!");
mysql_free_result();
return 1;
}
}
stock PlayerLogin(playerid, const password[])
?|
pawn Код:
|
|
Why are you bumping it when Jefff gave you the answer right there
?add the 'const' bit before the password part. |
public OnPlayerConnect(playerid)
{
if(CheckAccountExists(playerid) == 0) return ShowPlayerDialog(playerid,DIALOG_REGISTER,1,"Register",str,"Register","Cancel");
else return ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login",str1,"Login","Cancel");
}
stock CheckAccountExists(playerid)
{
new string[128];
format(string, sizeof(string), "SELECT * FROM users WHERE username = '%s'", pName(playerid));
mysql_query(string);
mysql_store_result();
new value;
value = mysql_num_rows();
mysql_free_result();
return value;
}
if(dialogid == DIALOG_REGISTER)
{
if(response)
{
if(strlen(inputtext[0]) < 6 || strlen(inputtext[0]) > 32) return ShowPlayerDialog(playerid,DIALOG_REGISTER,1,"Register","Password too short! Use 6-32 characters","Register","Cancel");
PlayerRegister(playerid, inputtext);
return 1;
}
else
{
SendInfoMessage(playerid,"You have to {a9c4e4}register {ffffff}in order to play!");
Kick(playerid);
return 1;
}
}
if(dialogid == DIALOG_LOGIN)
{
if(response)
{
if(strlen(inputtext[0]) < 6 || strlen(inputtext[0]) > 32) return ShowPlayerDialog(playerid,DIALOG_LOGIN,1,"Login","Password too short! Use 6-32 characters","Login","Cancel");
PlayerLogin(playerid, inputtext);
return 1;
}
else
{
SendInfoMessage(playerid,"You have to {a9c4e4}login {ffffff}in order to play!");
Kick(playerid);
return 1;
}
}
stock PlayerRegister(playerid, const password[])
{
new str[128], pass[32];
mysql_real_escape_string(password, pass);
format(str,sizeof(str),"INSERT INTO users (username, password, adminlvl, level, money, skin) VALUES ('%s', md5('%s'), 0, 1, 10000, 177) ",pName(playerid),pass);
mysql_query(str);
SendInfoMessage(playerid,"You have been successfully registered and logged in!");
PlayerLogin(playerid, password);
return 1;
}
stock PlayerLogin(playerid, const password[])
{
new str[128], pass[32];
mysql_real_escape_string(password, pass);
format(str,sizeof(str),"SELECT * FROM users WHERE username='%s' AND password=md5('%s') ",pName(playerid),pass);
mysql_query(str);
mysql_store_result();
if(mysql_num_rows() == 0)
{
SendInfoMessage(playerid,"Wrong {a9c4e4}password{ffffff}! Kicked for security reasons!");
Kick(playerid);
}
else
{
SendInfoMessage(playerid,"Successfully logged in!");
LoadPlayerData(playerid);
}
mysql_free_result();
return 1;
}
pass[32]
pass[33]