Quote:
Originally Posted by Shadowysn
I wanted to attempt spawning survivor ragdolls without removing the original death model. So far, I got the ragdoll death to an extent.
|
I'm not compeletely sure what do you try to accomplish ... "convert" client sided ragdoll to server-sided?
In L4D1 (not sure about L4d2) ragdoll entity is valid for a very small amount of time: "player_death" with EventHookMode_Pre and no more valid on Post-event.
A trick is to kill it right there and create your own by reproducing original preperties, something like this:
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#tryinclude <LMCCore>
public void OnPluginStart()
{
HookEvent("player_death", player_death, EventHookMode_Pre);
}
public Action player_death(Event event, const char [] name, bool dontBroadcast)
{
static char Tank_Model[PLATFORM_MAX_PATH];
int client = GetClientOfUserId(event.GetInt("userid"));
//required checks
//if (client && IsClientInGame(client) && IsInfected(client, ZOMBIECLASS_TANK))
{
// note: tank_killed event is too late here to retrieve ragdoll entity!
int ragdoll = GetEntPropEnt(client, Prop_Send, "m_hRagdoll"); // CCSRagdoll
if (ragdoll && IsValidEntity(ragdoll)) {
AcceptEntityInput(ragdoll, "Kill");
}
int r,g,b,a;
float vOrigin[3];
char sColor[16];
GetClientAbsOrigin(client, vOrigin);
GetEntityRenderColor(client, r,g,b,a);
Format(sColor, sizeof(sColor), "%i %i %i", r, g, b);
/*
int iOverlayModel = -1;
#if defined _LMCCore_included
if( bLMC_Available )
iOverlayModel = LMC_GetClientOverlayModel(client);
#endif
*/
//GetEntPropString(iOverlayModel < 1 ? client : iOverlayModel, Prop_Data, "m_ModelName", Tank_Model, sizeof(Tank_Model));
GetEntPropString(client, Prop_Data, "m_ModelName", Tank_Model, sizeof(Tank_Model));
CreateTankRagdoll(vOrigin, Tank_Model, sColor);
}
}
void CreateTankRagdoll(float pos[3], char[] sModel, char[] sColor)
{
static int body;
body = CreateEntityByName("prop_ragdoll");
if (body != -1) {
DispatchKeyValue(body, "model", sModel);
DispatchKeyValue(body, "RenderColor", sColor);
DispatchKeyValue(body, "spawnflags", "4");
DispatchSpawn(body);
TeleportEntity(body, pos, NULL_VECTOR, NULL_VECTOR);
SetEntityKillTimer(body, 60.0);
}
}
stock void SetEntityKillTimer(int ent, float time)
{
char sRemove[64];
Format(sRemove, sizeof(sRemove), "OnUser1 !self:Kill::%f:1", time);
SetVariantString(sRemove);
AcceptEntityInput(ent, "AddOutput");
AcceptEntityInput(ent, "FireUser1");
}
Apply original velocity and direction is the only required to add to finish what you want.
This sample was for my tank plugin.
__________________