25.03.2016, 10:49
I'm trying to create a mysql script. I have a login / account system.
When a admin bans a player, it adds the information (Name, IP, Reason etc) into a MySQL table "bans"
Under OnPlayerConnect, I currently use this:
I would like to make it so when they join, it searches the bans mysql table for the playername and IP and if it matches, it'll kick the player with a message or dialog with the ban information in.
My OnAccountCheck
When a admin bans a player, it adds the information (Name, IP, Reason etc) into a MySQL table "bans"
Under OnPlayerConnect, I currently use this:
pawn Код:
Player[playerid][Logged] = 0;
TogglePlayerSpectating(playerid, true);
new
query[128],
playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
My OnAccountCheck
pawn Код:
public OnAccountCheck(playerid)
{
new
rows,
fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "Password", Player[playerid][Password], mysql, 129);
Player[playerid][ID] = cache_get_field_content_int(0, "ID");
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_PASSWORD, "Login", "Welcome player!\nYour account has been found in our database. Please fill in your password:", "Login", "Quit");
}
else
{
ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_PASSWORD, "Register", "Welcome player!\nYour account has not been registered yet. Please fill in your desired password:", "Register", "Quit");
}
return true;
}