CMD:ban(playerid,params[]) {
new reason[100], id,szString[64];
if(PInfo[playerid][Level] < 2) return SendClientMessage(playerid,0xFF0000AA,"ERROR: You are not allowed to use this command!");
if(sscanf(params,"ds",id,reason)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /ban <playerid> <reason>");
if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(id, PlayerName, sizeof(PlayerName));
new GPlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, GPlayerName, sizeof(GPlayerName));
new plrIP[64];
GetPlayerIp(id, plrIP, 64);
new Year, Month, Day;
getdate(Year, Month, Day);
format(szString, sizeof(szString), "%s (ID:%d) has been banned by %s Reason: %s", PlayerName,GPlayerName, id, reason);
SendClientMessageToAll(0xFF444499, szString);
format(szString, sizeof(szString), "Admin %s, Used The Command: 'BAN' Target: %s", GPlayerName, PlayerName);
SendClientMessageToAdmins(szString);
format(szString, sizeof(szString), "You Have Been Banned By Admin: %s (ID:%d)", GPlayerName, playerid);
SendClientMessage(id, 0x00B359FF, szString);
format(szString, sizeof(szString), "Reason: %s", reason);
SendClientMessage(id, 0x00B359FF, szString);
format(szString, sizeof(szString), "Date: %02d/%02d/%d", Day, Month, Year);
SendClientMessage(id, 0x00B359FF, szString);
SendClientMessage(id, 0xF74646FF, "If you wish to appeal this ban, Then Appeal At: TOBEANNOUNCED");
format(szString, sizeof(szString), "[BAN] | Admin: %s | Name: %s | Reason: %s | Date: %02d/%02d/%d | IP: %s<hr/>", GPlayerName, PlayerName, reason, Day, Month, Year, plrIP);
Ban(id);
return 1;
}
INI_WriteInt("Banned",1);
INI_Open(file);
INI_WriteInt("Rank", PInfo[playerid][Rank]);
INI_WriteInt("Level", PInfo[playerid][Level]);
INI_WriteInt("Operator", PInfo[playerid][Operator]);
INI_WriteInt("Banned", PInfo[playerid][Banned]);
INI_WriteInt("Kills", PInfo[playerid][Kills]);
INI_WriteInt("Deaths", PInfo[playerid][Deaths]);
INI_WriteInt("Score", scores);
INI_WriteInt("Money", money);
INI_Save();
INI_Close();
Then under the /ban command, add
PInfo[id][Banned] = 1; That should work, then it will call onplayerdisconnect. Edit: Also, change Ban(id); to Kick(id); as it will ban them from the server and just show "You are banned from this server.". That way, you can add your own custom message under OnPlayerConnect. |
public OnPlayerConnect(playerid) {
SendClientMessage(playerid,red,"Welcome to United Kingdom TDM! Dont forget to check /updates ! ");
SendClientMessage(playerid,GREEN,"Remember to /buyrank to buy a rank ");
new name[MAX_PLAYER_NAME], string[24+MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "** %s has joined United Kingdom TDM", name);
IsOnAdminDuty[playerid] = false;
PInfo[playerid][Money] = 0;
PInfo[playerid][Score] = 0;
PInfo[playerid][Kills] = 0;
PInfo[playerid][Deaths] = 0;
PInfo[playerid][Level] = 0;
PInfo[playerid][Rank] = 0;
SendClientMessageToAll(-1, string);
PMEnabled[playerid] = 1;
IsMuted[playerid] = 0;
TogglePlayerSpectating(playerid, false);
new file[64],PlayerName[25];//Creating a variable where we can store the file path, and the variable to store the player's name.
GetPlayerName(playerid,PlayerName,sizeof PlayerName);//Storing the players name in the PlayerName variable.
format(file,sizeof file,"Admin/%s.ini",PlayerName);//Storing the file path with the players name.
if(fexist(file)) {
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Login Below", "Enter Your Password To Login!", "Login", "Quit");
} else {
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Register Below", "Enter A Password To Register And Play!", "Register", "Quit");
}
return 1;
}