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:
Code:
//[BlackNames]
extern vmCvar_t g_allowBlackNames;
//[/BlackNames]
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.
Original
Code:
if( ColorIndex(*in) == 0 ) {
Replace it with
Code:
//[BlackNames]
if( ColorIndex(*in) == 0 && !g_allowBlackNames.integer ) {
//[/BlackNames]
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.
Code:
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:
Code:
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;'
Code:
//[BlackNames]
vmCvar_t g_allowBlackNames; // Allow clients to use black names
//[/BlackNames]
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:
Code:
{ &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:
Code:
{ &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:
Code:
//[BlackNames]
//Toggles allowance of black names
{ &g_allowBlackNames, "g_allowBlackNames", "1", CVAR_ARCHIVE, 0, qtrue },
//[/BlackNames]
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)
!BUGS!
There are no bugs that I have discovered.
Other information
Feel free to contact me about any bugs/glitches/etc
Xfire: friedjawa101