[Tutorial] How to create a mask system capable for Roleplay Servers using ZCMD
#1

To earlier mention, this tutorial is for intermedate pawn scripters.

Mask System


The Mask System is usually used to hide the player's name if he's planing to make a single / mass - murder or something else, if he wishes to hide his identity from others. It'll remove his nametag + hide his name from the chat.

Alright, so, let's begin.

pawn Код:
#include <zcmd>
- This will read from the include file named ZCMD, used for command processing.

pawn Код:
new Masked[MAX_PLAYERS];
- This makes the variable which'll be allowing the command to recognise if the player has his mask on or off. Let's go forward.

pawn Код:
stock ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    new Float:posx, Float:posy, Float:posz;
    new Float:oldposx, Float:oldposy, Float:oldposz;
    new Float:tempposx, Float:tempposy, Float:tempposz;
    GetPlayerPos(playerid, oldposx, oldposy, oldposz);
    for(new i = 0; i < GetMaxPlayers(); i++)
    {
        GetPlayerPos(i, posx, posy, posz);
        tempposx = (oldposx -posx);
        tempposy = (oldposy -posy);
        tempposz = (oldposz -posz);
        if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16))) SendClientMessage(i, col1, string);
        else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8))) SendClientMessage(i, col2, string);
        else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4))) SendClientMessage(i, col3, string);
        else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2))) SendClientMessage(i, col4, string);
        else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi))) SendClientMessage(i, col5, string);
    }
    return 1;
}
- This is a function for sending area message.

pawn Код:
public OnPlayerConnect(playerid)
{
     Masked[playerid] = 0;
     return 1;
}
- This function is to set the masked variable to 0, so that when a player connects it won't make a mistake to count him as masked when he is not.

pawn Код:
CMD:mask(playerid, params[])
{
     if(Masked[playerid] == 0)
     {
          foreach(Player,i)
          {
               ShowPlayerNameTagForPlayer(playerid, i, 0);
          }
          SendClientMessage(playerid, 0xFFFFFFAA , " You have put your mask on!");
          Masked[playerid] = 1;
     }
     else
     {
          foreach(Player, i)
          {
               ShowPlayerNameTagForPlayer(playerid, i, 1);
          }
          SendClientMessage(playerid, 0xFFFFFFAA, " You have taken your mask off!");
          Masked[playerid] = 0;
     }
     return 1;
}
- This is the code for the command to put / take your mask on/off.

And now the final part!

pawn Код:
public OnPlayerText(playerid, text[])
{
     new string[256], pname[MAX_PLAYER_NAME];
     GetPlayerName(playerid, pname, sizeof(pname));
     if(Masked[playerid] == 1)
     {
          format(string, sizeof(string), "Stranger says: %s", text);
          ProxDetector(30.0, playerid,string,0xE6E6E6E6,0xC8C8C8C8,0xAAAAAAAA,0x8C8C8C8C,0x6E6E6E6E);
     }
     else
     {
          format(string, sizeof(string), "%s says: %s", pname, text);
          ProxDetector(30.0, playerid,string,0xE6E6E6E6,0xC8C8C8C8,0xAAAAAAAA,0x8C8C8C8C,0x6E6E6E6E);
     }
     return 0;
}
- This is the function which sends the message typed in the chatbox.

I hope I've helped the players which're in need of such a system!


ZCMD - DOWNLOAD
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)