SA-MP Forums Archive
Attach3DTextLabelToPlayer HP update? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Attach3DTextLabelToPlayer HP update? (/showthread.php?tid=454703)



Attach3DTextLabelToPlayer HP update? - RALL0 - 30.07.2013

How can I update a Attach3DTextLabelToPlayer with players health?


Re: Attach3DTextLabelToPlayer HP update? - wumpyc - 30.07.2013

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


Re: Attach3DTextLabelToPlayer HP update? - RajatPawar - 30.07.2013

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.


Re: Attach3DTextLabelToPlayer HP update? - RALL0 - 30.07.2013

Is it a global or a local variable?


Re: Attach3DTextLabelToPlayer HP update? - wumpyc - 30.07.2013

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


Re: Attach3DTextLabelToPlayer HP update? - thimo - 30.07.2013

It is global indeed and use what wumpyc said