SA-MP Forums Archive
Need some idea for textlabel - 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: Need some idea for textlabel (/showthread.php?tid=611998)



Need some idea for textlabel - SamBum - 13.07.2016

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.


Re: Need some idea for textlabel - Mencent - 13.07.2016

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;




Re: Need some idea for textlabel - SamBum - 13.07.2016

#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 !!


Re: Need some idea for textlabel - Mencent - 13.07.2016

%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".


Re: Need some idea for textlabel - SamBum - 14.07.2016

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