Hello,
I'm trying to create an entity and throw it at his spawn, I had it working with a prop_physics_override, but now I want to animate it, si I used the 'SetAnimation' input, but it didn't work ...
I tried with the prop_dynamic_override and then the Animation worked, but I can't throw the prop anymore
Here's my code:
Code:
stock Throw(client)
{
new Float:pos[3];
GetClientAbsOrigin(client, pos);
new entity = CreateEntityByName("prop_dynamic_override");
// new entity = CreateEntityByName("prop_physics_override");
if (IsValidEdict(entity))
{
SetEntityModel(entity, MODEL);
SetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity", client);
SDKHook(entity, SDKHook_Spawn, SDKHook_OnEntitySpawned);
SetEntPropFloat(entity, Prop_Send, "m_flElasticity", 0.0);
SetEntityGravity(entity, 0.01);
DispatchSpawn(entity);
new Float:angles[3] = {0.0, 0.0, 0.0};
TeleportEntity(entity, pos, angles, NULL_VECTOR);
// Works with prop_dynamic_override but not with prop_physics_override
SetAnim(entity, "Fly01");
return entity;
}
return -1;
}
SetAnim(ent, const String:anim[])
{
SetVariantString(anim);
AcceptEntityInput(ent, "SetAnimation");
}
public SDKHook_OnEntitySpawned(entity)
{
CreateTimer(0.1, Throw, entity);
}
// Works with prop_physics_override, but not with prop_dynamic_override
public Action:Throw(Handle:Timer, any:ent)
{
if(IsValidEdict(ent))
{
new client = GetEntPropEnt(ent, Prop_Send, "m_hOwnerEntity");
if(IsPlayerAlive(client))
{
new Float:fPos[3], Float:fVec[3], Float:fFw[3], Float:fUp[3];
GetClientEyeAngles(client, fVec);
GetClientEyePosition(client, fPos);
fPos[0]+=fFw[0]*45.0;
fPos[1]+=fFw[1]*45.0;
fPos[2]+=fFw[2]*45.0;
fPos[2] -= 30.0;
GetAngleVectors(fVec, fFw, NULL_VECTOR, fUp);
ScaleVector(fFw, 3000.0);
AddVectors(fFw, fUp, fVec);
TeleportEntity(ent, fPos, NULL_VECTOR, fVec);
}
else
{
AcceptEntityInput(ent, "Kill");
}
}
return Plugin_Stop;
}
Could you please help me ? ;(
Thanks in advance.
__________________