PDA

View Full Version : Mask is bugged O_O


D3vin
05/05/2014, 06:56 PM
I was playing after a while while i was masked then i went to a player , he saw my nametag lol

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_PURPL E,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_PURPL E,COLOR_PURPLE);
}
}
Anything wrong? please fix it :X

GeasyW
05/05/2014, 06:59 PM
CMD:mask(playerid, params[])
{
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(playerid, string, sizeof(string));
strmid(OldUsername[playerid], string, 0, strlen(string), 64);
format(string,sizeof(string), "Stranger", randomID);
SetPlayerName(playerid, string);
SetPlayerAttachedObject(playerid, 1, 19037, 2, 10, 4.7, 0.0, 90, 90, 0);//You can change this however you want, use sa-mp wiki for more info, right now is HockeyMask2
SendClientMessage(playerid, COLOR_WHITE, "You have put on a mask! (/mask to romove it)");
for(new i = 0; i < MAX_PLAYERS; i++)
{
ShowPlayerNameTagForPlayer(i, playerid, 0); // ShowPlayerNameTagForPlayer(i, playerid, 0) hide name for all players
}
}
else
{
SetPlayerName(playerid, OldUsername[playerid]); // SetPlayerName back your Roleplay name
isStranged[playerid] = false; // When is isStranged = false you speake normaly
SendClientMessage(playerid, COLOR_WHITE, "You have removed your mask!"); // This is message what was send when you remove your mask
if(IsPlayerAttachedObjectSlotUsed(playerid, 1)) RemovePlayerAttachedObject(playerid, 1); // This line is for Object what we attached, when you write /mask this remove it.
for(new i = 0; i < MAX_PLAYERS; i++)
{
ShowPlayerNameTagForPlayer(i, playerid, 1); // ShowPlayerNameTagForPlayer(i, playerid, 1) show name back.
}
}
return 1;
}

Konstantinos
05/05/2014, 06:59 PM
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.

D3vin
05/05/2014, 07:02 PM
EDIT: you mean like this?


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_PURPL E,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_PURPL E,COLOR_PURPLE);
}
}

D3vin
05/05/2014, 08:14 PM
Thanks , fixed ^^