/mask command
#1

Anyone has the /mask command? please send the codes here. i'd really appreciate if you help.
Reply
#2

Post what it should do
Reply
#3

Well, if youre writing /mask then you wont be able to see the name of the person above and in the chat. and if youre writing /mask again then it should go back to normal.
Reply
#4

Please anyone
Reply
#5

So /mask hides all player tags (name, id, health) and the chat messages?
Reply
#6

pawn Код:
#include <a_samp>
#include <zcmd>

new bool:pUsingMask[MAX_PLAYERS];

stock EnablePlayerName(playerid,bool:status) {
   for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(i, playerid, status)
   return true;
}

stock RetrievePlayerName(playerid) {
  new name[MAX_PLAYER_NAME];
  if(pUsingMask[playerid]) {
   format(name,sizeof(name),"Masked player");
  } else {
    GetPlayerName(playerid,name,sizeof(name));
  }
  return name;
}

CMD:mask(playerid,params[]) {
  if(pUsingMask[playerid]) {
    pUsingMask[playerid] = false;
    SendClientMessage(playerid,-1,"Mask disabled, all players will now see your name.");
    EnablePlayerName(playerid,true);
   } else {
    pUsingMask[playerid] = true;
    SendClientMessage(playerid,-1,"Mask enabled, all players won't see your name.");
    EnablePlayerName(playerid,false);
  }
  return true;
}

public OnPlayerConnect(playerid) {
  for(new i = 0; i < MAX_PLAYERS; i++) {
     ShowPlayerNameTag(playerid,i,pUsingMask[playerid]);
  }
  return true;
}

public OnPlayerText(playerid,text[]) {
  format(text,sizeof(text),"%s says: %s",RetrievePlayerName,text);
  SendClientMessageToAll(-1,text);
  return 0;
}
Made this in a few seconds.
If there is any error please contact me.

Little explanation:
I made a function which enables/disables player name tag.
For new players who connected later someone used /mask command, i sync them into the system, so they won't see your name if you're masked too.
I made another function which checks if you're masked or not, then the function is called when player speaks.
/mask checks if you're masked or not, and it will mask / unmask you automatically.
Reply
#7

Theres 26 errors and like 50 warnings.. But thanks anyway )
Reply
#8

Quote:
Originally Posted by CodyAlzack
Посмотреть сообщение
Theres 26 errors and like 50 warnings.. But thanks anyway )
In EnablePlayerName, there is a missing semicolon after:
pawn Код:
ShowPlayerNameTagForPlayer(i, playerid, status)
In ShowPlayerNameTag, replace "ShowPlayerNameTag" with "ShowPlayerNameTagForPlayer".

In OnPlayerText, replace "RetrievePlayerName" with "RetrievePlayerName(playerid)" and these 2 lines:
pawn Код:
format(text,sizeof(text),"%s says: %s",RetrievePlayerName(playerid),text);
SendClientMessageToAll(-1,text);
with:
pawn Код:
new msg[144];
format(msg,sizeof(msg),"%s says: %s",RetrievePlayerName(playerid),text);
SendClientMessageToAll(-1,msg);
The above will fix icra's mistakes. If you get any other error, it's because you added them wrong.
Reply
#9

This one compiles perfectly.
(I made is as a filterscript)

pawn Код:
#define FILTERSCRIPT

#include < a_samp >

new
    bool: pMask[ MAX_PLAYERS char ];
   
public OnPlayerConnect( playerid )
{
    pMask{ playerid } = false;
    // DEFAULT: Mask is off when you connect.
    return true;
}

public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if ( !strcmp( cmdtext, "/mask", true ) )
    {
        pMask{ playerid } = !pMask{ playerid };
        for ( new i, j = GetMaxPlayers( ); i < j; ++ i )
        {
            if ( !IsPlayerConnected( i ) )
                continue;
            ShowPlayerNameTagForPlayer( i, playerid, ( pMask{ playerid } ) ? ( 0 ) : ( 1 ) );
        }
        SendClientMessage( playerid, -1, ( pMask{ playerid } ) ? ( "[INFO]: Mask turned on." ) : ( "[INFO]: Mask turned off." ) );
        return 1;
    }
    return 0;
}

public OnPlayerText( playerid, text[ ] ) {
    new str[ 128 ], name[ 24 ];
    GetPlayerName( playerid, name, 24 );
    if ( pMask{ playerid } )
        format( str, 128, "Masked player says: %s", text );
    else
        format( str, 128, "%s (%d) says: %s", text );
    SendClientMessageToAll( -1, str );
    return 0; // Don't send text
}
Reply
#10

This is happening after http://imgur.com/Tj68bK8
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)