PDA

View Full Version : Removing Individual Ragdolls


SamuraiBarbi
10-03-2007, 17:40
Hey, how can I remove an individual players ragdoll? I'm not trying to remove all the ragdolls on the map, I just want to remove a single players ragdoll. I know I'm probably supposed to use m_hRagdoll but I'm foggy as to how to get a specific players m_hRagdoll and how to remove it.

I used to do this in Es Tools using
es_fire server_var(userid) cs_ragdoll Kill

Hope that helps in finding a Sourcemod equivalent.

Thanks!

BAILOPAN
10-03-2007, 19:00
You can use GetEntDataEnt() and if m_hRagdoll has a valid entity, you unset the value and then remove the entity.

SamuraiBarbi
10-03-2007, 22:15
Ok, so I do something like this to check if it has a valid entity?


#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

new ragdollOffset;

public OnPluginStart()
{
HookEvent("player_death", HookPlayerDeath);
ragdollOffset = FindSendPropOffs("CCSPlayer","m_hRagdoll");
}

public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new userid = GetEventInt(event,"userid");
new victim = GetClientOfUserId(userid);
new victimTeam = GetClientTeam(victim);

if (victimTeam == 2)
{
CreateTimer(1.0, RemoveRagdoll, victim);
}
}

public Action:RemoveRagdoll(Handle:timer, any:victim)
{
new playerRagdoll = GetEntDataEnt(victim, ragdollOffset);
PrintToChatAll("%i", playerRagdoll);
}

BAILOPAN
10-04-2007, 08:43
Yes.

SamuraiBarbi
10-04-2007, 10:47
Ok, here's what I got, although it doesn't work and I'm kinda lost because the compiler isn't giving me any errors. What aren't I doing or what am I not doing right?

This is my gamedata

"Games"
{
"cstrike"
{
"Signatures"
{
"UTIL_Remove"
{
"library" "server"
"windows" "\x8B\x44\x24\x04\x85\xC0\x74\x2A\x05\x2A\x2A\ x00\x00\x89\x44\x24\x04\xE9\x2A\xFF\xFF\xFF"
"linux" "@_Z11UTIL_RemoveP11CBaseEntity"
}
}
}
}

And this is my code

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

new ragdollOffset;
new Handle:hutilRemove;

public OnPluginStart()
{
hgameConf = LoadGameConfigFile("km.mod");
HookEvent("player_death", HookPlayerDeath);
ragdollOffset = FindSendPropOffs("CCSPlayer","m_hRagdoll");

/** Util Remove */
StartPrepSDKCall(SDKCall_Static);
PrepSDKCall_SetFromConf(hgameConf, SDKConf_Signature, "UTIL_Remove");
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
hutilRemove = EndPrepSDKCall();
}

public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new userid = GetEventInt(event,"userid");
new victim = GetClientOfUserId(userid);
new victimTeam = GetClientTeam(victim);

if (victimTeam == 2)
{
CreateTimer(1.0, RemoveRagdoll, victim);
}
}

public Action:RemoveRagdoll(Handle:timer, any:victim)
{

new playerRagdoll = GetEntDataEnt(victim, ragdollOffset);
SetEntDataEnt(victim, ragdollOffset, 0, true);
RemoveEnt(playerRagdoll);
}

public Action:RemoveEnt(entity)
{
/* Just incase 0 get passed */
if(entity)
{
SDKCall(hutilRemove, entity);
}
}

BAILOPAN
10-04-2007, 18:29
What's not working?

SamuraiBarbi
10-04-2007, 18:59
I'm not sure what it is in the script that's not working, I was hoping someone might be able to tell me what the problem is. What I do know is that it's not getting rid of the players ragdoll when they die.

ferret
10-04-2007, 20:14
0 error messages? I'd throw in some debugging message to test the values of things. I.e., "PrintToChat("Event_PlayerDeath: %d %d %d", userid, victim, victimTeam);" and so forth. Check what data you're dealing with, will possibly help illuminate the issue.

SamuraiBarbi
10-05-2007, 00:34
Thanks for the suggestion ferret, I've checked and double checked those values already. All the values I'm using are correct, it's just I don't know what's wrong and I'd like to get a more experienced Sourcemod scripter to verify that the code itself is sound and should achieve what I'm trying to accomplish.

bl4nk
10-05-2007, 11:01
Does the ragdoll still parent to the player once the player is killed or does it do it's own thing?

BAILOPAN
10-05-2007, 11:56
What value is getting passed to RemoveEnt()?

SamuraiBarbi
10-16-2007, 15:19
i'm still trying to figure out what the problem is btw. just curious, why am i setting the players ragdoll offset to 0? wouldn't that mean the value i'm passing to RemoveEnt() would end up being 0?

BAILOPAN
10-16-2007, 16:36
No. You saved the original value (I hope).

M249-M4A1
10-16-2007, 22:35
I helped SamuraiBarbi with his problem, it's solved

BAILOPAN
10-16-2007, 23:48
Were you planning on posting the solution ;)

FlyingMongoose
10-17-2007, 06:53
aye, I wouldn't mind being able to do this with some of my punishments in ATAC >.<

M249-M4A1
10-17-2007, 08:34
Were you planning on posting the solution ;)

No need to, he made some careless mistakes here and there :)

SamuraiBarbi
10-17-2007, 11:58
ah. oks, thank you bailopan with your suggestions earlier and some doublecheckin from a friend we were able to get the plugin workin like a charm. :D

Fredd
03-28-2008, 18:23
mind posting the final script?

DiscoBBQ
03-28-2008, 21:25
Solution can be found in http://forums.alliedmods.net/showthread.php?t=67863

starting at line 109