3D Text Above players head if hes under level 4
#1

Hello there!
I would like to have players who are under level 4 have a 3DTextLabel above their head with...
But Im having trouble creating it since im very new to this can anyone give me a little push in the right direction?
Reply
#2

What's your variable for levels?

or are you just using score?
Reply
#3

the variable should be pLevel
Reply
#4

Код:
public OnPlayerConnect 
{
    for(new i = 0; i < MAX_PLAYERS; i++);
    if(pLevel[i] < 5);
    {
         new Text3D:label = Create3DTextLabel("I am a newbie. (Level: %s) ",pLevel[i] , 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
         Attach3DTextLabelToPlayer(label, i, 0.0, 0.0, 0.7);
         return 1;
    } 
return 1;
}
https://sampwiki.blast.hk/wiki/Attach3DTextLabelToPlayer
Something like that (made on phone so expect mistakes)
Reply
#5

There are some mistakes with that, use it like this:
pawn Код:
new Text3D:ScoreLabel[MAX_PLAYERS]; // It should be a global array, so we can destroy it again
public OnPlayerConnect(playerid) // You need the playerid-parameter
{
    // Why use a loop? That would just create more and more labels when someone connects
    if(pLevel[playerid] < 5) // If-statements cannot have semicolons
    {
        new string[24];
        format(string, sizeof(string), "I am newbie. (Level: %i)", pLevel[playerid]); // You need to format the string, and you also need to use an integer, not string for the level
        ScoreLabel[playerid] = CreateDynamic3DTextLabel(string, 0x008080FF, 30.0, 40.0, 50.0, 40.0, playerid);
        // No need for 2 returns
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    DestroyDynamic3DTextLabel(ScoreLabel[playerid]); // Destroys the 3DTextLabel
}
With Streamer, it can easily bug out if you don't use dynamic labels.
But whenever you give some player score, you should check if his score goes over 4, and destroy the text label, like:
pawn Код:
if(pLevel[playerid] > 4) DestroyDynamic3DTextLabel(ScoreLabel[playerid]);
Reply
#6

First of all thank you very much for your help. But now im getting this reply when i want to Compile:

Код:
(24551) : error 028: invalid subscript (not an array or too many subscripts): "pLevel"
(24551) : warning 215: expression has no effect
(24551) : error 001: expected token: ";", but found "]"
(24551) : error 029: invalid expression, assumed zero
(24551) : fatal error 107: too many error messages on one line
Line 24551:

Код:
if(pLevel[playerid] < 5) // If-statements cannot have semicolons
Reply
#7

Then you aren't using pLevel, show where you declare it, or use GetPlayerScore(playerid) instead.
Reply
#8

Doesnt seem to be pLevel then lol, cant find it now but I was sure i defined it as that... I will have to look into it later when Im back
Reply
#9

Checked it now, it is pLevel I am using it for the /levelup command....
Reply
#10

Can you show your /levelup command then, or just where you use pLevel?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)