Raised This Month: $ Target: $400
 0% 

Solved Spawn prop_physics


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
3ipKa
Member
Join Date: Jul 2013
Location: Western Siberia
Old 07-16-2022 , 13:03   Re: Spawn prop_physics
Reply With Quote #1

Ok, I've tried code given in link, but nothing, model doesn't spawn.

Code:
#define PIPE_MODEL	"models/w_models/weapons/w_eq_pipebomb.mdl"

public void OnPluginStart()
{
	RegConsoleCmd("sm_spawnphy", spanwCMD);
}

public void OnMapStart()
{
	PrecacheModel( "models/w_models/weapons/w_eq_pipebomb.mdl", true );
}

public Action spanwCMD(int client,int args)
{
	float SpawnPosition[3], SpawnAngle[3];
	GetClientAbsOrigin( client, SpawnPosition );
	SpawnPosition[2] += 20; SpawnAngle[0] = 90.0;
	int phymdl = CreateEntityByName("prop_physics");//prop_physics_multiplayer - no effect too
	if(IsValidEdict(phymdl))
	{		
		PrintToChatAll("phymdl is valid");// fired well
		DispatchKeyValue(phymdl, "model", PIPE_MODEL);
    
		TeleportEntity(phymdl, SpawnPosition, SpawnAngle, NULL_VECTOR);
		DispatchSpawn(phymdl);
			
		DispatchKeyValue(phymdl, "StartDisabled", "false");
		DispatchKeyValue(phymdl, "Solid", "6");
			
		// DispatchKeyValue(phymdl, "spawnflags", "8"); 
		// SetEntProp(phymdl, Prop_Data, "m_CollisionGroup", 5);
		AcceptEntityInput(phymdl, "EnableCollision"); 
		AcceptEntityInput(phymdl, "TurnOn", phymdl, phymdl, 0);
			
		SetEntityMoveType(phymdl, MOVETYPE_VPHYSICS);
		SetEntProp(phymdl, Prop_Data, "m_nSolidType", 6);
		SetEntProp(phymdl, Prop_Data, "m_CollisionGroup", 2);
		SetEntProp(phymdl, Prop_Data, "m_takedamage", 0);  
	}
	return Plugin_Handled;
}
I've tried different properties. I mean DispatchKeyValue and SetEntProp with solid type, collision group properties, tried MOVETYPE_VPHYSICS, different spawnflags, tried swapping keys (teleport first than DispatchSpawn).
My goal is to spawn model with physics, I could use another one, but pipebomb fits my needs excellent. It shouldn't be pickable.

Last edited by 3ipKa; 07-16-2022 at 13:06.
3ipKa is offline
Sreaper
髪を用心
Join Date: Nov 2009
Old 07-16-2022 , 15:54   Re: Spawn prop_physics
Reply With Quote #2

Quote:
Originally Posted by 3ipKa View Post
Ok, I've tried code given in link, but nothing, model doesn't spawn.

Spoiler


I've tried different properties. I mean DispatchKeyValue and SetEntProp with solid type, collision group properties, tried MOVETYPE_VPHYSICS, different spawnflags, tried swapping keys (teleport first than DispatchSpawn).
My goal is to spawn model with physics, I could use another one, but pipebomb fits my needs excellent. It shouldn't be pickable.

Code:
#include <sdktools>

#define PIPE_MODEL	"models/props_c17/oildrum001_explosive.mdl"

public void OnPluginStart()
{
	RegConsoleCmd("sm_spawnphy", spanwCMD);
}

public void OnMapStart()
{
	PrecacheModel( "models/props_c17/oildrum001_explosive.mdl", true );
}

public Action spanwCMD(int client,int args)
{
	float SpawnPosition[3], SpawnAngle[3];
	GetClientAbsOrigin( client, SpawnPosition );
	SpawnPosition[2] += 20; SpawnAngle[0] = 90.0;
	int phymdl = CreateEntityByName("prop_physics");
	if(IsValidEdict(phymdl))
	{		
		PrintToChatAll("phymdl is valid");// fired well
		DispatchKeyValue(phymdl, "model", PIPE_MODEL);
    
		TeleportEntity(phymdl, SpawnPosition, SpawnAngle, NULL_VECTOR);
		DispatchSpawn(phymdl);
        
		DispatchKeyValue(phymdl, "StartDisabled", "false");
		DispatchKeyValue(phymdl, "Solid", "6");
			
		AcceptEntityInput(phymdl, "EnableCollision"); 
		AcceptEntityInput(phymdl, "TurnOn", phymdl, phymdl, 0);
			
		SetEntityMoveType(phymdl, MOVETYPE_VPHYSICS);
		SetEntProp(phymdl, Prop_Data, "m_nSolidType", 6);
		SetEntProp(phymdl, Prop_Data, "m_CollisionGroup", 0);
		SetEntProp(phymdl, Prop_Data, "m_takedamage", 2);

	}
	return Plugin_Handled;
}
This seems to work as intended.

Last edited by Sreaper; 07-16-2022 at 15:55.
Sreaper 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 22:24.


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