Jump to content

? servers

? players online

Showname plugin

Recommended Posts


  • Content Count:  1534
  • Joined:  07/27/09
  • Status:  Offline

I made a showname plugin using the new game_text feature recently added to sourcemod (requires the latest stable build)

 

How does it work? Hold E / Use key or Shift / Walk key and whoever is in your crosshairs the name will be displayed in game_text.

 

@Punky is also working on a fancy version that should come soon.

 

Download:

showplayername.smx

 

 

#pragma semicolon 1
#pragma newdecls required

#include 
#include 
//#include 

#define PLUGIN_NAME 	"Show Player Name"
#define PLUGIN_VERSION 	"1.0"

Handle g_HSync;
float g_fCmdTime[MAXPLAYERS + 1];

public Plugin myinfo = {
name = PLUGIN_NAME,
author = "Wesker",
description = "Show name in game text",
version = PLUGIN_VERSION,
url = "http://steam-gamers.net/"
};

public void OnPluginStart()
{
CreateConVar("sm_showplayername", PLUGIN_VERSION, "Show nickname", FCVAR_SPONLY | FCVAR_DONTRECORD | FCVAR_NOTIFY);

g_HSync = CreateHudSynchronizer();
}

public void OnMapEnd()
{
if (g_HSync != INVALID_HANDLE)
{
	CloseHandle(g_HSync);
	g_HSync = INVALID_HANDLE;
}
}

public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
if (!IsPlayerAlive(client))
{
	//Client is in spec
	return Plugin_Continue;
}

if ((buttons & IN_USE) || (buttons & IN_WALK)) {
	//Holding Use or Walk key
	if (g_fCmdTime[client] 			//Delay next call for optimization
		g_fCmdTime[client] = GetGameTime() + 0.3; //Wait
		int target = GetClientAimTarget(client, true);
		if (IsValidClient(target)) {
			ShowTargetName(client, target);
		}
	}
}

return Plugin_Continue;
}

public void OnClientPostAdminCheck(int client)
{
g_fCmdTime[client] = 0.0;
}

stock bool IsValidClient(int client) {
if ((client  MaxClients)) {
	return false;
}
if (!IsClientInGame(client)) {
	return false;
}
if (!IsPlayerAlive(client)) {
	return false;
}
return true;
}

stock void ShowTargetName(int client, int target)
{
SetHudTextParams(-1.0, 0.6, 3.0, 255, 255, 255, 255, 0, 0.25, 0.1, 0.1);
ClearSyncHud(client, g_HSync);
ShowSyncHudText(client, g_HSync, "%N", target);
}

 

Edited by Wesker
Link to comment

  • Content Count:  1534
  • Joined:  07/27/09
  • Status:  Offline

Uhh I'm adding Punky's version because I like it a lot and I don't see the point of having two different plugins that both have the same purpose

 

I was under the impression that it was a WIP, is it already uploaded?

Link to comment

  • Content Count:  6759
  • Joined:  06/23/13
  • Status:  Offline

I was under the impression that it was a WIP, is it already uploaded?

 

Still WIP but when I saw the screenshots I said immediately said yes to adding his version. I'm not sure how much more needs to be done but it's dope @Punky confirm ETA pls

Link to comment

  • Content Count:  1592
  • Joined:  03/16/12
  • Status:  Offline

Still WIP but when I saw the screenshots I said immediately said yes to adding his version. I'm not sure how much more needs to be done but it's dope @Punky confirm ETA pls

 

the v1 should be ready by tomorrow if everything goes well.

  • Like 6
Link to comment

  • Content Count:  3052
  • Joined:  08/30/09
  • Status:  Offline

Still WIP but when I saw the screenshots I said immediately said yes to adding his version. I'm not sure how much more needs to be done but it's dope @Punky confirm ETA pls

 

the v1 should be ready by tomorrow if everything goes well.

 

Will need to shutdown the server to do the sourcemod update. I plan on doing this tomorrow morning before work, so around 5am when the server should be empty

  • Like 2
Link to comment

Reply to Thread

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...