17.12.2013, 04:23
Correction:
pawn Код:
CMD:ban(playerid,params[])
{
if(pInfo[playerid][Adminlevel] < 3 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} You don't have an appropriate administration level to use this command.");
new targetid, reason[25];
if(sscanf(params, "ds[25]", targetid, reason)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: {FFFFFF}/ban [ID] [Reason]");
if(!IsPlayerConnected(targetid) || targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player is not connected!");
if(pInfo[targetid][USER_LOGGED_IN] == false) return SendClientMessage(playerid, COLOR_RED, "[ERROR]{FFFFFF} Player has not logged in.");
new ip[16], string[100], Query[500], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
GetPlayerIp(targetid, ip, sizeof(ip));
GetPlayerName(targetid, name2, sizeof(name2));
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "[ADMIN]{FFFFFF} %s(%d) has been banned by %s(%d) {28f200}[reason: %s]", name2, targetid, name, playerid, reason);
SendClientMessageToAll(COLOR_ADMIN, string);
pInfo[targetid][Banned] = 1;
format(string, sizeof(string), "banip %s", ip);
SendRconCommand(string);
SendRconCommand("reloadbans");
format(Query, sizeof(Query), "UPDATE users SET banned = %d WHERE username = '%s'",pInfo[targetid][Banned],targetid);
db_query(DatabaseAcc, Query);
Kicked(targetid, 500);
return 1;
}