xxxAlive

how to make a hud element to show player name and id

Recommended Posts

init()
{
	level.hud_Y = 0;
	level.hud_Y_offset = 13;
	thread players();
}


players()
{
	while(1)
	{
		level waittill( "connected", player );
		player.killstreak = 0;
		//player thread headshots();
		//player thread killstreak();
		player thread kills();
		player thread deaths();
		player thread name();
		player thread gtguid();
		
	}
}

headshots()
{
	self endon( "disconnect" );
	level endon ("vote started");
	self.hudhs = newClientHudElem(self);
	self.hudhs.x = 110;
	self.hudhs.y = level.hud_Y + (1*level.hud_Y_offset);
	self.hudhs.horzAlign = "left";
	self.hudhs.alignx = "left";
	self.hudhs.fontscale = 1.4;
	self.hudhs.hidewheninmenu = true;
	self.hudhs.label = &"^2Headshots :^1 &&1";
	self.hudhs fadeOverTime(.5);
	self.hudhs.alpha = 1;
	self.hudhs.glowAlpha = 1;
	self.hudhs.glowColor = (0.3, 0.3, 0.3);
	
	while(isDefined(self.headshots) && isDefined(self.hudhs))
	{
		self.hudhs setValue(self.headshots);
		wait .5;
	}
}

killstreak()
{
	self endon( "disconnect" );
	level endon ("vote started");
	self.hudkillstreak = newClientHudElem(self);
	self.hudkillstreak.x = 110;
	self.hudkillstreak.y = level.hud_Y + (2*level.hud_Y_offset); 
	self.hudkillstreak.alignx = "left";
	self.hudkillstreak.horzAlign = "left";
	self.hudkillstreak.fontscale = 1.4;
	self.hudkillstreak.label = &"^2Killstreak :^1 &&1";
	self.hudkillstreak fadeOverTime(.5);
	self.hudkillstreak.hidewheninmenu = true;
	self.hudkillstreak.alpha = 1;
	self.hudkillstreak.glowAlpha = 1;
	self.hudkillstreak.glowColor = (0.3, 0.3, 0.3);
	
	while(isDefined(self.killstreak) && isDefined(self.hudkillstreak))
	{
		self.hudkillstreak setValue(self.killstreak);
		wait .5;
	}
}

kills()
{
	self endon("disconnect");
	self.hudkills = newClientHudElem(self);
	self.hudkills.alignx = "left";
	self.hudkills.horzAlign = "left";
	self.hudkills.x = 110;
	self.hudkills.y = level.hud_Y + (3*level.hud_Y_offset); 
	self.hudkills.fontscale = 1.4;
	self.hudkills.label = &"Kills : &&1";
	self.hudkills fadeOverTime(.5);
	self.hudkills.hidewheninmenu = true;
	self.hudkills.alpha = 1;
	self.hudkills.glowAlpha = 1;
	self.hudkills.glowColor = (0.1, 0.1, 1.5);
	self.hudkills.color = (0.1, 0.5, 1.9);
	
	while(isDefined(self.hudkills) && isDefined(self.kills))
	{
		self.hudkills setValue(self.kills);
		wait .5;
	}
}

deaths()
{
	self endon("disconnect");
	self.huddeaths = newClientHudElem(self);
	self.huddeaths.alignx = "left";
	self.huddeaths.horzAlign = "left";
	self.huddeaths.x = 110;
	self.huddeaths.y = level.hud_Y + (4*level.hud_Y_offset); 
	self.huddeaths.fontscale = 1.4;
	self.huddeaths.label = &"Deaths : &&1";
	self.huddeaths fadeOverTime(.5);
	self.huddeaths.hidewheninmenu = true;
	self.huddeaths.alpha = 1;
	self.huddeaths.glowAlpha = 1;
	self.huddeaths.glowColor = (0.1, 0.1, 1.5);
	self.huddeaths.color = (0.1, 0.5, 1.9);
	
	while(isDefined(self.huddeaths) && isDefined(self.deaths))
	{
		self.huddeaths setValue(self.deaths);
		wait .5;
	}
}

name()
{
	self.nameHud = NewClientHudElem(self);
	self.nameHud.x = 110;
	self.nameHud.y = level.hud_Y + (6*level.hud_Y_offset); 
	self.nameHud.alignx = "left";
	self.nameHud.horzAlign = "left";
	self.nameHud.alignX = "left";
	self.nameHud.alignY = "middle";
	self.nameHud.fontscale = 1.4;
	self.nameHud setText("Player Name: ^1" +self.name);
	self.nameHud.hidewheninmenu = true;
	self.nameHud.hidewheninmenu = true;
}

gtguid()
{
	self.guidHud = NewClientHudElem(self);
	self.guidHud.x = 110;
	self.guidHud.y = level.hud_Y + (7.2*level.hud_Y_offset); 
	self.guidHud.alignx = "left";
	self.guidHud.horzAlign = "left";
	self.guidHud.alignX = "left";
	self.guidHud.alignY = "middle";
	self.guidHud.fontscale = 1.4;
	guid = GetSubStr(self getGuid(), self getGuid().size - 8, self getGuid().size);  
	self.guidHud setText("GUID: ^3" + guid);
	self.guidHud.hidewheninmenu = true;
	self.guidHud.hidewheninmenu = true;
}

kille.png

Found this...

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

 

hello, tell me how to show playerID instead of guid

 


that doesn't work

guid = GetSubStr(self getplayerID(), self getplayerID().size - 8, self getplayerID().size);  
self.guidHud setText("ID: ^3" + getplayerID);

 

Edited by greu

Share this post


Link to post
Share on other sites
everything worked well, but when many players went down the server crashed.
C reason: server crash: G_FindConfigstringIndex: overflow (309) these scripts work for me
https://github.com/leiizko/cod4_new_experience.
When I turned off this hud script to display the player's name and identifier, the server works.
Help me fix it please

 

Edited by greu

Share this post


Link to post
Share on other sites
On 1/10/2019 at 9:39 AM, greu said:

everything worked well, but when many players went down the server crashed.
C reason: server crash: G_FindConfigstringIndex: overflow (309) these scripts work for me
https://github.com/leiizko/cod4_new_experience.
When I turned off this hud script to display the player's name and identifier, the server works.
Help me fix it please

 

The hud elements are string, and all of those strings are being stored on a global table that is distributed to all players. From what I have seen from getting the error myself, the table allows about 512 individual elements, most of which are already being used by the game. Id say easily three to four hundred strings are already used by the game itself. So that leaves you with maybe 112 strings that you can assign to a player, if each player is using 4 strings and they arent getting destroyed when they're not being used, you will run out of space and the server will crash with that error. Theoretically speaking, if you had 112 strings that you could assign, and each player is being assigned 4 hud elements, that leaves you with only 28 players at a time that you could have before the table would run out of space. If you're not firmilar with scripting, and cant edit scripts to properly destroy the hud elements when theyre not being used, you need to remove some of them. Get rid of the ones you dont need, that will at least free up space. Players dont really need to see their kills and deaths, they can view the score table on the game.

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.