Topic limit test
Select messages from # through # Forum FAQ
[/[Print]\]

Soldier Of Fortune 2 -> SOF2 Tutorials

#1: No icon Topic limit test Author: Punisher PostPosted: Wed Apr 01, 2015 5:24 pm
    —
SOF2MODDING Advanced tutorial – Adding Editable rank prefixes Part.1

In this tutorial im gonna show you how to make the rank prefixes editable, in for example your server config.
You should be a little bit familiar with the SDK of SOF2, setup successfully, and followed or atleast have something similar to Floo’s tutorial done.
I’ll be starting after the Tutorial of Floo by making the ranknames into a command line which you can edit in the server config.
I wont be using Images in this tutorial, only code example.

To Summerize Floo’s tutorial:
- Open g_cmd.c.
- Search G_SayTo by pressing ctrl + f in notepad and selecting the “ Search “ tab.
- When you did this you’ll probably see this:
/*
==================
G_SayTo
==================
*/

- Scroll down until you see:
else if ( ghost )
{
   type = "*ghost* ";
}
else if ( spec )
{
   type = "*spec* ";
}

- We will be duplicating this with the other ranks too:
else if ( ghost )
{
type = “^7*Ghost*”;
}
else if ( spec )
{
type = “^7*Spec*”;
}
else if ( ent->client->sess.modData->adminref == 2 )
{
type = “^7*Admin*”;
}
else if ( ent->client->sess.modData->adminref == 1 )
{
type = “^7*Referee*”;
}
else if ( ent->client->sess.modData->adminref == 3 )
{
type = “^7*Sysop*”;
}

else if ( ent->client )
{
type = “^7*Visitor*”;
}
else if ( ent->client->sess.modData->clan == 1 && ent->client->sess.modData->adminref <1>client->sess.modData->adminref == 2 )
{
type = “^7*Admin*”;
}

As you can see the type = “ Text ”; give you the text you see ingame.
This is the part we are going to edit.
Now use the commands you made, so in my case :

vmCvar_t pref_admin;
vmCvar_t pref_ref;
vmCvar_t pref_sysop;
vmCvar_t pref_coldr;
vmCvar_t pref_clan;
vmCvar_t pref_spec;
vmCvar_t pref_ghost;
vmCvar_t pref_visitor;


and add the commands instead of the “ text “.
So it’ll look something like this:

else if ( ent->client->sess.modData->adminref == 2 )
{
type = pref_admin.string;
}


Repeat it for the other ranks but with the other command names you made.
I ended up with this code:

else if ( ghost )
{
type = pref_ghost.string;
}
else if ( spec )
{
type = pref_spec.string;
}
else if ( ent->client->sess.modData->adminref == 2 )
{
type = pref_admin.string;
}
else if ( ent->client->sess.modData->adminref == 1 )
{
type = pref_ref.string;
}
else if ( ent->client->sess.modData->adminref == 3 )
{
type = pref_sysop.string;
}
else if ( ent->client->sess.modData->adminref == 4 )
{
type = pref_coldr.string;
}
else if ( ent->client )
{
type = pref_visitor.string;
}
else if ( ent->client->sess.modData->clan == 1 && ent->client->sess.modData->adminref <1>client->sess.modData->versionVerified )
{
chat = "achat";
}


Save the g_cmds.c and you are done.
Now you only have to compile it into a .qvm and copy/paste it into your vm folder.

If any errors occurred you probably misspelled a name or deleted a part of a code such as the “ ; “ at the end or didn’t use the same word as you used before.



Soldier Of Fortune 2 -> SOF2 Tutorials


output generated using printer-friendly topic mod. All times are GMT + 2 Hours

Page 1 of 1