Mask is bugged O_O
#1

I was playing after a while while i was masked then i went to a player , he saw my nametag lol
pawn Код:
if(strcmp(cmd, "/mask", true) == 0)
    {
        if(PlayerInfo[playerid][pMember] != 8)
        {
            SendClientMessage(playerid, COLOR_GREY, "   You are not authorized to use that command !");
            return 1;
        }
        if(PlayerInfo[playerid][pMask] == 0)
        {
            PlayerInfo[playerid][pMask] = 1;
            foreach (Player, i)
            {
                if(IsPlayerConnected(i))
                {
                    ShowPlayerNameTagForPlayer(i, playerid, 0);
                }
            }
            strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
            format(string, sizeof(string), "* %s has put a mask on.", sendername);
            ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
        else if(PlayerInfo[playerid][pMask] == 1)
        {
            foreach (Player, i)
            {
                if(IsPlayerConnected(i))
                {
                    ShowPlayerNameTagForPlayer(i, playerid, 1);
                }
            }
            PlayerInfo[playerid][pMask] = 0;
            strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
            format(string, sizeof(string), "* %s has put their mask away.", sendername);
            ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
    }
Anything wrong? please fix it :X
Reply
#2

PHP код:
CMD:mask(playeridparams[])
{
    if(
pInfo[playerid][pLevel] == 0)  //If you don't want all player use it change this line 
    
if(isStranged[playerid] == 0//If your maks is put on
    
{
        new 
randomID random(200);
        new 
string[35];
        
isStranged[playerid] = true
        
GetPlayerName(playeridstringsizeof(string));
        
strmid(OldUsername[playerid], string0strlen(string), 64);
        
format(string,sizeof(string), "Stranger"randomID);
        
SetPlayerName(playeridstring);
        
SetPlayerAttachedObject(playerid1190372104.70.090900);//You can change this however you want, use sa-mp wiki for more info, right now is HockeyMask2
        
SendClientMessage(playeridCOLOR_WHITE"You have put on a mask! (/mask to romove it)");
        for(new 
0MAX_PLAYERSi++)
        {
            
ShowPlayerNameTagForPlayer(iplayerid0); // ShowPlayerNameTagForPlayer(i, playerid, 0) hide name for all players
        
}
    }
    else
    {
        
SetPlayerName(playeridOldUsername[playerid]);  // SetPlayerName back your Roleplay name
        
isStranged[playerid] = false// When is isStranged = false you speake normaly
        
SendClientMessage(playeridCOLOR_WHITE"You have removed your mask!"); // This is message what was send when you remove your mask
        
if(IsPlayerAttachedObjectSlotUsed(playerid1)) RemovePlayerAttachedObject(playerid1); // This line is for Object what we attached, when you write /mask this remove it.
        
for(new 0MAX_PLAYERSi++)
        {
            
ShowPlayerNameTagForPlayer(iplayerid1); // ShowPlayerNameTagForPlayer(i, playerid, 1) show name back.
        
}
    }
    return 
1;

Reply
#3

You hide the name tag for the connected players (plus you don't need to check if the player is connected - that's what foreach does in the first place: looping through connected players only) and if players connectsafter you used the command, they will be able to see your name tag.
Reply
#4

EDIT: you mean like this?

pawn Код:
if(strcmp(cmd, "/mask", true) == 0)
    {
        if(PlayerInfo[playerid][pMember] != 8)
        {
            SendClientMessage(playerid, COLOR_GREY, "   You are not authorized to use that command !");
            return 1;
        }
        if(PlayerInfo[playerid][pMask] == 0)
        {
            PlayerInfo[playerid][pMask] = 1;
            foreach (Player, i)
            {
                ShowPlayerNameTagForPlayer(i, playerid, 0); // Hides the nametag
            }
            strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
            format(string, sizeof(string), "* %s has put a mask on.", sendername);
            ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
        else if(PlayerInfo[playerid][pMask] == 1)
        {
            foreach (Player, i)
            {
                ShowPlayerNameTagForPlayer(i, playerid, 1);
            }
            PlayerInfo[playerid][pMask] = 0;
            strmid(sendername, PlayerRPName(playerid), 0, MAX_PLAYER_NAME);
            format(string, sizeof(string), "* %s has put their mask away.", sendername);
            ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
    }
Reply
#5

Thanks , fixed ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)