CheckDatabase(playerid)
{
new q[200];
new playername[24];
GetPlayerName(playerid,playername,sizeof(playername));
format(q, 200, "SELECT * FROM bans WHERE name = '%s' ORDER BY id DESC LIMIT 1", playername);
mysql_query(q,THREAD_BAN_CHECK_NAME,playerid);
new ip[16];
GetPlayerIp(playerid, ip, sizeof(ip));
format(q, 200, "SELECT * FROM bans WHERE ip = '%s' ORDER BY id DESC LIMIT 1", ip);
mysql_query(q,THREAD_BAN_CHECK_IP,playerid);
}
CheckBan(ip[])
{
new string[20];
new File: file = fopen("ban.cfg", io_read);
while(fread(file, string))
{
if (strcmp(ip, string, true, strlen(ip)) == 0)
{
fclose(file);
return 1;
}
}
fclose(file);
return 0;
}
AddBan(ip[])
{
if (CheckBan(ip) == 0)
{
new File: file = fopen("ban.cfg", io_append);
new string[300];
format(string, sizeof(string), "\n%s", ip);
fwrite(file, string);
fclose(file);
foreach(Player, playerid)
{
new playerIP[16];
GetPlayerIp(playerid, playerIP, sizeof(playerIP));
if (strcmp(playerIP, ip) == 0)
{
strcat(string, "{FF0000}You were IP address banned. If you believe this was in error, appeal at www.usa-rp.cf\n");
strcat(string, "This ban is occured due to a permanant ban being issued.");
ShowPlayerDialog(playerid, DIALOG_SHOW_INFO, DIALOG_STYLE_MSGBOX, "{FFFFFF}Banned from Server", string, "Ok", "Cancel");
SetTimerEx("SendToKick", 1500, 0, "i", playerid);
}
}
return 1;
}
return 0;
}
RemoveBan(ip[])
{
if (CheckBan(ip) == 1)
{
new string[20];
new File: file = fopen("ban.cfg", io_read);
fcreate("tempBan.cfg");
new File: file2 = fopen("tempBan.cfg", io_append);
while(fread(file, string))
{
if (strcmp(ip, string, true, strlen(ip)) != 0 && strcmp("\n", string) != 0)
{
fwrite(file2, string);
}
}
fclose(file);
fclose(file2);
file = fopen("ban.cfg", io_write);
file2 = fopen("tempBan.cfg", io_read);
while(fread(file2, string))
{
fwrite(file, string);
}
fclose(file);
fclose(file2);
fremove("tempBan.cfg");
return 1;
}
return 0;
}
CMD:banaccount(playerid, params[])
{
if(!PlayerInfo[playerid][pAdmin]) return Error(playerid, "You are not authorized to use this command!");
new playername[24], length, reason[64];
if(sscanf(params, "s[24]is[64]", playername, length, reason)) return Syntax(playerid, "banaccount", "[playername] [length (days) 0 = perm] [reason]");
new giveplayerid = ReturnUser(playername);
new string[128];
format(STRING, "That player is currently on the server. Use /ban. (ID: %d)", giveplayerid);
if(IsPlayerConnected(giveplayerid)) return Error(playerid, string);
if(!doesAccountExist(playername)) return Error(playerid, "Could not find account specified. Check the name and try again.");
OnPlayerOfflineLogin(playername);
if(PlayerInfo[MAX_PLAYERS][pAdmin] > PlayerInfo[playerid][pAdmin]) return Error(playerid, "You cannot ban a higher level admin.");
new ip[16];
format(ip, sizeof(ip), "%s", PlayerInfo[MAX_PLAYERS][pIP]);
BanAccount(playerid, playername, length, reason, ip);
//PlayerInfo[MAX_PLAYERS][pBanned] = 1;
OnPlayerOfflineSave(playername);
new year, month,day;
getdate(year, month, day);
format(string, sizeof(string), "AdmCmd: %s (IP:%s) was offline banned for %d days by %s, reason: %s (%d-%d-%d)", playername, PlayerInfo[MAX_PLAYERS][pIP], length, GetPlayerNameEx(playerid), reason, month, day, year);
Log("logs/ban.log", string);
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return Error(playerid, "You are not authorized to use this command");
new giveplayerid, time, reason[64], string[128];
if(sscanf(params, "iis[64]", giveplayerid, time, reason)) return Syntax(playerid, "ban", "[playerid/PartOfName] [time(days) 0 = perm] [reason]");
if(!IsPlayerConnected(giveplayerid)) return Error(playerid, "Invalid player specified!");
if(playerid == giveplayerid) return Error(playerid, "You cannot ban youself, Chris McLeary.");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin]) return Error(playerid, "You cannot ban a equal or higher level admin.");
//PlayerInfo[giveplayerid][pBanned] = 1;
BanPlayer(playerid, giveplayerid, time, reason);
format(string, sizeof(string), "AdmCmd: %s was banned by %s for %s, reason: %s ", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), time, reason);
Log("logs/ban.log", string);
return 1;
}
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return Error(playerid, "You are not authorized to use this command");
new giveplayerid, time, reason[64], string[128];
if(sscanf(params, "iis[64]", giveplayerid, time, reason)) return Syntax(playerid, "ban", "[playerid/PartOfName] [time(days) 0 = perm] [reason]");
if(!IsPlayerConnected(giveplayerid)) return Error(playerid, "Invalid player specified!");
if(playerid == giveplayerid) return Error(playerid, "You cannot ban youself, Chris McLeary.");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin]) return Error(playerid, "You cannot ban a equal or higher level admin.");
//PlayerInfo[giveplayerid][pBanned] = 1;
BanPlayer(playerid, giveplayerid, time, reason);
format(string, sizeof(string), "AdmCmd: %s was banned by %s for %s, reason: %s ", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), time, reason);
Log("logs/ban.log", string);
return 1;
}
|
Are you referring specifically to this command?
pawn Код:
|
CMD:ban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return Error(playerid, "You are not authorized to use this command");
new giveplayerid, time, reason[64], string[128];
if(sscanf(params, "iis[64]", giveplayerid, time, reason)) return Syntax(playerid, "ban", "[playerid/PartOfName] [time(days) 0 = perm] [reason]");
if(!IsPlayerConnected(giveplayerid)) return Error(playerid, "Invalid player specified!");
if(playerid == giveplayerid) return Error(playerid, "You cannot ban youself, Chris McLeary.");
if(PlayerInfo[playerid][pAdmin] < PlayerInfo[giveplayerid][pAdmin]) return Error(playerid, "You cannot ban a equal or higher level admin.");
PlayerInfo[giveplayerid][pBanned] = 1;//why did you defined it as a comment?
BanPlayer(playerid, giveplayerid, time, reason);
format(string, sizeof(string), "AdmCmd: %s was banned by %s for %s, reason: %s ", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), time, reason);
Log("logs/ban.log", string);
return 1;
}
if(PlayerInfo[playerid][pBanned] == 1)
{
SendClientMessage(playerid,-1,"This Account is banned!");
Kick(playerid);