[Solved] Creating a tag above player names.
#1

My idea is to have an afk command, and using one of the new features ( create3dtextlabel )
It will place "afk" above their heads.
.


Here's what I have so far.

I am asking for help because I don't understand the syntax of the function.
I placed 0s mostly, in hopes that it would work.

pawn Код:
if(strcmp(cmd, "/afk", true) == 0) {
      new afk;
      Create3DTextLabel(afk, 0xFFFF00FF, 0, 0, 0, 100, 0, 0);
      Attach3DTextLabelToPlayer(afk, playerid, 0, 0, 0, 0);
    return 1;
    }
What's the correct way to do this?
Reply
#2

Try...

pawn Код:
if(strcmp(cmd, "/afk", true) == 0) {
      new Text3D:afk;
      afk= Create3DTextLabel("afk", 0xFFFF00FF, 0, 0, 0, 100, 0, 0);
      Attach3DTextLabelToPlayer(afk, playerid, 0, 0, 0, 0);
    return 1;
    }
Reply
#3

Quote:
Originally Posted by Mr.Z
Try...

pawn Код:
if(strcmp(cmd, "/afk", true) == 0) {
      new afk = Create3DTextLabel("afk", 0xFFFF00FF, 0, 0, 0, 100, 0, 0);
      Attach3DTextLabelToPlayer(afk, playerid, 0, 0, 0, 0);
    return 1;
    }
Ah, now this is what I thought.

But I receive these warnings, (probably nothing...)
Quote:

(29)warning 213: tag mismatch
(30)warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Warnings.


Reply
#4

Quote:
Originally Posted by Ace_Menace
Quote:
Originally Posted by Mr.Z
Try...

pawn Код:
if(strcmp(cmd, "/afk", true) == 0) {
      new afk = Create3DTextLabel("afk", 0xFFFF00FF, 0, 0, 0, 100, 0, 0);
      Attach3DTextLabelToPlayer(afk, playerid, 0, 0, 0, 0);
    return 1;
    }
Ah, now this is what I thought.

But I receive these warnings, (probably nothing...)
Quote:

(29)warning 213: tag mismatch
(30)warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Warnings.


Firstly: What's on line 29 and 30? (See edit at the bottom of the post)
Secondly: Change Attach3DTextLabelToPlayer to this - Attach3DTextLabelToPlayer(afk, playerid, 0, 0, 0, 0.7); This will make the label appear above the name tag rather than at the level of the player, you can change the 0.7 part to get the desired position but remember that 1.0 is a fairly large step, you can also go in the negatives I believe.

Edit: Sorry, didn't read the code well enough. What you need to do is change the line that says-
new afk = Create3DTextLabel("afk", 0xFFFF00FF, 0, 0, 0, 100, 0, 0);

into this-

new Text3D:afk = Create3DTextLabel("afk", 0xFFFF00FF, 0, 0, 0, 100, 0, 0);
Reply
#5

Quote:
Originally Posted by Dresden
Quote:
Originally Posted by Ace_Menace
Quote:
Originally Posted by Mr.Z
Try...

pawn Код:
if(strcmp(cmd, "/afk", true) == 0) {
      new afk = Create3DTextLabel("afk", 0xFFFF00FF, 0, 0, 0, 100, 0, 0);
      Attach3DTextLabelToPlayer(afk, playerid, 0, 0, 0, 0);
    return 1;
    }
Ah, now this is what I thought.

But I receive these warnings, (probably nothing...)
Quote:

(29)warning 213: tag mismatch
(30)warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


2 Warnings.


Firstly: What's on line 29 and 30? (See edit at the bottom of the post)
Secondly: Change Attach3DTextLabelToPlayer to this - Attach3DTextLabelToPlayer(afk, playerid, 0, 0, 0, 0.7); This will make the label appear above the name tag rather than at the level of the player, you can change the 0.7 part to get the desired position but remember that 1.0 is a fairly large step, you can also go in the negatives I believe.

Edit: Sorry, didn't read the code well enough. What you need to do is change the line that says-
new afk = Create3DTextLabel("afk", 0xFFFF00FF, 0, 0, 0, 100, 0, 0);

into this-

new Text3D:afk = Create3DTextLabel("afk", 0xFFFF00FF, 0, 0, 0, 100, 0, 0);
Thanks, this information should be added to the wiki.
Reply
#6

You will need something more.. When the player returns Text3D it should be deleted, and for that we will need ID, therefore it tries the following:

In the top
pawn Код:
new Text3D: Label_AFK[MAX_PLAYERS];
In OnPlayerConnect
pawn Код:
Label_AFK[playerid]=INVALID_3DTEXT_ID;
In OnPlayerDisconnect
pawn Код:
if(Label_AFK[playerid]!=INVALID_3DTEXT_ID) Delete3DTextLabel(Label_AFK[playerid]);
In Command /afk
pawn Код:
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
Label_AFK[playerid]=Create3DTextLabel("afk", 0xFFFF00FF, x, y, z+1, 100, 0, 0),Attach3DTextLabelToPlayer(Label_AFK[playerid], playerid, 0, 0, 0, 0);
In Command /iamback
pawn Код:
Delete3DTextLabel(Label_AFK[playerid]);
I hope gives right
Reply
#7

Why can't I see the Label myself?





Quote:
Originally Posted by Mr.Z
You will need something more.. When the player returns Text3D it should be deleted, and for that we will need ID, therefore it tries the following:

In the top
pawn Код:
new Text3D: Label_AFK[MAX_PLAYERS];
In OnPlayerConnect
pawn Код:
Label_AFK[playerid]=INVALID_3DTEXT_ID;
In OnPlayerDisconnect
pawn Код:
if(Label_AFK[playerid]!=INVALID_3DTEXT_ID) Delete3DTextLabel(Label_AFK[playerid]);
In Command /afk
pawn Код:
new Float:x,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
Label_AFK[playerid]=Create3DTextLabel("afk", 0xFFFF00FF, x, y, z+1, 100, 0, 0),Attach3DTextLabelToPlayer(Label_AFK[playerid], playerid, 0, 0, 0, 0);
In Command /iamback
pawn Код:
Delete3DTextLabel(Label_AFK[playerid]);
I hope gives right
Reply
#8

Quote:
Originally Posted by Ace_Menace
Why can't I see the Label myself?
When you attach a 3D text label to a player it seems to do that, other people can see it though.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)