SOF2MODDING Advanced tutorial – Editable rank prefixes P2
Select messages from # through # Forum FAQ
[/[Print]\]

Soldier Of Fortune 2 -> SOF2 Tutorials

#1: No icon SOF2MODDING Advanced tutorial – Editable rank prefixes P2 Author: Punisher PostPosted: Wed Apr 01, 2015 4:48 pm
    —
SOF2MODDING Advanced tutorial – Adding Editable rank prefixes Part.2

PART.1 - Editable Rank Prefixes
Step.2   - g_main.c

Now we are going to make it a text ( string ) so you can edit it in your cfg as a text between the “ “.
Before we are doing this we will have to do the same thing as we did at the g_local.h file.
On about line 240 theres some free space, add the codes you need there.
Just about: //vmCvar_t g_anonymousReferee;

For me it’s:
// Rank Prefixes
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;


When we have done this we need to add the string part. It gives the information that it has to be a text and not a true/false or value.

When you search for g_message1 again you’ll see the following code:
{ &g_message1, "g_message1", "", 0, 0.0f, 0.0f, 0, qfalse },

We are gonna change this for our command.
Copy it and paste it in a open space.
On about line 575 theres some free space for the code for me.

I’m adding the code:
// Admin Prefixes
{ &pref_admin, "pref_admin", "", 0, 0.0f, 0.0f, 0, qfalse },
{ &pref_ref, "pref_ref", "", 0, 0.0f, 0.0f, 0, qfalse },
{ &pref_sysop, "pref_sysop", "", 0, 0.0f, 0.0f, 0, qfalse },
{ &pref_coldr, "pref_coldr", "", 0, 0.0f, 0.0f, 0, qfalse },
{ &pref_clan, "pref_clan", "", 0, 0.0f, 0.0f, 0, qfalse },
{ &pref_spec, "pref_spec", "", 0, 0.0f, 0.0f, 0, qfalse },
{ &pref_ghost, "pref_ghost", "", 0, 0.0f, 0.0f, 0, qfalse },
{ &pref_visitor, "pref_visitor", "", 0, 0.0f, 0.0f, 0, qfalse },


Save g_main.c also and you are done here too.
We only need to add these to the correct rank so it can be changed by cfg.

Step.3   - g_cmds.c

This is the last part we have to do.
Go back to the lines where you left of at Floo’s tutorial.

I’m using the Admin prefixes as an example in this part.

If you did it correct your Admin prefixes will look something like this:
else if ( ent->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.

#2: No icon Re: SOF2MODDING Advanced tutorial – Editable rank prefixes Author: Punisher PostPosted: Wed Apr 01, 2015 6:36 pm
    —
I Hope you guys understood what i was explaining.
Give me some feedback, or tips.
Such as better technique or something about my writing / explaining style. etc...

Upcoming Tutorial:
Adding a new rank.

#3: No icon Re: SOF2MODDING Advanced tutorial – Editable rank prefixes Author: abdouraoui PostPosted: Wed Apr 01, 2015 6:38 pm
    —
it's doesn't work for me :/
look what I see

#4: No icon Re: SOF2MODDING Advanced tutorial – Editable rank prefixes Author: Punisher PostPosted: Wed Apr 01, 2015 8:10 pm
    —
give me line 1853 of g_cmd.c please, Thats the line which gives you an error.

Also compile with the game.bat in your code folder not in your game folder.
for me the one in the game folder gives errors or just wont work, while the game.bat in my code folder compiles properly.

#5: No icon Re: SOF2MODDING Advanced tutorial – Editable rank prefixes Author: abdouraoui PostPosted: Thu Apr 02, 2015 3:13 pm
    —
the line 1853 is:
else if ( ent->client->sess.modData->clan == 1 && ent->client->sess.modData->adminref <1>client->sess.modData->versionVerified )

#6: No icon Re: SOF2MODDING Advanced tutorial – Editable rank prefixes Author: Punisher PostPosted: Thu Apr 02, 2015 3:43 pm
    —
It's the clan prefix right?

If yes, it should be:
ent->client->sess.modData->clan == 1 && ent->client->sess.modData->adminref <1>client->sess.modData->versionVerified

Shouldnt be anywhere near there, only the line:
if ( g_voiceCommandsEnabled.integer == 1 && sv_modClient.integer || other->client->sess.modData->versionVerified )
{
trap_SendServerCommand( other-g_entities, va("sound %i \"%s\"", ent->client->sess.team, sound));
}


for me on line 1856 contains that part of the code.

So if the lines above and under it are like this:

type = pref_visitor.string;
}
else if ( ent->client->sess.modData->clan == 1 && ent->client->sess.modData->adminref <1>client->sess.modData->versionVerified )
{
type = pref_clan.string;
}


Then you should change:

ent->client->sess.modData->clan == 1 && ent->client->sess.modData->adminref <1>client->sess.modData->versionVerified


to:
ent->client->sess.modData->clan == 1 && ent->client->sess.modData->adminref < 1

Try that and compile again, dunno if it'll work tho bu that part doesnt belong there.

#7: No icon Re: SOF2MODDING Advanced tutorial – Editable rank prefixes Author: abdouraoui PostPosted: Thu Apr 02, 2015 4:35 pm
    —
yeah it's work but when i compiled it i don't found file sof2mp_game.qvm in folder vm

#8: No icon Re: SOF2MODDING Advanced tutorial – Editable rank prefixes Author: Punisher PostPosted: Thu Apr 02, 2015 4:51 pm
    —
use the game.bat in your CODE folder not in your GAME folder, same is when your editing in cgame folder you have to use the CGAMe.bat in your CODE folder.

Also be sure you have edited the paths in your .bat

so for Rocmod2.1c game.bat in your code folder you'll get this code:
Change the colored parts in your game.bat to the path you have your SDK installed to.
Also be sure there arent any errors.
Hidden: 

@ECHO OFF

if not "%nocount%" == "1" call buildcounter.bat

@set include=

@cd game

del /q vm
mkdir vm
cd vm
set cc=C:\SoF2SDK\bin\sof2lcc -A -DQ3_VM -DROCMOD_BUILD=%buildcount% -DMISSIONPACK -S -Wf-target=bytecode -Wf-g -I..\..\cgame -I..\..\game -I..\..\ui %1

echo ---------------------------------

%cc%  ../g_main.c
@if errorlevel 1 goto quit

%cc%  ../g_syscalls.c
@if errorlevel 1 goto quit

%cc%  ../bg_misc.c
@if errorlevel 1 goto quit
%cc%  ../bg_lib.c
@if errorlevel 1 goto quit
%cc%  ../bg_pmove.c
@if errorlevel 1 goto quit
%cc%  ../bg_slidemove.c
@if errorlevel 1 goto quit
%cc%  ../bg_player.c
@if errorlevel 1 goto quit
%cc%  ../bg_weapons.c
@if errorlevel 1 goto quit
%cc%  ../bg_gametype.c
@if errorlevel 1 goto quit
%cc%  ../q_math.c
@if errorlevel 1 goto quit
%cc%  ../q_shared.c
@if errorlevel 1 goto quit

%cc%  ../ai_main.c
@if errorlevel 1 goto quit
%cc%  ../ai_util.c
@if errorlevel 1 goto quit
%cc%  ../ai_wpnav.c
@if errorlevel 1 goto quit

%cc%  ../g_active.c
@if errorlevel 1 goto quit
%cc%  ../g_antilag.c
@if errorlevel 1 goto quit
%cc%  ../g_bot.c
@if errorlevel 1 goto quit
%cc%  ../g_client.c
@if errorlevel 1 goto quit
%cc%  ../g_cmds.c
@if errorlevel 1 goto quit
%cc%  ../g_combat.c
@if errorlevel 1 goto quit
%cc%  ../g_gametype.c
@if errorlevel 1 goto quit
%cc%  ../g_items.c
@if errorlevel 1 goto quit
%cc%  ../g_misc.c
@if errorlevel 1 goto quit
%cc%  ../g_missile.c
@if errorlevel 1 goto quit
%cc%  ../g_mover.c
@if errorlevel 1 goto quit
%cc%  ../g_session.c
@if errorlevel 1 goto quit
%cc%  ../g_spawn.c
@if errorlevel 1 goto quit
%cc%  ../g_svcmds.c
@if errorlevel 1 goto quit
%cc%  ../g_target.c
@if errorlevel 1 goto quit
%cc%  ../g_team.c
@if errorlevel 1 goto quit
%cc%  ../g_trigger.c
@if errorlevel 1 goto quit
%cc%  ../g_utils.c
@if errorlevel 1 goto quit
%cc%  ../g_weapon.c
@if errorlevel 1 goto quit

%cc%  ../g_admin.c
@if errorlevel 1 goto quit
%cc%  ../g_admincmds.c
@if errorlevel 1 goto quit

echo ---------------------------------

C:\SoF2SDK\bin\sof2asm -f ../game
@if errorlevel 1 goto quit

mkdir "..\..\..\base\vm"
copy *.map "..\..\..\base\vm"
copy *.qvm "..\..\..\base\vm"
copy *.qvm "..\..\..\packages\ROCmod-xxxx-server\rocmod\vm"

:quit
@cd ..
@cd ..


Also be sure you got something similar to this:



Soldier Of Fortune 2 -> SOF2 Tutorials


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

Page 1 of 1