Players should not be able to create a new account with the same name, could you kindly assist?
Someone logged in with the same name as me but it created a new account.
Someone logged in with the same name as me but it created a new account.
Code:
forward IsPlayerBanned(playerid);
public IsPlayerBanned(playerid)
{
new rows, fields, string[128];
cache_get_data(rows, fields);
new pip[64];
GetPlayerIp(playerid, pip, sizeof(pip));
if(rows)
{
format(string, sizeof(string), "Your IP:{FF0000} %s{FFFFFF} is {FF0000}BANNED{FFFFFF} from Los Santos City Roleplay.", pip);
SendClientMessage(playerid, COLOUR_WHITE, string);
format(string, sizeof(string), "PLEASE POST A {FF0000}BAN APPEAL{FFFFFF} ON http://lsc-rp.com");
SendClientMessage(playerid, COLOUR_WHITE, string);
SetTimerEx("KickPlayer", 500, false, "i",playerid);// Kicks player in 500ms
}
else
{
new escape[MAX_PLAYER_NAME*2], query[256];
mysql_real_escape_string(GetName(playerid), escape);
format(query, sizeof(query), "SELECT `id` FROM `accounts` WHERE `PlayerName` = '%s' LIMIT 1", escape);
mysql_tquery(dbHandle, query, "OnPlayerDataLoad", "i", playerid);
}
return 1;
}
Code:
forward OnPlayerDataLoad(playerid);
public OnPlayerDataLoad(playerid)
{
SetPlayerTime(playerid,THrs,TMins);
new rows, fields;
cache_get_data(rows, fields);
if(!rows)
{
new string[256];
format(string, sizeof(string), "Welcome to %s\n\nPlease create an account by entering a password below:", HOSTNAME);
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register Here", string, "Register", "Leave");
}
else
{
new string[256];
format(string,sizeof(string),"Welcome to Los Santos City Roleplay, "COL_GREEN"%s!",GetNameEx(playerid));
SendClientMessage(playerid, COLOUR_WHITE,string);
format(string, sizeof(string), "Welcome to %s.\nPlease enter your password below:", HOSTNAME);
new temp[12];
cache_get_row(0, 0, temp);
PlayerSQLID[playerid] = strval(temp);
printf("PlayerSQLID: %d", PlayerSQLID[playerid]);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Los Santos City Roleplay.", string, "Login", "Leave");
}
return 1;
}