Above Head Tag For Admins.
#1

Hey there, I created tag system for admin in which they can toggle their admin tag above thier head with a command ie /tog admtag. It should work by hiding the players health bar armor bar and their names, and just show the tag which i created it worked fine but in a while after toggling it on and off for some couple of times i found a problem it sometime shows both, the admin tag and players original tag ( ie ,health bar, armor , name)
My code is like this i expect help from you guys so i could fix it and it works in proper manner.
pawn Код:
else if(!strcmp(params, "admtag", true))
    {
        if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
        if(!AdminTag[playerid])
        {
            AdminTag[playerid] = 1;
            foreach(Player, i)
            {
                ShowPlayerNameTagForPlayer(i, playerid, 0);
            }
            format(string, sizeof(string), "{FF6347}UT-RP Administrator\n{FFFFFF}%s\n{2641FE}%s", RPN(playerid), RPALN(playerid));
            Attach3DTextLabelToPlayer(AdminText[playerid], playerid, 0, 0, 0.25);
            if(IsValidDynamic3DTextLabel(AdminText[playerid])) DestroyDynamic3DTextLabel(AdminText[playerid]);
            AdminText[playerid] = CreateDynamic3DTextLabel(string, COLOR_WHITE, 0, 0, -20, 25, playerid);
            Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, AdminText[playerid] , E_STREAMER_ATTACH_OFFSET_Z, 0.25);
            SendClientMessage(playerid, COLOR_GREEN, "You have toggled your Admin Head Tag on.");
        }
        else
        {
            AdminTag[playerid] = 0;
            foreach(Player, i)
            {
                ShowPlayerNameTagForPlayer(i, playerid, 0);
            }
            if(IsValidDynamic3DTextLabel(AdminText[playerid])) DestroyDynamic3DTextLabel(AdminText[playerid]);
            SendClientMessage(playerid, COLOR_DARKRED, "You have toggled your Admin Head Tag off.");
        }
    }
Thanks in advance.
Reply
#2

Why don't you use just this: https://sampwiki.blast.hk/wiki/SetPlayerChatBubble ? I think it would work better and more reliably.
Reply
#3

Quote:
Originally Posted by sekonoppa
Посмотреть сообщение
Why don't you use just this: https://sampwiki.blast.hk/wiki/SetPlayerChatBubble ? I think it would work better and more reliably.
Dont think you you've understood what i mean.
Reply
#4

Quote:
Originally Posted by sekonoppa
Посмотреть сообщение
Why don't you use just this: https://sampwiki.blast.hk/wiki/SetPlayerChatBubble ? I think it would work better and more reliably.
That's not what he's trying to achieve. The chat bubble displays a message above a player. What Imperor wants is for the admin to hide their name, health, and armour, and then show a text label instead.

@Imperor

When turning the "admin head tag" on, you attached the text label before creating it. You also had ShowPlayerNameTagForPlayer setting to disabled for everyone when turning off the "admin head tag" instead of re-enabling it. Give this edit a try and let me know if it works.

pawn Код:
else if(!strcmp(params, "admtag", true))
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(!AdminTag[playerid])
    {
        AdminTag[playerid] = 1;
        foreach(Player, i)
        {
            ShowPlayerNameTagForPlayer(i, playerid, 0);
        }
        format(string, sizeof(string), "{FF6347}UT-RP Administrator\n{FFFFFF}%s\n{2641FE}%s", RPN(playerid), RPALN(playerid));
        if(IsValidDynamic3DTextLabel(AdminText[playerid])) DestroyDynamic3DTextLabel(AdminText[playerid]);
        AdminText[playerid] = CreateDynamic3DTextLabel(string, COLOR_WHITE, 0, 0, -20, 25, playerid);
        Attach3DTextLabelToPlayer(AdminText[playerid], playerid, 0, 0, 0.25);
        Streamer_SetFloatData(STREAMER_TYPE_3D_TEXT_LABEL, AdminText[playerid] , E_STREAMER_ATTACH_OFFSET_Z, 0.25);
        SendClientMessage(playerid, COLOR_GREEN, "You have toggled your Admin Head Tag on.");
    }
    else
    {
        AdminTag[playerid] = 0;
        foreach(Player, i)
        {
            ShowPlayerNameTagForPlayer(i, playerid, 1);
        }
        if(IsValidDynamic3DTextLabel(AdminText[playerid])) DestroyDynamic3DTextLabel(AdminText[playerid]);
        SendClientMessage(playerid, COLOR_DARKRED, "You have toggled your Admin Head Tag off.");
    }
}
Reply
#5

So will this fix the issue of showing both tags?
Reply
#6

Quote:
Originally Posted by Imperor
Посмотреть сообщение
So will this fix the issue of showing both tags?
It should, as I don't see any further issues. Don't take my word for it though, test it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)