Need some idea for textlabel
#1

My Problem:
I update 3dtext label when player take damage, it will appear their real health, armour. But it delay the last update about their health, armour.
Example: When player have 100 health and 100 armour, and they got damage from some source (example it will take 10 damage). In fact 3d text label will appear player have 90 health. But in my script, It will appear 100 health, and if they continuous been attack again, It will appear 90 health (But in real, it's 80 health)
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
   	Delete3DTextLabel(masknamelabel[playerid]);
new string[128];
	if(PlayerInfo[playerid][pDangdeomask] == 1)
	{
		GetPlayerHealth(playerid, health);
		GetPlayerArmour(playerid, armour);
		masknamelabel[playerid] = Create3DTextLabel(" ",0x9ACD32AA,30.0,40.0,50.0,15.0,0);
		format(string,sizeof(string),"Nguoi la mat #%d\nMau: %d, Giap: %d", GetPlayerSQLId(playerid), floatround(health), floatround(armour));
		Update3DTextLabelText(masknamelabel[playerid], 0x9ACD32AA, string);
		Attach3DTextLabelToPlayer(masknamelabel[playerid], playerid, 0.0, 0.0, 0.4);
	}
	return 1;
}
I have put this script onto OnPlayerUpdate, but the problem is the 3dtextlabel is spamming, more time people more lagger.
Reply
#2

Hello!

Solution for problem 1:
PHP код:
public OnPlayerConnect(playerid)
{
    new 
Float:healthFloat:armour;
    
GetPlayerHealth(playeridhealth);
    
GetPlayerArmour(playeridarmour);
    if(
PlayerInfo[playerid][pDangdeomask] == 1)
     {
         new 
string[128];
           
masknamelabel[playerid] = Create3DTextLabel(" ",0x9ACD32AA,30.0,40.0,50.0,15.0,0);
        
format(string,sizeof(string),"Stranger #%d\nHealth: %f, Armour: %f"GetPlayerSQLId(playerid), health,armour);
        
Update3DTextLabelText(masknamelabel[playerid], 0x9ACD32AAstring);
        
Attach3DTextLabelToPlayer(masknamelabel[playerid], playerid0.00.00.4);
    }
    return 
1;

Reply
#3

#Mencent thank you so much for reply my post, I have worked with %s %d before, But I haven't ever work with %f, I will try to practice more about this. Thank for your suggestion !!
Reply
#4

%s is for strings (letters and other characters)
%i and %d is for integers ( only numbers, like this: 1 or 114 )
%f is for floats ( numbers with "points", like this: 1.4 or 114.98 )

These are the main "symbols".
Reply
#5

Quote:
Originally Posted by Mencent
Посмотреть сообщение
%s is for strings (letters and other characters)
%i and %d is for integers ( only numbers, like this: 1 or 114 )
%f is for floats ( numbers with "points", like this: 1.4 or 114.98 )

These are the main "symbols".
thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)