SA-MP Forums Archive
/mask HP & Armour - 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: /mask HP & Armour (/showthread.php?tid=421633)



/mask HP & Armour - Young_M - 10.03.2013

I've scripted a mask command and I have a question

Quote:

public OnPlayerUpdate(playerid)
{
if(UsingMask[playerid]==1)
{
new string[124];
new Float:armour;
GetPlayerArmour(playerid, armour);
new Float:health;
GetPlayerHealth(playerid,health);
format(string,sizeof(string), "HP:%0.f Armour:%0.f",health ,armour );
new Text3D:label = Create3DTextLabel(string, COLOR_GREY, 30.0, 40.0, 45.0, 40.0, 0);
Attach3DTextLabelToPlayer(label, playerid, 0.0, 0.0, 0.1);
}
return 1;
}

It looks like this above a player: HP:100.0000000 Armour 100:0000000

How to change it to HP:100 Armour 100?


Re: /mask HP & Armour - Zio - 10.03.2013

%.0f or %d


AW: /mask HP & Armour - Young_M - 10.03.2013

thanks worked, but it gets bugged when someone looses help, you see it 2 times above the players name


Re: /mask HP & Armour - Zio - 10.03.2013

Quote:

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid != INVALID_PLAYER_ID)
{
new string[256];
new attacker[MAX_PLAYER_NAME];
GetPlayerName(issuerid, attacker, sizeof (attacker));
format(string, sizeof(string), "-%.0f From %s", amount,attacker);
SetPlayerChatBubble(playerid, string, COLOR_RED, 20.0, 3000);
}
return 1;
}

it? =)


AW: Re: /mask HP & Armour - Young_M - 10.03.2013

Quote:
Originally Posted by Zio
Посмотреть сообщение
it? =)
no

//Edit:

Quote:

public OnPlayerUpdate(playerid)
{
if(UsingMask[playerid]==1)
{
new string[124];
new Float:armour;
GetPlayerArmour(playerid, armour);
new Float:health;
GetPlayerHealth(playerid,health);
format(string,sizeof(string), "HP:%.2f Armour:%.2f",health ,armour );
label = Create3DTextLabel(string, COLOR_GREY, 30.0, 40.0, 45.0, 40.0, 0);
}
else
{
Delete3DTextLabel(label);
}
return 1;
}

Fixed it but the health/armour does not update at all it stays the same


Re: /mask HP & Armour - Zio - 10.03.2013

https://sampwiki.blast.hk/wiki/Update3DTextLabelText


AW: /mask HP & Armour - Young_M - 10.03.2013

Quote:

public OnPlayerUpdate(playerid)
{
if(UsingMask[playerid]==1)
{
new string[124];
new Float:armour;
GetPlayerArmour(playerid, armour);
new Float:health;
GetPlayerHealth(playerid,health);
format(string,sizeof(string), "HP:%.2f Armour:%.2f",health ,armour );
label = Create3DTextLabel(string, COLOR_GREY, 30.0, 40.0, 45.0, 40.0, 0);
Update3DTextLabelText(label, COLOR_GREY, string);
}
else
{
Delete3DTextLabel(label);
}
return 1;
}

nothing happens


Re: /mask HP & Armour - Threshold - 10.03.2013

Give this a shot:

pawn Код:
new Text3D:label[MAX_PLAYERS];
new isusinglabel[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
    if(UsingMask[playerid] == 1)
    {
        new string[124];
        new Float:armour;
        GetPlayerArmour(playerid, armour);
        new Float:health;
        GetPlayerHealth(playerid,health);
        format(string,sizeof(string), "HP:%0.f\nArmour:%0.f", health, armour);
        label[playerid] = Create3DTextLabel(string, COLOR_GREY, 30.0, 40.0, 45.0, 40.0, 0);
        Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.1);
        isusinglabel[playerid] = 1;
    }
    else
    {
        if(isusinglabel[playerid] != 0)
        {
            Delete3DTextLabel(label[playerid]);
            isusinglabel[playerid] = 0;
        }
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    isusinglabel[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(isusinglabel[playerid] != 0)
    {
        Delete3DTextLabel(label[playerid]);
        isusinglabel[playerid] = 0;
    }
    return 1;
}