Raised This Month: $51 Target: $400
 12% 

Prop model not loading correctly


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Chrissy
Member
Join Date: May 2013
Old 10-12-2019 , 17:18   Prop model not loading correctly
Reply With Quote #1

Hi guys,

I'm trying to spawn a coin, but it will disappear in the next tick. I'm not sure why though as it worked in the past and hoping someone here can point out my problem. Thanks.

(Pretty much should spawn a coin model that has the spinning anim that is parent to a trigger)

Code:
void SpawnCoin(const float vPos[3])
{
	int Coin = CreateEntityByName("prop_dynamic");
	int Trigger = CreateEntityByName("trigger_multiple");
	
	if(IsValidEntity(Coin) && IsValidEntity(Trigger))
	{
		//Coin Setup
		DispatchKeyValue(Coin, "model", "models/coop/challenge_coin.mdl");
		SetEntPropFloat(Coin, Prop_Send, "m_flModelScale", 0.7);
		
		DispatchSpawn(Coin);
		
		SetVariantString("challenge_coin_idle");
		AcceptEntityInput(Coin, "SetAnimation");
		
		SetEntityRenderColor(Coin, 255, 215, 0, 255);
		
		TeleportEntity(Coin, vPos, NULL_VECTOR, NULL_VECTOR);
		
		//Trigger Setup
		DispatchSpawn(Trigger);
		ActivateEntity(Trigger);
		
		SetEntityModel(Trigger, "models/props/cs_office/vending_machine.mdl");
		
		TeleportEntity(Trigger, vPos, NULL_VECTOR, NULL_VECTOR);
				
		float vMin[3], vMax[3];
		
		for (int i = 0; i < 3; i++) {
			vMin[i] = -10.0;
		}

		for (int i = 0; i < 3; i++) {
			vMax[i] = 10.0;
		}
		
		SetEntPropVector(Trigger, Prop_Send, "m_vecMins", vMin);
		SetEntPropVector(Trigger, Prop_Send, "m_vecMaxs", vMax);
		SetEntPropEnt(Trigger, Prop_Send, "m_hOwnerEntity", Coin);
		SetEntProp(Trigger, Prop_Send, "m_nSolidType", 2);
		SetEntProp(Trigger, Prop_Send, "m_fEffects", GetEntProp(Trigger, Prop_Send, "m_fEffects") | 32);  
		
		SDKHook(Trigger, SDKHook_StartTouch, Hook_StartTouch);
	}
Chrissy is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-18-2019 , 14:48   Re: Prop model not loading correctly
Reply With Quote #2

Did you try it without trigger_multiple hook?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Chrissy
Member
Join Date: May 2013
Old 10-19-2019 , 07:46   Re: Prop model not loading correctly
Reply With Quote #3

Quote:
Originally Posted by Dragokas View Post
Did you try it without trigger_multiple hook?
Thing is it worked before (this was roughly 2 years ago).

What I figured out was that if I touch the trigger just once, the coin model would spawn in every single time thereafter. On a map restart it would go back to despawning instantly.
Chrissy is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 10-19-2019 , 08:42   Re: Prop model not loading correctly
Reply With Quote #4

I just try to help you find out the problem step by step. Something changed since. So, check everything separately.

Previously, you told it disappear in the next tick.

And definitely, need to see Hook_StartTouch part of code as well.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Chrissy
Member
Join Date: May 2013
Old 10-19-2019 , 08:54   Re: Prop model not loading correctly
Reply With Quote #5

This is the trigger hook:
Code:
public Action Hook_StartTouch(int trigger, int client)
{
	if(IsValidClient(client) && GetClientTeam(client) == CS_TEAM_T)
	{
		int Coin = GetEntPropEnt(trigger, Prop_Send, "m_hOwnerEntity");
		
		if(IsValidEntity(Coin))
		{	
			AcceptEntityInput(Coin, "Kill");
			
			int Effect = CreateEntityByName("info_particle_system");
			
			if(IsValidEntity(Effect))
			{
				float vPos[3];
				GetEntPropVector(Coin, Prop_Data, "m_vecOrigin", vPos);
			
				DispatchKeyValue(Effect, "effect_name", "confetti_B_omni");
				
				DispatchSpawn(Effect);
				
				TeleportEntity(Effect, vPos, NULL_VECTOR, NULL_VECTOR);
				
				ActivateEntity(Effect);
				
				AcceptEntityInput(Effect, "Start");		

				CreateTimer(5.0, Timer_RemoveConfetti, Effect);
			}
		
		AcceptEntityInput(trigger, "Kill");
	}
}
Chrissy is offline
Chrissy
Member
Join Date: May 2013
Old 10-19-2019 , 15:27   Re: Prop model not loading correctly
Reply With Quote #6

I've unhooked it, but it still exhibits the same problem.

I can spawn a few coins until it spawns and seems to "disappear". The ones which don't "spawn" suddenly render in when you for example noclip into the void/wall or walk really far away from it. They're there, but the model doesn't always render on spawn.
Chrissy is offline
Reply



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 08:50.


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