I will try it later.
The other purpose I had with it was to print variable messages to everyone (iprintln):
Code:
iprintln(&"BATTLEFIELD_MONSTERKILL", player);
Localized string:
Code:
REFERENCE MONSTERKILL
LANG_ENGLISH "&&1 ^7- ^1MONSTER KILL !!!"
LANG_GERMAN "#same"
LANG_RUSSIAN "#same"
Edit #1: I posted because it worked without the need of setplayernamestring(player). I copied the way it is on meatbot.
Edit #2: I tried izno's suggestion and it seems to be the best thing to do because (1) I only need 1 hud and (2) it is now perfectly centered. Thank you very much one again.
Just one small corretion, change
for
And here is the code for a simple hud for headshots.
1. You must create the localized string for the label:
Code:
REFERENCE HEADSHOT
LANG_ENGLISH "^7Headshot: ^1&&1 ^7m"
2. On player connect, set self.headshothudid to 0;
3. Call this function with the killer
PHP Code:
displayHeadshot(distance, duration)
{
self.headshothudid += 1;
hudid = self.headshothudid;
if(isdefined(self.headshothud))
{
self.headshothud destroy();
}
self.headshothud = newClientHudElem(self);
self.headshothud.vertAlign = "top";
self.headshothud.horzAlign = "center";
self.headshothud.alignx = "center";
self.headshothud.y = 120;
self.headshothud setValue(distance);
self.headshothud.label = &"FILENAME_HEADSHOT";
self.headshothud.fontScale = 1.4;
self.headshothud.alpha = 1;
self.headshothud.sort = 5000;
self.headshothud.color = (1, 1, 1);
wait(duration);
// if the player performed another headshot, there will be a new hud, which should not be affected/deleted by the old hud function
if(self.headshothudid == hudid)
{
self.headshothud fadeOverTime(1);
self.headshothud.alpha = 0;
wait(1);
if(self.headshothudid == hudid)
{
if(isdefined(self.headshothud))
{
self.headshothud destroy();
}
self.headshothudid = 0;
}
}
}
Where FILENAME is the name of your localized strings file; duration is the duration of the hud (not counting the 1 second for fading); and distance(in meters) can be given as
Code:
distance = int(((distance(attacker.origin , self.origin)) * 0.0254) + 0.5);
(the +0.5 is because int will round, for example, 3.7 to 3, and I'd rather have it rounding it to the nearest int)