[Tutorial] Make A Simple Warning System
#1

pawn Code:
new WarnTimes[MAX_PLAYERS];
This Is Made To Get The Warning Times That The Player Had....

NOTE: I Will Explain How To Use in ZCMD, You Can Change It.....

pawn Code:
command(warn, playerid, params[])
{
    return 1;
}
This Is The Command

pawn Code:
command(warn, playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        return 1;
    }
}
Is Player Admin = RCON ADMIN, You Can Change It To Your Own Admin System....

pawn Code:
command(warn, playerid, params[])
{
    if(IsPlayerAdmin(playerid))
    {
        new i, reason[50];
        new name[50];
        new string[250];
        if(sscanf(params, "us[50]", i, reason)) SendClientMessage(playerid, BLANCO, "USAGE: /warn [id] [reason]");
        else if(i == INVALID_PLAYER_ID) SendClientMessage(playerid, ROJO, "Player is not connected!");
        else
       {
            return 1;
       }
    }
}
NOTE: You will need SSCANF Include Here
This Is Used To Give The USAGE and check if id is online


pawn Code:
GetPlayerName(i, name, sizeof(name));
if(playerid!=i)
{
playerid!=i is player can't warn his self

pawn Code:
if(WarnTimes[i]>=2)
                {
                    format(string, 256,"[AUTO-KICK]: %s[%d] Has Been Kicked From The Server, [3/3 Warnings]", name, i);
                    SendClientMessageToAll(AC, string);
                    SetPlayerHealth(i, 999999999);
                    SetPlayerInterior(i, 10);
                    SetPlayerPos(i,226.9807,111.1730,999.0156);
                    format(string, sizeof(string), "~W~You Have Been ~R~Kicked ~W~From The Server");
                    GameTextForPlayer(i ,string, 99999999999999999999999, 3);
                    Kick(i);
                }
here if player got 3 warning he gets auto kick if(WarnTimes[i]>=2, >more than


pawn Code:
else
                {
                    WarnTimes[i]+=1;
                    if(WarnTimes[i]==1)
                    {
                        format(string, 256,"[ADMIN-WARN]: You Have Received A Warning, Reason: %s, [1/3 Warnings]", reason);
                        SendClientMessage(i, AC, string);
                    }
                    else if(WarnTimes[i]==2)
                    {
                        format(string, 256,"[ADMIN-WARN]: You Have Received A Warning, Reason: %s, [2/3 Warnings]", reason);
                        SendClientMessage(i, AC, string);
                    }
                    format(string, 256,"[ADMIN-WARN]: %s[%d] Has Received A Warning, Reason: %s", name, i, reason);
                    SendClientMessageToAll(AC, string);
                    GameTextForPlayer(i,"~W~You Have Received A ~n~  ~R~Warning",5000,3);
                }
WarnTimes[i]+=1; to increase the warning times
else if(war......) is to send message for player 1/3 warning 2/3 etc....


pawn Code:
command(warn, playerid, params[])
{
    if(SInfo[playerid][pAdmin] >= 1)
    {
        new i, reason[50];
        new name[50];
        new string[250];
        if(sscanf(params, "us[50]", i, reason)) SendClientMessage(playerid, BLANCO, "USAGE: /warn [id] [reason]");
        else if(i == INVALID_PLAYER_ID) SendClientMessage(playerid, ROJO, "Player is not connected!");
        else
        {
            GetPlayerName(i, name, sizeof(name));
            if(playerid!=i)
            {
                if(WarnTimes[i]>=2)
                {
                    format(string, 256,"[AUTO-KICK]: %s[%d] Has Been Kicked From The Server, [3/3 Warnings]", name, i);
                    SendClientMessageToAll(AC, string);
                    SetPlayerHealth(i, 999999999);
                    SetPlayerInterior(i, 10);
                    SetPlayerPos(i,226.9807,111.1730,999.0156);
                    format(string, sizeof(string), "~W~You Have Been ~R~Kicked ~W~From The Server");
                    GameTextForPlayer(i ,string, 99999999999999999999999, 3);
                    Kick(i);
                }
                else
                {
                    WarnTimes[i]+=1;
                    if(WarnTimes[i]==1)
                    {
                        format(string, 256,"[ADMIN-WARN]: You Have Received A Warning, Reason: %s, [1/3 Warnings]", reason);
                        SendClientMessage(i, AC, string);
                    }
                    else if(WarnTimes[i]==2)
                    {
                        format(string, 256,"[ADMIN-WARN]: You Have Received A Warning, Reason: %s, [2/3 Warnings]", reason);
                        SendClientMessage(i, AC, string);
                    }
                    format(string, 256,"[ADMIN-WARN]: %s[%d] Has Received A Warning, Reason: %s", name, i, reason);
                    SendClientMessageToAll(AC, string);
                    GameTextForPlayer(i,"~W~You Have Received A ~n~  ~R~Warning",5000,3);
                }
            }
            else SendClientMessage(playerid, COLOR_RED, "You Can't Warn Your Self");
        }
    }
    else SendClientMessage(playerid, COLOR_RED, "[Command Not Found Use /cmds or /commands.!]");
    return 1;
}
IF THE TUTORIAL ISN'T GOOD, TELL ME TO MAKE SOME EDITS
Reply
#2

Nice and simple tut
Reply
#3

Explain more.
Reply
#4

Quote:
Originally Posted by gtakillerIV
View Post
Explain more.
^^

__


pawn Code:
new string[250];
Oh, don't do that. 128 is the limit.
Reply
#5

Quote:
Originally Posted by Dwane
View Post
^^

__


pawn Code:
new string[250];
Oh, don't do that. 128 is the limit.
what u mean?
Reply
#6

Limits
pawn Code:
Text I/O     128 cells (512 bytes)
It's just useless and you waste bytes when the limit is 128. It will never show a message with 250 chars.

- I'm not refering to textdraws or dialogs. Only messages.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)