COMMAND:warn(playerid, params[])
{
new PlayerToWarn, Reason[128], ReasonMsg[128], Name[24];
// Send the command to all admins so they can see it
SendAdminText(playerid, "/warn", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 1
if (APlayerData[playerid][PlayerLevel] >= 1)
{
if (sscanf(params, "us[128]", PlayerToWarn, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/warn <PlayerToWarn> <Reason>\"");
else
if (IsPlayerConnected(PlayerToWarn)) // If the player is a valid playerid (he's connected)
{
// Increase the number of warnings
APlayerData[PlayerToWarn][Warnings]++;
// Get the name of the player who warned the player
GetPlayerName(playerid, Name, sizeof(Name));
// Send the warned player a message who warned him and why he's been warned
format(ReasonMsg, 128, "You have been warned by %s %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
SendClientMessage(PlayerToWarn, 0xFF0000FF, ReasonMsg);
format(ReasonMsg, 128, "Reason: %s", Reason);
SendClientMessage(PlayerToWarn, 0xFF0000FF, ReasonMsg);
format(ReasonMsg, 128, "~w~Warning %i/%i: ~r~%s~w~", APlayerData[PlayerToWarn][Warnings], AutoKickWarnings, Reason);
GameTextForPlayer(PlayerToWarn, ReasonMsg, 5000, 4);
// Get the name of the warned player
GetPlayerName(PlayerToWarn, Name, sizeof(Name));
// Let the admin know who has been warned and why
format(ReasonMsg, 128, "You have warned %s (warnings: %i/%i)", Name, APlayerData[PlayerToWarn][Warnings], AutoKickWarnings);
SendClientMessage(playerid, 0x00FF00FF, ReasonMsg);
format(ReasonMsg, 128, "Reason: %s", Reason);
SendClientMessage(playerid, 0xFF0000FF, ReasonMsg);
// Automatically kick the player if he got 3 warnings (if autokick is enabled)
if ((APlayerData[PlayerToWarn][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1))
Kick(PlayerToWarn);
}
else
SendClientMessage(playerid, 0xFF0000FF, "That player isn't online");
}
else
return 0;
}
else
return 0;
format(ReasonMsg, sizeof(ReasonMsg), "%s %s has warned %s. Reason: %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name, PlayerToWarn, reason);
SendClientMessageToAll(-1, ReasonMsg);
COMMAND:warn(playerid, params[])
{
new PlayerToWarn, Reason[128], ReasonMsg[128], Name[24], Target[24];
// Get the name
GetPlayerName(playerid, Name, sizeof(Name));
GetPlayerName(PlayerToWarn, Target, sizeof(Target));
// Send the command to all admins so they can see it
SendAdminText(playerid, "/warn", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 1
if (APlayerData[playerid][PlayerLevel] >= 1)
{
if (sscanf(params, "us[128]", PlayerToWarn, Reason)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/warn <PlayerToWarn> <Reason>\"");
else
if (IsPlayerConnected(PlayerToWarn)) // If the player is a valid playerid (he's connected)
{
// Increase the number of warnings
APlayerData[PlayerToWarn][Warnings]++;
// Send the warned player a message who warned him and why he's been warned
format(ReasonMsg, 128, "You have been warned by %s %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
SendClientMessage(PlayerToWarn, 0xFF0000FF, ReasonMsg);
format(ReasonMsg, 128, "Reason: %s", Reason);
SendClientMessage(PlayerToWarn, 0xFF0000FF, ReasonMsg);
format(ReasonMsg, 128, "~w~Warning %i/%i: ~r~%s~w~", APlayerData[PlayerToWarn][Warnings], AutoKickWarnings, Reason);
GameTextForPlayer(PlayerToWarn, ReasonMsg, 5000, 4);
// Let the admin know who has been warned and why
format(ReasonMsg, 128, "You have warned %s (warnings: %i/%i)", Target, APlayerData[PlayerToWarn][Warnings], AutoKickWarnings);
SendClientMessage(playerid, 0x00FF00FF, ReasonMsg);
format(ReasonMsg, 128, "Reason: %s", Reason);
SendClientMessage(playerid, 0xFF0000FF, ReasonMsg);
// Send it to all players
format(ReasonMsg, sizeof(ReasonMsg), "%s %s has warned %s. [Reason: %s].", AdminLevelName[APlayerData[playerid][PlayerLevel]], Name, Target, Reason);
SendClientMessageToAll(0xFF0000FF, ReasonMsg);
// Automatically kick the player if he got 3 warnings (if autokick is enabled)
if ((APlayerData[PlayerToWarn][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1))
Kick(PlayerToWarn);
}
else
SendClientMessage(playerid, 0xFF0000FF, "That player isn't online");
}
else
return 0;
}
else
return 0;
new Warns[MAX_PLAYERS]; #define SCM SendClientMessage
CMD:warn(playerid, params[]) { new id, reason[124], string[124], plrIP[16]; if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, COLOR_GREY, "You're not authorized to use that command."); if(sscanf(params,"us[124]",id,reason)) return SCM(playerid, COLOR_GREY,"[Usage:] /warn [playerid/partofname] [reason]."); if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_LIGHTRED,"That player is not connected."); if(Warns[playerid] >= 5) { format(string, sizeof(string), "AdmCmd: %s was banned by %s. Reason: 5 warnings.", GetName(playerid), GetName(id)); SendClientMessageToAll(COLOR_LIGHTRED, string); GetPlayerIp(id,plrIP, sizeof(plrIP)); SendClientMessage(id,COLOR_LIGHTRED,"|___________[BAN INFO]___________|"); format(string, sizeof(string), "Your name: %s.",GetName(id)); SendClientMessage(id, COLOR_LIGHTRED, string); format(string, sizeof(string), "Your IP: %s.",plrIP); SendClientMessage(id, COLOR_LIGHTRED, string); format(string, sizeof(string), "Banned by: %s.",GetName(playerid)); SendClientMessage(id, COLOR_LIGHTRED, string); SendClientMessage(id,COLOR_LIGHTRED,"Reason: 5 warnings."); SendClientMessage(id,COLOR_LIGHTRED,"|___________[BAN INFO]___________|"); SetTimerEx("UnsetBan", 500, 0, "i", id); } Warns[playerid] += 1; format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s", GetName(id), GetName(playerid), reason); SendClientMessageToAll(COLOR_LIGHTRED,string); return 1; }
[code]
This is the /warn in my script, maybe you can make it work on yours :/ |
COMMAND:warn(playerid,params[])
{
new Pid[MAX_PLAYER_NAME],reason[128],string[128],Pname[MAX_PLAYER_NAME],Aname[MAX_PLAYER_NAME];
SendAdminText(playerid, "/warn", params);
if(APlayerData[playerid][LoggedIn] != true) return 0; //check if the player has logged in
if(APlayerData[playerid][PlayerLevel] <= 1) return 0;
if(sscanf(params, "us[128]",Pid,reason)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /warn <PlayerToWarn> <Reason>");
if(!IsPlayerConnected(Pid)) return SendClientMessage(playerid,0xFF0000FF, "That player isn't online");
APlayerData[PlayerToWarn][Warnings]++;
GetPlayerName(playerid, Aname, sizeof(Aname));
format(string,sizeof(string),"You have been warned by %s %s (warnings %i/%i) . Reason: %s", AdminLevelName[APlayerData[playerid][PlayerLevel]], Aname,APlayerData[Pid][Warnings],AutoKickWarnings,reason);
SendClientMessage(Pid, 0x00FF00FF, string);
GetPlayerName(playerid, Pname, sizeof(Pname));
format(string,sizeof(string),"Administrator %s has warned %s(%d).(warnings %i/%i) Reason %s",Aname,Pname,Pid,APlayerData[Pid][Warnings],AutoKickWarnings,reason);
SendClientMessageToAll(0xFF0000FF, string);
if((APlayerData[Pid][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1))
{
Kick(Pid);
format(string, sizeof(string),"%s(%d) has been kicked from the server. Reason: %i/%i warns",Pname,Pid,AutoKickWarnings,AutoKickWarnings);
SendClientMessageToAll(0xFF0000FF, string);
}
return 1;
}