[Coding] Setting custom gun skin with CVAR


(eQuilibrium) #1

Greetings!

I’m working on a mod where I’d like to implement a feature where the player can select a skin for his weapon using a CVAR. I’ve named the CVAR /cg_mp40skin1 for now. When this is set to 1, it uses an alternate skin for the MP40. I looked at how the medic’s syringe works, since that changes shader once you’re level 3 or above medic. I’ve actually got this “working”. When I set up the CVAR though, other players just see the default skin. Perhaps because the skin selection is not being sent over the net?

Here’s the bit of code:

		if (cg_mp40skin1.integer == 1){
			cgs.clientinfo[cg.clientNum].mp40skin1 = 1;
		}
		if( !ps ) {
			if ( cgs.clientinfo[ cent->currentState.clientNum ].mp40skin1 == 1 ){
				if( weaponNum == WP_MP40 ) {
					gun.customShader	= weapon->modModels[0];
				}
			}
		}

If anyone could point me in the right direction that would be greatly appreciated :penguin:


(Indloon) #2

It is same as ETPub´s custom weapon shader, which can be changed by client, you only see it on screen while others don´t.

I faced same problem while I was working on my own mod too, solution( note, it is not the best solution to deal with! ) was to add new weapons on both, game and client game code, the new weapons had only different skin textures, but the models were same.

Here is a tutorial how to add a weapon by Bacon: http://forums.warchest.com/showthread.php/7081-code-Mauser

After you have added new “weapons”, you can see them via entering cvar /give all.


(eQuilibrium) #3

[QUOTE=Indloon;427387]It is same as ETPub´s custom weapon shader, which can be changed by client, you only see it on screen while others don´t.

I faced same problem while I was working on my own mod too, solution( note, it is not the best solution to deal with! ) was to add new weapons on both, game and client game code, the new weapons had only different skin textures, but the models were same.

Here is a tutorial how to add a weapon by Bacon: http://forums.warchest.com/showthread.php/7081-code-Mauser

After you have added new “weapons”, you can see them via entering cvar /give all.[/QUOTE]

Fortunately I already have experience with adding new weapons, so this shouldn’t be a problem :slight_smile:

Thanks for your assistance, I will try messing around with it now!


(eQuilibrium) #4

Alright, I’ve got this working in a more convinient way!

Thanks for your help :slight_smile:


(Indloon) #5

[QUOTE=eQuilibrium;428095]Alright, I’ve got this working in a more convinient way!

Thanks for your help :)[/QUOTE]

Glad you got it working. Wunderbar! :eek: