Raised This Month: $334 Target: $400
 83%   Almost there!

Molotov w_ model problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BeNq!
Senior Member
Join Date: Mar 2009
Old 11-06-2021 , 12:38   Molotov w_ model problem
Reply With Quote #1

Hello,

I have a problem with the molotov w_ model. I'm used this code:

Code:
public void OnEntityCreated( int entity, const char[] classname )
{
	if( IsValidEntity( entity ) ) 
		SDKHook( entity, SDKHook_SpawnPost, OnEntitySpawned );
}

public void OnEntitySpawned( int entity )
{
	char class_name[ 64 ];
	GetEntityClassname( entity, class_name, 64 );
	
	int owner = GetEntPropEnt( entity, Prop_Data, "m_hOwnerEntity" );
	
	if( StrContains( class_name, "projectile" ) != -1 && IsValidEntity( entity ) && IsValidClient( owner ) )
	{
		if( StrContains( class_name, "hegrenade" ) != -1 )
		{			
			SetEntityModel( entity, "models/testmodel/w_red.mdl" );
			PrintToChatAll( "test red %i", entity );
		}
		else if( StrContains( class_name, "decoy" ) != -1 )
		{
			SetEntityModel( entity, "models/testmodel/w_blue.mdl" );
		}
		else if( StrContains( class_name, "incgrenade" ) != -1 )
		{
			SetEntityModel( entity, "models/testmodel/w_orange.mdl");
			PrintToChatAll( "test orange %i", entity );
		}
		
		else if( StrContains( class_name, "molotov" ) != -1 )
		{
			SetEntityModel( entity, "models/testmodel/w_yellow.mdl");
			PrintToChatAll( "test yellow %i", entity );
		}
	}
}
What's problem? Grenade i.e. hegren and decoy works ( model works ) but incegrenade and molotov is showing original model ( models don't change ). Where did I go wrong? Maybe it is impossible to change the model of incendiary grenades?
BeNq! is offline
Kxnrl
AlliedModders Donor
Join Date: May 2015
Old 11-18-2021 , 20:53   Re: Molotov w_ model problem
Reply With Quote #2

you should create a timer
__________________
Kxnrl is offline
kadet.89
Veteran Member
Join Date: Nov 2012
Old 11-26-2021 , 04:15   Re: Molotov w_ model problem
Reply With Quote #3

Create a timer with 0.0 time, that will move execution of your code to 1 gameframe ahead. So it will be executed after the engine sets a model to the entity. In current impliementation the engine overrides to model name, which is set by the plugin.

Last edited by kadet.89; 11-26-2021 at 04:16.
kadet.89 is offline
Send a message via Skype™ to kadet.89
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 15:27.


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