Quote:
Originally Posted by 3ipKa
Ok, I've tried code given in link, but nothing, model doesn't spawn.
Spoiler
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.
|
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.
|