question about 3d attach
#1

How do I make a 3d attachement above player's head whenever they get hit so it says like

" -60 hp"
" 40 hp left"
Reply
#2

you could just use earch and find some ideas.

https://sampforum.blast.hk/showthread.php?tid=351329
Reply
#3

thats textdraw though
Reply
#4

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.
Reply
#5

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.
Reply
#6

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;

Reply
#7

use ChatBubbles, it's much easier.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)