Jump to content


TUTORIAL: Allow black names (includes adding a cvar)


Recommended Posts

Apparently people like me writing tutorials, so here's another one. o_o









What you will achieve

The purpose of this modification is to allow players to use a black color in their name.









Before we get started

I would like to point out, we will be adding a new cvar to the game.

Cvars are basically pairs of 'key' and 'value'. An example is 'fraglimit'

Key: fraglimit, Value: x

So typing '/fraglimit 60' will set the fraglimit to 60.

You can use cvars for all sorts of things, as you will see.









Files edited

- g_client.c (game)

- g_main.c (game)









Step 1

Open up g_client.c and search for the 'ClientCleanName' function


Before that function begins, we want to make sure it knows about our cvar we're going to create

Insert the following code before that function:

extern vmCvar_t g_allowBlackNames;


You might not understand why we put that line there until we've finished making our changes.









Step 2

There's already a part in ClientCleanName that checks for what colors are used, so we're just going to attach a check for our cvar there.



		if( ColorIndex(*in) == 0 ) {


Replace it with

		if( ColorIndex(*in) == 0 && !g_allowBlackNames.integer ) {









Step 3

From here on all we're doing is making the cvar work.


Open up g_main.c and scroll down a little bit to find a rather large list that looks like this.

vmCvar_t		debugNPCAimingBeam;
vmCvar_t		debugBreak;
vmCvar_t		debugNoRoam;
vmCvar_t		d_saberCombat;
vmCvar_t		d_JediAI;
vmCvar_t		d_noGroupAI;
vmCvar_t		d_asynchronousGroupAI;
vmCvar_t		d_slowmodeath;
vmCvar_t		d_noIntermissionWait;


The last one on the list is currently:

vmCvar_t		g_showDuelHealths;


What we want to do is create more of these so we can use them, right?

Just add the following code after 'g_showDuelHealths;'

vmCvar_t	g_allowBlackNames;		// Allow clients to use black names









Step 4

Almost done!

Now all we have to do is add our new cvar to the actual cvar table


Scroll down and you'll see a bunch of stuff like:

{ &g_speed, "g_speed", "200", 0, 0, qtrue  },
{ &g_gravity, "g_gravity", "800", 0, 0, qtrue  },
{ &g_knockback, "g_knockback", "1000", 0, 0, qtrue  },
{ &g_quadfactor, "g_quadfactor", "3", 0, 0, qtrue  },
{ &g_weaponRespawn, "g_weaponrespawn", "5", 0, 0, qtrue  },
{ &g_weaponTeamRespawn, "g_weaponTeamRespawn", "5", 0, 0, qtrue },


The last one on the table is currently:

{ &g_powerDuelEndHealth, "g_powerDuelEndHealth", "90", CVAR_ARCHIVE, 0, qtrue  },


What we want to do is create more of these so we can use them, right?

Just add the following code after that:

//Toggles allowance of black names
{ &g_allowBlackNames, "g_allowBlackNames", "1", CVAR_ARCHIVE, 0, qtrue },









You're done!

Now you can compile your code, and try it out!

type /name "^0My Black Name" to use black in your name.

To change whether or not clients can use black in their name, use 'g_allowBlackNames' as a key, and '0' or '1' as a value. (0 = don't allow, 1 = allow)










There are no bugs that I have discovered.





Other information

Feel free to contact me about any bugs/glitches/etc

Xfire: friedjawa101

Link to comment
Share on other sites

  • 1 year later...


There are no bugs that I have discovered.


At first i wrote my own code for black names as i didn't discover this, but kind of failed, then desided to use this, sure enough it works

but then the server crashes for some reason after the second kill.

This is for basejka, only thing i can think of is i AM using NeWaGe's sdk fix.

But as i remember i did do another mod prior to this "FunMod" and worked fine.

So i'm not quite sure.

But since i added this the server crashed twice which is a kind of a shame.



See if anything is found,




Edit: Nevermind, fixed it, my own error on another code lol

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...