question about 3d attach -
ivndosos - 06.02.2018
How do I make a 3d attachement above player's head whenever they get hit so it says like
" -60 hp"
" 40 hp left"
Re: question about 3d attach -
PepsiCola23 - 06.02.2018
you could just use earch and find some ideas.
https://sampforum.blast.hk/showthread.php?tid=351329
Re: question about 3d attach -
ivndosos - 06.02.2018
thats textdraw though
Re: question about 3d attach -
KayJ - 06.02.2018
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
https://sampwiki.blast.hk/wiki/Attach3DTextLabelToPlayer
PHP код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID) // If not self-inflicted
{
new
infoString[128],
victimName[MAX_PLAYER_NAME],
attackerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, victimName, sizeof (victimName));
GetPlayerName(issuerid, attackerName, sizeof (attackerName));
new str[30];
new Float:health;
format(str, sizeof(str), "-%.0f HP\n%d HP Left", amount, GetPlayerHealth(issuerid, health));
new Text3D:HealthLabel = Create3DTextLabel(infoString, 0x00AE00FF, 0,0, 0, 20.0, 0, 1);
Attach3DTextLabelToPlayer(HealthLabel, issuerid, 0.0, 0.0, 2.0);
}
return 1;
}
Untested, let me know if problem persists.
EDIT: I saw that this will not delete the 3Dlabel once created so what you can do is; add timer to delete it.
Re: question about 3d attach -
Sew_Sumi - 06.02.2018
Quote:
Originally Posted by KayJ
Untested, let me know if problem persists.
EDIT: I saw that this will not delete the 3Dlabel once created so what you can do is; add timer to delete it.
|
You don't use them like that... Use an array of 3dtexts for each player, and simply clear it so it's empty when you don't want things to show.
You're making a variable, which is one. One person gets shot, that variable will match their 3dtext. Another gets shot, that original text stays, the next person gets the ID for the text. The first text is now stuck on the original player, and if they get hit again it'll likely double up... Not duplicate, but the old values on the old text, and the new variable on the new text.
And this is also because you create a local variable, so in that callback at that time, the variable will exist, but in others, it won't. Hence why global array of text for each player is better.
Re: question about 3d attach -
solstice_ - 06.02.2018
Well i use chat bubble on my script because it's easier for me, if you want to try it out here is the code;
PHP код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
new string[50], playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
if(playerid != INVALID_PLAYER_ID && issuerid != INVALID_PLAYER_ID)
{
SetTimerEx("DamageString", 10, false, "i", issuerid);
format(string, sizeof(string), "{800000}-%.0f damage by {800000}%s", amount, playername(issuerid));
SetPlayerChatBubble(playerid, string, COLOR_GREY, 60.0, 3000);
}
return 1;
}
Re: question about 3d attach -
Mugala - 06.02.2018
use ChatBubbles, it's much easier.