Raised This Month: $32 Target: $400
 8% 

Changing the model of equipped pills


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 12-13-2020 , 05:47   Changing the model of equipped pills
Reply With Quote #1

Hello there,

once again I am wondering how to do stuff..

This time I tried to replace pills with a roll of toilet paper. (don't ask why..)

For now I managed to replace the pills on spawn and throughout the map with a toiletroll.

Then I wondered how to replace the model on the survivor when they equipped it.

I hooked entiy creation and then checked for model and simply tried to replace (like I did with the spawn pills.)

See attached file, when I try to replace the model this time (that I think it is.. w_eq_painpills.mdl not sure about that though) the game crashes.

Is it even possible to just replace the model? Or do I have to make fancy stuff?
Attached Files
File Type: sp Get Plugin or Get Source (l4d1_toiletpaperv1.sp - 89 views - 5.6 KB)
__________________

Last edited by finishlast; 12-13-2020 at 05:49.
finishlast is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 12-15-2020 , 22:27   Re: Changing the model of equipped pills
Reply With Quote #2

You can try something like this.
I have no access to any tools when writing this but it give you the idea how to do it.

PHP Code:
char g_sPainPills[] = "models/props_interiors/toiletpaperroll.mdl";

public 
void OnMapStart() {
    
PrecacheModelg_sPainPills );
}

public 
void OnClientPutInServerint client ) {
    
SDKUnhookclientSDKHook_WeaponSwitchOnWeaponSwitch );
    
SDKHookclientSDKHook_WeaponSwitchOnWeaponSwitch );
}

public 
Action OnWeaponSwitchint clientint weapon ) {
    
int pills GetEntPropEntclientProp_Send"m_hActiveWeapon" );
    if( 
pills == weapon && IsValidEntitypills )) {
        
char entClass[64];
        
GetEntityClassnamepillsentClasssizeofentClass ));
        if( 
StrEqualentClass"weapon_pain_pills"false ) || StrEqualentClass"weapon_first_aid_kit"false )) {
            
SetEntityModelpillsg_sPainPills );
        }
    }

__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 12-17-2020 , 13:46   Re: Changing the model of equipped pills
Reply With Quote #3

Hi and thx.

But I fear this task is not as easy as I first thought.

I succesfully hook that with sdkhook and it seems to alter the model bc the view of pills changed to a "stuck" like animation.

I changed the uzi to pistols model as test but then the uzi animation went bezerk,it was still uzi but out of control. really.

Attached version with pills to toiletroll over the map and

models/v_models/v_painpills.mdl
to
models/props_interiors/toiletpaperroll.mdl

sdhook with not working side effects.

Maybe that is not possible at all.

I wonder if it is at least possible to alter the pills that are carried on the belt of the survivors or if this will result in a similar result?!
Attached Files
File Type: sp Get Plugin or Get Source (l4d1_toiletpaperv2.sp - 50 views - 6.3 KB)
__________________

Last edited by finishlast; 12-17-2020 at 13:51.
finishlast is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 12-19-2020 , 12:09   Re: Changing the model of equipped pills
Reply With Quote #4

I do not have deep knowledge in this but if you look hard enough there is already a plugin that do swap the weapon model. probably best to look at they example.

Also you precache the model on OnMapStart() not plugin start.

If you reloading plugin during debug in midgame you just check if late load then call the OnMapStart() function again.
__________________
If i happen to insulted you unintentionally,
it was me and Google Translate who did it.
GsiX is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode