Raised This Month: $51 Target: $400
 12% 

[L4D2]How do I get text overlay on players/entities?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Morning
Member
Join Date: May 2021
Old 06-06-2023 , 10:48   [L4D2]How do I get text overlay on players/entities?
Reply With Quote #1

It's hard to describe the exact text I mean, but it's basically the same text as the player names that hover over your teammates in game. Not really part of the HUD so to speak, but dynamic text that follows a player as they move.

It's not the same as hint text or any panels, and it can appear in any colour. Can anyone point me to the function I need to use? I did much searching on this a while back and concluded it was impossible to do server-side, but I have seen it done somewhere else now (using sourcemod) so I know there is a solution. Thanks!

Last edited by Morning; 06-06-2023 at 10:49.
Morning is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 06-06-2023 , 13:41   Re: [L4D2]How do I get text overlay on players/entities?
Reply With Quote #2

player name is client side, but you can try something similar using "instructor hint"
__________________
Marttt is offline
Morning
Member
Join Date: May 2021
Old 06-06-2023 , 19:41   Re: [L4D2]How do I get text overlay on players/entities?
Reply With Quote #3

Yes, i'm using env_instructor_hint at the moment, but I want to parent it to the player and make it follow them as they move around the screen. I'm not sure how to do that. Here is my current code that displays text when aiming at a player on the opposite team:

Code:
#include <sourcemod>
#include <sdktools>

new Handle:hTimer[MAXPLAYERS+1] = INVALID_HANDLE;

public OnClientPostAdminCheck(client)
{
if(hTimer[client] == INVALID_HANDLE) hTimer[client] = CreateTimer(1.0, Timer, client, TIMER_REPEAT);
}

public OnClientDisconnect(client)
{
if (hTimer[client] != INVALID_HANDLE)
	{
        KillTimer(hTimer[client]);
	hTimer[client] = INVALID_HANDLE;
	}
}

public Action:Timer(Handle:timer, any:client)
{
if (IsClientInGame(client) && !IsFakeClient(client))
	{
	new target = GetClientAimTarget(client, true); 
	if(target < 1 || target > MaxClients || target == client) return Plugin_Continue;

	if(IsClientInGame(target) && IsPlayerAlive(target))
		{
		new client_team = GetClientTeam(client);
		new target_team = GetClientTeam(target);

		if (client_team != target_team)
			{
			char targetname[64];
			Format(targetname, 64, "%N", target);
			int entity = CreateEntityByName("env_instructor_hint");
                        char sInstructorHintTarget[64];
                        Format(sInstructorHintTarget, sizeof(sInstructorHintTarget), "hint%d", target);
                        DispatchKeyValue(client, "targetname", sInstructorHintTarget);
                        DispatchKeyValue(entity, "hint_target", sInstructorHintTarget);
                        DispatchKeyValue(entity, "hint_timeout", "15");
		        DispatchKeyValue(entity, "hint_static", "1");
		        DispatchKeyValue(entity, "hint_forcecaption", "1");
                        DispatchKeyValue(entity, "hint_caption", targetname);
                        DispatchKeyValue(entity, "hint_icon_onscreen", "icon_skull");
		        DispatchKeyValue(entity, "hint_icon_offset", "50.0")
		        DispatchKeyValue(entity, "hint_pulseoption", "0");
                        DispatchKeyValue(entity, "hint_color", "30 255 30");
                        DispatchSpawn(entity);
                        AcceptEntityInput(entity, "ShowHint", client);
                        SetVariantString("OnUser1 !self:Kill::6:1");
                        AcceptEntityInput(entity, "AddOutput");
                        AcceptEntityInput(entity, "FireUser1");
			}
		}
	}
}

Last edited by Morning; 06-06-2023 at 19:59.
Morning is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:49.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode