Raised This Month: $7 Target: $400
 1% 

Solved [TF2] prop_ragdoll keeps crashing my game even with a model set.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 10-06-2019 , 04:29   [TF2] prop_ragdoll keeps crashing my game even with a model set.
Reply With Quote #1

FIXED: The crash was because TeleportEntity was being called before DispatchSpawn and ActivateEntity.

If I spawn a prop_ragdoll using the console:
ent_create prop_ragdoll model "models/player/spy.mdl"
...the game won't crash and the ragdoll is spawned.
However, if I do it in Sourcemod, even ensuring it's model is set... it crashes.
PHP Code:
    float pos[3];
    
float ang[3];
    
GetClientAbsOrigin(clientpos);
    
GetClientAbsAngles(clientang);
    
    
char clientModel[64];
    
GetClientModel(clientclientModelsizeof(clientModel));
    
//char add_output_model[32];
    //Format(add_output_model, sizeof(add_output_model), "model %s", clientModel);
    
    //if (!IsModelPrecached(clientModel))
    //{ PrecacheModel(clientModel); }
    //PrintToChatAll(clientModel);
    
    
int rag CreateEntityByName("physics_prop_ragdoll");
    if(
rag 1)
    { return; }
    
AcceptEntityInput(ragdoll"kill");
    
    
//SetEntProp(rag, Prop_Send, "m_nModelIndex", GetEntProp(client, Prop_Send, "m_nModelIndex"))
    //DispatchKeyValue(rag, "model", clientModel);
    //SetVariantString(add_output_model);
    //AcceptEntityInput(rag, "AddOutput");
    
SetEntityModel(ragclientModel);
    
TeleportEntity(ragposangNULL_VECTOR);
    
    
char value[32];
    
IntToString(GetEntProp(clientProp_Send"m_nSkin"), valuesizeof(value));
    
DispatchKeyValue(rag"skin"value);
    
    
IntToString(GetEntProp(clientProp_Send"m_nBody"), valuesizeof(value));
    
DispatchKeyValue(rag"body"value);
    
    
IntToString(8192valuesizeof(value));
    
DispatchKeyValue(rag"spawnflags"value);
    
    
DispatchSpawn(rag);
    
ActivateEntity(rag);
    
    
SetEdictFlags(ragFL_EDICT_DONTSEND);
    
    
SetVariantString("OnUser1 !self:Kill::15.0:1");
    
AcceptEntityInput(rag"AddOutput");
    
AcceptEntityInput(rag"FireUser1"); 
Spawning a prop_dynamic instead of the ragdoll revealed that the model should be set properly.
As I cannot even debug if my game crashes straightaway after the problem, plus seeing how a plugin that spawned prop_ragdolls worked in another game, (and following that plugin's code still crashes in TF2) I have no idea what to do next.

Why do I want server-sided ragdolls? Well, it was just a little experiment I wanted to conduct.

Last edited by Shadowysn; 01-27-2021 at 07:17.
Shadowysn is offline
Nanochip
Senior Member
Join Date: Jan 2014
Old 10-08-2019 , 12:10   Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
Reply With Quote #2

For TF2, use the entity tf_ragdoll.
__________________
Nanochip is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 10-11-2019 , 12:19   Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
Reply With Quote #3

Quote:
Originally Posted by Nanochip View Post
For TF2, use the entity tf_ragdoll.
I already knew that, I was just experimenting with a rather-pretty-useless feature of forcing server-sided ragdolls.

Dangit, I should've made it more clear. I always manage to forget about info, info, and more info.
Shadowysn is offline
Lux
Veteran Member
Join Date: Jan 2015
Location: Cat
Old 10-16-2019 , 16:32   Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
Reply With Quote #4

Have you tried not creating a "physics_prop_ragdoll" instead use the entity you are using with this command (ent_create prop_ragdoll model "models/player/spy.mdl")

PHP Code:
int rag CreateEntityByName("prop_ragdoll"); 
Also dunno if you intended to not transmit the entity you may wanna remove that line.
PHP Code:
SetEdictFlags(ragFL_EDICT_DONTSEND); 
__________________
Connect
My Plugins: KlickME
[My GitHub]

Commission me for L4D
Lux is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 10-17-2019 , 02:48   Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
Reply With Quote #5

Quote:
Originally Posted by Lux View Post
Have you tried not creating a "physics_prop_ragdoll" instead use the entity you are using with this command (ent_create prop_ragdoll model "models/player/spy.mdl")

PHP Code:
int rag CreateEntityByName("prop_ragdoll"); 
Also dunno if you intended to not transmit the entity you may wanna remove that line.
PHP Code:
SetEdictFlags(ragFL_EDICT_DONTSEND); 
I actually took those from your code
I initially went with prop_ragdoll and didn't include that SetEdictFlags in my code, but they didn't work. Fast-forward to using those bits of code, and it still hasn't solved the problem.
__________________
ragdoll spam, that is all

Steam profile, where I game, obviously.
Youtube channel, where I do Stick Death Maze animations and some other stuff.
no plugin requests, sorry


My Plugins:
-search list-
Modified Plugins:
1 | 2 | 3 | 4
Shadowysn is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 01-27-2021 , 07:16   Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
Reply With Quote #6

Well, after the passing of the dreaded 2020, I finally found out why prop_ragdoll was crashing my game.

It was because TeleportEntity was being called before DispatchSpawn and ActivateEntity.


So, uh... do yourselves a good favor and remember how to avoid this crash the next time you want to use prop_ragdoll. ¯\_(ツ)_/¯
__________________
ragdoll spam, that is all

Steam profile, where I game, obviously.
Youtube channel, where I do Stick Death Maze animations and some other stuff.
no plugin requests, sorry


My Plugins:
-search list-
Modified Plugins:
1 | 2 | 3 | 4
Shadowysn is offline
Reply


Thread Tools
Display Modes

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 07:10.


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