Health and Armor Textdraw
#1

Hi, i cant find any Health and Armor Textdraw well. can anyone explain or make a tutorial or make 1 i dont know how to start but i got my idea how to make it.. the health and armor will use OnPlayerUpdate? :/ can anyone explain? how will i make it c'oz im going to make a Advance Weapon System.
Reply
#2

Well, personally to create textdraws I find it much easier to use Zamaroht's Textdraw Editor (You can find edited versions of this that allow you to also place sprites - just search the forums). You can create the textdraws how you would like, to show health/armor you can simply hide/show certain textdraws indicating the amount of health a player has (In my case, I used bars although you can show it however you would like).

And yes you can use OnPlayerUpdate, but this is called very frequently and could cause some lag. Your best option would be to create a timer, and check the health via that as you can define how often it is called.

Edit: To add on to the post below, without bumping the topic again, you could use foreach (Which would be more efficient) to loop through the players.
Reply
#3

Try something like:

pawn Код:
new
    timerHealth,
    Text: textdrawid[MAX_PLAYERS];

// OnGameModeInit
timerHealth = SetTimer("UpdateHealth", 1000, true); // A repeating timer each second

//On Player Connect
textdrawid[playerid] = TextDrawCreate(...);

TextDrawShowForPlayer(playerid, textdrawid[playerid]);

//On Player Disconnect
TextDrawHideForPlayer(playerid, textdrawid[playerid]);

forward UpdateHealth();
public UpdateHealth()
{
    new
        stringHealth[50],
        Float: health[2];

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i) || IsPlayerNPC(i)) // We don't update the health of players not connected and NPC's
            continue;

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

        format(stringHealth, sizeof(stringHealth), "Health: %.0f - Armour: %.0f", health[0], health[1]);
        TextDrawSetString(textdrawid[i], stringHealth);
    }
    return 1;
}
Just make your own textraw to fit your needs
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)