Attach3DTextLabelToPlayer HP update?
#1

How can I update a Attach3DTextLabelToPlayer with players health?
Reply
#2

For example:
Код:
    
    new Float:health,Text3D:label = Create3DTextLabel(GetPlayerHealth(playerid,health), 0x008080FF, 30.0, 40.0, 50.0, 40.0, 0);
    Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.7);
Haven't tested it so not sure if it works. Let me know
Reply
#3

pawn Код:
new Float:_health; GetPlayerHealth(playerid, _health);

new Text3D: _label = Create3DTextLabel(valstr(floatround(_health)), COLOR, 0.0, 30.0, 40.0, 50.0, 40.0, 0);
Attach3DTextLabelToPlayer(_label, playerid, 0.0, 0.0, 0.7);

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
    {
          new Float:_health; GetPlayerHealth(playerid, _health);
            Update3DTextLabelText(_label, COLOR, valstr(_health));
....
There is much to be optimised/Added/deleted, but this is the basic idea.
Reply
#4

Is it a global or a local variable?
Reply
#5

Quote:
Originally Posted by RALL0
Посмотреть сообщение
Is it a global or a local variable?
I believe it's global, but add [playerid] and define it as [MAX_PLAYERS] and you shouldn't have problems
Reply
#6

It is global indeed and use what wumpyc said
Reply


Forum Jump:


Users browsing this thread: