Question about UI

Hello people of facepunch,

So i’ve been working on a UI which will be turned into more later

Pretty much I have this sofar

I wanna know what I can do to make the text in the lower part of the UI Better, the rest is fine it’s just there seems to be a lot of spacing and such, and it just doesn’t look well done in my opinion, was wondering what I can do to make it better? Help would be appreciated.

make the box height a little smaller so then move the text closer a bit then that will remove the gap

[editline]5th June 2014[/editline]

also i would keep white font color on the top as well

By the gap, I mainly mean the big gap inbetween for example

The -'s being spaces

then change width a little and still if you havent change the ‘Name’ to white.

[editline]5th June 2014[/editline]

or for the health use a bar instead of text

Another question I’ve been wondering if people seem to know, what would I use to get the name of the person I would be spectating at the very moment, same for health and stuff, how would I get the general information of people i’m spectating or w/e



But if I were to just put ply:Name() wouldn’t it detect my name rather then the person i’m spectating?

You’d have to specifiy what Name would mean. So it’d be like

 local Name = ply:Nick()

And yeah it will only show the one you spectate.

It depends how you are referencing the function. If you’re calling it on something that is referring to your player (LocalPlayer or the networked entity of your player) then Nick() will return yours, however if the player entity you are calling it on is available, you can use that to get the spectated players name.

So I have something like this

local ply = LocalPlayer()
local name = ply:Nick()

draw.SimpleText( name, "Deathrun_SmoothBig", ScrW() / 2, ScrH() - 115, Color( 255, 255, 255, 255 ), TEXT_ALIGN_CENTER )

It seems to be displaying my name though, how would I modify it to show the player I am spectating?

You’d need to replace the call to LocalPlayer() with the variable you have stored your spectated player in. So, I assume you have some way of knowing which player to look for correct? If you use one of the existing “player” library methods you likely have the player object itself. If not, you can do something like this;

  • A lazy but slow way;
  1. Grab all the players on the server with player.GetAll()
  2. Loop through that list and find the player you want to spectate.
  3. Call :Nick() on the player object.
  • A better, general way;
  1. Have some unique ID for the player (connection ID or uniqueID (SteamID? I’m not sure what this one is)).
  2. Call player.GetByID(int id) or player.GetByUniqueID(string id) to get the player object.
  3. Call :Nick() on that object.

Though if you already have something in place to spectate the player, you should have their player object at hand. Just replace LocalPlayer() with that.

The deathrun gamemode I’m using already has something in place to spectate the player, but I can’t find what I actually should be using. I have found a couple different lines for spectators which are as stated below

if ply:Team() == TEAM_SPECTATOR then
		if IsValid(ob) and ob == ply then
		if IsValid(targ) then
			ply:Spectate( ply._smode or OBS_MODE_CHASE )
			ply:SpectateEntity( targ )
		if IsValid(targ) then
			ply:Spectate( ply._smode or OBS_MODE_CHASE )
			ply:SpectateEntity( targ )
		local targ = ply:GetObserverTarget()
		if not IsValid(targ) or not targ:IsPlayer() then return end

		if not ply._smode or ply._smode == OBS_MODE_CHASE then
			ply._smode = OBS_MODE_IN_EYE
		elseif ply._smode == OBS_MODE_IN_EYE then
			ply._smode = OBS_MODE_CHASE

		ply:Spectate( ply._smode )
		ply:Spectate( OBS_MODE_ROAMING )

I have tried to use a couple of those functions to actually call the player name of which is being spectated, but I have no clue which I actually should be using…

Try Player:GetObserverTarget

I had actually given that a try, it seems to show more then just the name though, for example…

[Player 1][Lyerech]

Rather then that I just want it to display
How would I go about that?

Call :Nick() on the result of it.

Alright, I seemed to have figured everything out except for the usergroup, how would I find the usergroup and have it display? I currently have this.

	draw.SimpleText( ply:GetObserverTarget():Health() .. "%", "Deathrun_SmoothBig", ScrW() / 2 + 100, ScrH() - 69, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER )
	draw.SimpleText( "Owner", "Deathrun_SmoothBig", ScrW() / 2 + 80, ScrH() - 40, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER )

What admin mod, if any, are you running?

I’m running ULX at this current moment. I would assume it’s something to the effect of GetUserGroup but not sure exactly how it is done or handled or w/e.

Take the same thing you called :Nick() on, but instead of calling :Nick(), call :GetUserGroup()

If they don’t have a group they’re displayed as “user”. The first letter of any default group is lowercase. What I did was ply:GetUserGroup():gsub("^%l", string.upper), which capitalizes the first letter of the string.

Works, thanks for all the help. much appreciated