04.05.2014, 12:58
pawn Код:
public OnPlayerConnect(playerid)
{
new query[200];
format(query, sizeof(query), "SELECT IP FROM 'playerdata' WHERE user = '%s' LIMIT 1", GetName(playerid));
mysql_query(query);
mysql_store_result();
new rows = mysql_num_rows();
if (!rows)
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""RED">> "PREMIUM"Account Register", ""WHITE"Welcome to "RED"Burn0uT ParadisE"WHITE"!\n"WHITE"This account is "RED"not "WHITE"registered.\n\n"YELLOW"» Please enter a password below to register.", "Register", "Quit");
}
if (rows == 1)
{
new IP[2][16];
mysql_fetch_field_row(IP[0], "IP");
GetPlayerIp(playerid, IP[1], 16);
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_PASSWORD, ""RED">> "PREMIUM"Account Login", ""WHITE"Welcome back to "RED"Burn0uT ParadisE"WHITE"!\n"WHITE"This account is "GREEN"registered"WHITE".\n\n"YELLOW"» Please enter your password below to login.", "Login", "Quit");
PlayerInfo[playerid][IsRegistered] = 1;
}
}
mysql_free_result();
return 1;
}
pawn Код:
if (dialogid == DIALOG_REGISTER)
{
if (response)
{
if(!strlen(inputtext) || strlen(inputtext) > 68)
{
SendClientMessage(playerid, -1, ""RED":: "GREY"Your password cannot be longer than 68 characters.");
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, ""RED">> "PREMIUM"Account Register", ""WHITE"Welcome to "RED"Burn0uT ParadisE"WHITE"!\n"WHITE"This account is "RED"not "WHITE"registered.\n\n"YELLOW"» Please enter a password below to register.", "Register", "Quit");
}
else if(strlen(inputtext) > 0 && strlen(inputtext) < 68)
{
new escpass[100];
mysql_real_escape_string(inputtext, escpass);
MySQL_Register(playerid, escpass);
}
}
if (!response)
{
SendClientMessage(playerid, -1, ""RED":: "LIGHTBLUE"You can come back any time to register!");
SetTimerEx("KickPlayer", 500, false, "i", playerid);
}
}
//---------------
// Login Dialog
//---------------
if (dialogid == DIALOG_LOGIN)
{
if (!response)
{
SendClientMessage(playerid, -1, ""RED":: "LIGHTBLUE"Forgot your password? Contact our staff on http://www.bestsampserver.com to get help!");
SetTimerEx("KickPlayer", 500, false, "i", playerid);
}
if (response)
{
new query[200], escapepass[100];
mysql_real_escape_string(inputtext, escapepass);
format(query, sizeof(query), "SELECT `user` FROM playerdata WHERE user = '%s' AND password = SHA1('%s')", GetName(playerid), escapepass);
mysql_query(query);
mysql_store_result();
new numrows = mysql_num_rows();
if (numrows) MySQL_Login(playerid);
if (!numrows)
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, ""RED">> "PREMIUM"Account Login", ""WHITE"Welcome back to "RED"Burn0uT ParadisE"WHITE"!\n"WHITE"This account is "GREEN"registered"WHITE".\n\n"YELLOW"» Please enter your password below to login.", "Login", "Quit");
SendClientMessage(playerid, -1, ""RED":: "GREY"You have entered an incorrect password!");
}
mysql_free_result();
}
}