pawn Код:
CMD:banaccount(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
return 1;
}
new string[128], playername[MAX_PLAYER_NAME], reason[64];
if(sscanf(params, "ss", playername, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /banaccount [playername] [reason]");
new giveplayerid = ReturnUser(playername);
if(IsPlayerConnected(giveplayerid))
{
if(PlayerInfo[giveplayerid][pAdmin] > PlayerInfo[playerid][pAdmin])
{
format(string, sizeof(string), "AdmCmd: %s has been auto-banned, reason: Trying to /ban a higher admin.", GetPlayerNameEx(playerid));
ABroadCast(COLOR_YELLOW,string,2);
PlayerInfo[playerid][pBanned] = 1;
new ip[32];
GetPlayerIp(giveplayerid,ip,sizeof(ip));
AddBan(ip);
Kick(giveplayerid);
}
else
{
new year, month,day;
getdate(year, month, day);
new playerip[32];
GetPlayerIp(giveplayerid, playerip, sizeof(playerip));
format(string, sizeof(string), "AdmCmd: %s(IP:%s) was banned by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), playerip, GetPlayerNameEx(playerid), reason,month,day,year);
Log("logs/ban.log", string);
SendClientMessage(playerid, COLOR_WHITE, "The player is online and has been banned!");
format(string, sizeof(string), "PlayerBan: %s was banned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason);
SendClientMessageToAllEx(COLOR_RED, string);
PlayerInfo[giveplayerid][pBanned] = 1;
format(PlayerInfo[giveplayerid][pFlag], 128, "");
new ip[32];
GetPlayerIp(giveplayerid,ip,sizeof(ip));
AddBan(ip);
Kick(giveplayerid);
}
}
else if(doesAccountExist(playername))
{
OnPlayerOfflineLogin(playername);
if( PlayerInfo[MAX_PLAYERS][pPermaBanned] == 3 )
{
SendClientMessageEx( playerid, COLOR_WHITE, "That player is already permabanned!" );
return 1;
}
if( PlayerInfo[MAX_PLAYERS][pAdmin] >= 2 )
{
SendClientMessageEx( playerid, COLOR_WHITE, "You can not ban admin accounts!" );
return 1;
}
else
{
if( PlayerInfo[MAX_PLAYERS][pBanned] >= 0 )
{
PlayerInfo[MAX_PLAYERS][pBanned] = 1;
AddBan(PlayerInfo[MAX_PLAYERS][pIP]);
OnPlayerOfflineSave(playername);
new year, month,day;
getdate(year, month, day);
format(string, sizeof(string), "AdmCmd: %s (IP:%s) was offline banned by %s, reason: %s (%d-%d-%d)", playername, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid), reason, month, day, year);
Log("logs/ban.log", string);
format(string, 128, "PlayerBan: %s (IP:%s) was offline banned by %s, reason: %s", playername, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid), reason);
ABroadCast(COLOR_RED,string,2);
print(string);
}
else
{
SendClientMessageEx( playerid, COLOR_WHITE, "Already a banned account!" );
}
}
}
else
{
SendClientMessageEx( playerid, COLOR_WHITE, "That account doesn't exist." );
}
return 1;
}