SA-MP Forums Archive
Create3DTextLabel - 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: Create3DTextLabel (/showthread.php?tid=292179)



Create3DTextLabel - KeeDee - 23.10.2011

Hello, with Create3DTextLabel i wanted to make a script that's it's show the health & armor number up our head can someone teach me how to do that? Example: Someone has half Health and up his head it's write something like 50.0 HP


Re: Create3DTextLabel - Kingunit - 23.10.2011

Click me


Re: Create3DTextLabel - KeeDee - 23.10.2011

Quote:
Originally Posted by Kingunit
View Post
Can i change this to Label?
Code:
	    new Float:shealth;
	    GetPlayerHealth(giveplayerid,shealth);
	    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
	    format(string, sizeof(string), "%s Health is: %.2f", giveplayer ,shealth);
	    SendClientMessage(playerid, COLOR_GRAD1, string);



Re: Create3DTextLabel - [L3th4l] - 23.10.2011

Here's a rough example:

pawn Code:
#include <a_samp>

new
    Text3D: gHPLabel[MAX_PLAYERS];

public OnFilterScriptInit()
{
    SetTimer("UpdateLabels", 1000, true);
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    gHPLabel[playerid] = Create3DTextLabel(" ", -1, 0.0, 0.0, 0.0, 20.0, GetPlayerVirtualWorld(playerid), true);
    Attach3DTextLabelToPlayer(gHPLabel[playerid], playerid, 0.0, 0.0, 0.8);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    Delete3DTextLabel(gHPLabel[playerid]);
    return 1;
}

forward UpdateLabels();
public UpdateLabels()
{
    for(new i = 0; i < MAX_PLAYERS; i++) //foreach(Player, i)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
            new
                iStr[30],
                Float: iHealth[2];

            GetPlayerHealth(i, iHealth[0]);
            GetPlayerArmour(i, iHealth[1]);

            format(iStr, sizeof(iStr), "Health: %.0f\nArmour: %.0f", iHealth[0], iHealth[1]);
            Update3DTextLabelText(gHPLabel[i], -1, iStr);
        }
    }
}



Re: Create3DTextLabel - KeeDee - 23.10.2011

Quote:
Originally Posted by [L3th4l]
View Post
Here's a rough example:

pawn Code:
#include <a_samp>

new
    Text3D: gHPLabel[MAX_PLAYERS];

public OnFilterScriptInit()
{
    SetTimer("UpdateLabels", 1000, true);
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

public OnPlayerConnect(playerid)
{
    gHPLabel[playerid] = Create3DTextLabel(" ", -1, 0.0, 0.0, 0.0, 20.0, GetPlayerVirtualWorld(playerid), true);
    Attach3DTextLabelToPlayer(gHPLabel[playerid], playerid, 0.0, 0.0, 0.8);
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    Delete3DTextLabel(gHPLabel[playerid]);
    return 1;
}

forward UpdateLabels();
public UpdateLabels()
{
    for(new i = 0; i < MAX_PLAYERS; i++) //foreach(Player, i)
    {
        if(IsPlayerConnected(i) && !IsPlayerNPC(i))
        {
            new
                iStr[30],
                Float: iHealth[2];

            GetPlayerHealth(i, iHealth[0]);
            GetPlayerArmour(i, iHealth[1]);

            format(iStr, sizeof(iStr), "Health: %.0f\nArmour: %.0f", iHealth[0], iHealth[1]);
            Update3DTextLabelText(gHPLabel[i], -1, iStr);
        }
    }
}
I'll try that.


Re: Create3DTextLabel - KeeDee - 23.10.2011

Quote:
Originally Posted by KeeDee
View Post
I'll try that.
Dosen't Working