[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
#2

Nice tutorial but must be explained. People might not know what's /mask
Reply
#3

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
Nice tutorial but must be explained. People might not know what's /mask
Edited, added the explenation of what is the command "/mask" for.
Reply
#4

Код:
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;
}
Where do i put this one ?
Reply
#5

What about onplayerstreamin ? If a new player joins they will see his nameplate and so will people who just streamed in for him.

@Neko just put it anywhere
Reply
#6

Quote:

@Neko just put it anywhere

Its not working on me ..
Reply
#7

Quote:
Originally Posted by NekoChan
Посмотреть сообщение
Код:
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;
}
Where do i put this one ?
Put it anywhere but not in an public or so. ProxDetector is an old and outdated function from gf to send messages to players that are in a specified range, in different colors dependent on how far they are away from the center of the range. With that in mind, you can just look it up in the GodFather script, although I strongly advise to not use it.

original ProxDetector:

Код:
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5);
Код:
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    if(IsPlayerConnected(playerid))
    {
        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);
        //radi = 2.0; //Trigger Radius
        foreach(Player, i) // or use: for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(!BigEar[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)))
                {
                    SendClientPlayerMessage(i, col2, string);
                }
                else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                {
                    SendClientPlayerMessage(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);
                }
            }
            else if(MeBigears == 0)
            {
                SendClientMessage(i, col1, string);
            }
            else
            {
                MeBigears = 0;
            }
        }
    }//not connected
    return 1;
}
Reply
#8

Well, to be honest, I use the stock -way ProxDetector because I haven't encountered any problems with it, plus it's way smaller on lines as a code.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)