AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [TF2] prop_ragdoll keeps crashing my game even with a model set. (https://forums.alliedmods.net/showthread.php?t=319009)

Shadowysn 10-06-2019 04:29

[TF2] prop_ragdoll keeps crashing my game even with a model set.
 
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.

Nanochip 10-08-2019 12:10

Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
 
For TF2, use the entity tf_ragdoll.

Shadowysn 10-11-2019 12:19

Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
 
Quote:

Originally Posted by Nanochip (Post 2669197)
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. :P

Dangit, I should've made it more clear. I always manage to forget about info, info, and more info.

Lux 10-16-2019 16:32

Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
 
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); 


Shadowysn 10-17-2019 02:48

Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
 
Quote:

Originally Posted by Lux (Post 2669906)
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 :P
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.

Shadowysn 01-27-2021 07:16

Re: [TF2] prop_ragdoll keeps crashing my game even with a model set.
 
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. ¯\_(ツ)_/¯


All times are GMT -4. The time now is 18:20.

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