SA-MP Forums Archive
question about 3d attach - 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: question about 3d attach (/showthread.php?tid=649283)



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(playeridissueridFloatamountweaponidbodypart)
{
    if(
issuerid != INVALID_PLAYER_ID// If not self-inflicted
    
{
        new
            
infoString[128],
            
victimName[MAX_PLAYER_NAME],
            
attackerName[MAX_PLAYER_NAME];
        
GetPlayerName(playeridvictimNamesizeof (victimName));
        
GetPlayerName(issueridattackerNamesizeof (attackerName));
        new 
str[30];
        new 
Float:health;
        
        
format(strsizeof(str), "-%.0f HP\n%d HP Left"amountGetPlayerHealth(issueridhealth));
        new 
Text3D:HealthLabel =  Create3DTextLabel(infoString0x00AE00FF0,0020.001);
        
Attach3DTextLabelToPlayer(HealthLabelissuerid0.00.02.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(playeridissueridFloatamountweaponidbodypart)
{
    new 
string[50], playername[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayernamesizeof(playername));
    if(
playerid != INVALID_PLAYER_ID && issuerid != INVALID_PLAYER_ID)
    {
        
SetTimerEx("DamageString"10false"i"issuerid);
        
format(stringsizeof(string), "{800000}-%.0f damage by {800000}%s"amountplayername(issuerid));
        
SetPlayerChatBubble(playeridstringCOLOR_GREY60.03000);
    }
    return 
1;




Re: question about 3d attach - Mugala - 06.02.2018

use ChatBubbles, it's much easier.