#define MAX_WARNINGS 3
CMD:warn(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
new Target;
new Reason[50];
// if(sscanf(params, "us[50]", Target)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /warn [playerid] [reason]");
if(!sscanf(params, "us[50]", Target, Reason))
{
//if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
if(!IsPlayerConnected(Target))
return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
if(PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You can't perform this command on Admins that are higher than your level!");
PlayerInfo[Target][Warnings]++;
new tname[MAX_PLAYER_NAME];
GetPlayerName(Target,tname,sizeof(tname));
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
new MyString[256];
new TargetString[256];
WarnLog(Target);
format(MyString,sizeof MyString, "You have warned %s! (Reason: %s) (Warnings: %d/%d)", tname, Reason, PlayerInfo[Target][Warnings],MAX_WARNINGS);
format(TargetString,sizeof TargetString, "Administrator %s has given %s a warning! Reason: %s (Warnings: %d/%d)", pname, tname, Reason,PlayerInfo[Target][Warnings],MAX_WARNINGS);
SendClientMessage(Target, COLOR_RED, TargetString);
SendClientMessageToAll(COLOR_YELLOW, MyString);
if(PlayerInfo[Target][Warnings] == MAX_WARNINGS)
{
new kstring[256];
new name[MAX_PLAYER_NAME];
GetPlayerName(Target,name,sizeof(name));
format(kstring,sizeof(kstring),"Player %s (ID:%d) got kicked! (Reason: Maximum warnings)", name, Target);
SendClientMessageToAll(COLOR_RED,kstring);
PlayerInfo[Target][Warnings] = 0;
WarnKick(Target);
Kick(Target);
}
}
}
else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 3 to perform this command!");
return 1;
}
stock WarnKick(Target)
{
new File:Log = fopen(warnPATH, io_append);
new logData[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(Target,name,sizeof(name));
new fTime[6];
getdate(fTime[0], fTime[1], fTime[2]);
gettime(fTime[3], fTime[4], fTime[5]);
format(logData, sizeof logData, "[%02d/%02d/%04d || %02d:%02d:%02d]%s got kicked for reaching maximum warnings!\r\n", fTime[2], fTime[1], fTime[0], fTime[3], fTime[4], fTime[5], name);
fwrite(Log, logData);
fclose(Log);
return 1;
}
stock WarnLog(Target)
{
new File:Log = fopen(warnPATH, io_append);
new logData[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(Target,name,sizeof(name));
new fTime[6];
getdate(fTime[0], fTime[1], fTime[2]);
gettime(fTime[3], fTime[4], fTime[5]);
format(logData, sizeof logData, "[%02d/%02d/%04d || %02d:%02d:%02d]%s got warned!\r\n", fTime[2], fTime[1], fTime[0], fTime[3], fTime[4], fTime[5], name);
fwrite(Log, logData);
fclose(Log);
return 1;
}
CMD:warn(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
new Target;
new Reason[50];
if(sscanf(params, "us[50]", Target,Reason)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /warn [playerid] [reason]");
if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
if(PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You can't perform this command on Admins that are higher than your level!");
PlayerInfo[Target][Warnings] ++;
new tname[MAX_PLAYER_NAME];
GetPlayerName(Target,tname,sizeof(tname));
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
new MyString[128];
WarnLog(Target);
format(MyString,sizeof MyString, "You have warned %s! (Reason: %s) (Warnings: %d/%d)", tname, Reason, PlayerInfo[Target][Warnings],MAX_WARNINGS);
SendClientMessageToAll(COLOR_YELLOW,MyString);
format(MyString,sizeof(MyString), "Administrator %s has given %s a warning! Reason: %s (Warnings: %d/%d)", pname, tname, Reason,PlayerInfo[Target][Warnings],MAX_WARNINGS);
SendClientMessage(Target, COLOR_RED, MyString);
if(PlayerInfo[Target][Warnings] == MAX_WARNINGS)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(Target,name,sizeof(name));
format(MyString,sizeof(MyString),"Player %s (ID:%d) got kicked! (Reason: Maximum warnings)", name, Target);
SendClientMessageToAll(COLOR_RED,MyString);
WarnKick(Target);
Kick(Target);
}
}
else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 3 to perform this command!");
return 1;
}
COMMAND:warn(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
new Target;
new Reason[50];
if(sscanf(params, "us[50]", Target,Reason)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /warn [playerid] [reason]");
{
//if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
if(!IsPlayerConnected(Target))
return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
if(PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You can't perform this command on Admins that are higher than your level!");
PlayerInfo[Target][Warnings]++;
new tname[MAX_PLAYER_NAME];
GetPlayerName(Target,tname,sizeof(tname));
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
new MyString[128];
WarnLog(Target);
format(MyString,sizeof MyString, "You have warned %s! (Reason: %s) (Warnings: %d/%d)", tname, Reason, PlayerInfo[Target][Warnings],MAX_WARNINGS);
SendClientMessage(Target, COLOR_RED, MyString);
format(MyString,sizeof MyString, "Administrator %s has given %s a warning! Reason: %s (Warnings: %d/%d)", pname, tname, Reason,PlayerInfo[Target][Warnings],MAX_WARNINGS);
SendClientMessageToAll(COLOR_YELLOW, MyString);
if(PlayerInfo[Target][Warnings] == MAX_WARNINGS)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(Target,name,sizeof(name));
format(MyString,sizeof(MyString),"Player %s (ID:%d) got kicked! (Reason: Maximum warnings)", name, Target);
SendClientMessageToAll(COLOR_RED,MyString);
PlayerInfo[Target][Warnings] = 0;
WarnKick(Target);
Kick(Target);
}
}
}
else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 3 to perform this command!");
return 1;
}
CMD:warn(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] >= 3)
{
new Target;
new Reason[50];
if(sscanf(params, "us[50]", Target,Reason)) SendClientMessage(playerid, COLOR_LIGHTBLUE, "USAGE: /warn [playerid] [reason]");
if(Target == playerid) return SendClientMessage(playerid, COLOR_RED, "SERVER: Cant perform this command on yourself!" );
if(Target == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected!");
if(PlayerInfo[Target][pAdmin] > PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid,COLOR_RED,"ERROR: You can't perform this command on Admins that are higher than your level!");
PlayerInfo[Target][Warnings] ++;
new tname[MAX_PLAYER_NAME];
GetPlayerName(Target,tname,sizeof(tname));
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
new MyString[128];
WarnLog(Target);
format(MyString,sizeof MyString, "You have warned %s! (Reason: %s) (Warnings: %d/%d)", tname, Reason, PlayerInfo[Target][Warnings],MAX_WARNINGS);
SendClientMessageToAll(COLOR_YELLOW,MyString);
format(MyString,sizeof(MyString), "Administrator %s has given %s a warning! Reason: %s (Warnings: %d/%d)", pname, tname, Reason,PlayerInfo[Target][Warnings],MAX_WARNINGS);
SendClientMessage(Target, COLOR_RED, MyString);
if(PlayerInfo[Target][Warnings] == 3)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(Target,name,sizeof(name));
format(MyString,sizeof(MyString),"Player %s (ID:%d) got kicked! (Reason: Maximum warnings)", name, Target);
SendClientMessageToAll(COLOR_RED,MyString);
WarnKick(Target);
Kick(Target);
}
}
else return SendClientMessage(playerid,COLOR_RED,"ERROR: You must be level 3 to perform this command!");
return 1;
}
CMD:warn(playerid, params[])
{ if (PlayerInfo[playerid][pAdmin] >= 2) { new string[128], giveplayerid, reason[64]; if(sscanf(params, "us[64]", giveplayerid, reason)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /warn [playerid] [reason]"); if(IsPlayerConnected(giveplayerid)) { if(PlayerInfo[giveplayerid][pAdmin] >= 2) { SendClientMessageEx(playerid, COLOR_GRAD2, "Admins can not be warned !"); return 1; } PlayerInfo[giveplayerid][pWarns] += 1; if(PlayerInfo[giveplayerid][pWarns] >= 3) { new year, month,day; new ip[32]; GetPlayerIp(giveplayerid,ip,sizeof(ip)); getdate(year, month, day); format(string, sizeof(string), "AdmCmd: %s (IP: %s) was banned by %s (had 3 Warnings), reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), ip, GetPlayerNameEx(playerid), reason,month,day,year); Log("logs/ban.log", string); format(string, sizeof(string), "AdmCmd: %s was banned by %s (had 3 Warnings), reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason); SendClientMessageToAllEx(COLOR_LIGHTRED, string); PlayerInfo[giveplayerid][pBanned] = 1; AddBan(ip); Kick(giveplayerid); return 1; } new year, month, day; getdate(year, month, day); format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason); ABroadCast(COLOR_LIGHTRED, string, 2); format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s (%d-%d-%d)", GetPlayerNameEx(giveplayerid), GetPlayerNameEx(playerid), reason,month, day, year); Log("logs/admin.log", string); format(string, sizeof(string), "You were warned by %s, reason: %s", GetPlayerNameEx(playerid), reason); SendClientMessageEx(giveplayerid, COLOR_LIGHTRED, string); return 1; } } else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified."); return 1; } |