Raised This Month: $51 Target: $400
 12% 

Any idea why this makes the game crash?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 05-15-2021 , 10:55   Any idea why this makes the game crash?
Reply With Quote #1

I am trying to replace the pills model once it is created.

Like when a bot has pills and dies, it should replace the pills model that pops up with the one in the script.

But when I activate it, the game stucks and crashes.

When I comment out the SetEntityModel(entity, model); I can see in the echos that it sees the pill model when a bot dies. I just wonder why it would make the whole thing crash?!

PHP Code:
public void OnEntityCreated(int entity, const char[] classname)
{
    
    if (!
IsValidEntityIndex(entity))
        return;

        
SDKHook(entitySDKHook_SpawnPostOnSpawnPost);
}

bool IsValidEntityIndex(int client)
{
    return (
MaxClients+<= client <= GetMaxEntities());
}


/****************************************************************************************************/

public void OnSpawnPost(int entity)
{
    
RequestFrame(OnNextFrameEntIndexToEntRef(entity));
}

/****************************************************************************************************/

public void OnNextFrame(int entityRef)
{
//PrintToChatAll("*************************change*****************************");
    
int entity;
    while((
entity FindEntityByClassname(entity"weapon_pain_pills*")) > -1)
    {
        if(
IsValidEntity(entity) )
            {
                
char sModel[64];
                
GetEntPropString(entityProp_Data"m_ModelName"sModelsizeof(sModel));
                
//PrintToChatAll("%s*************************change*****************************", sModel);

                
if(StrContains(sModel"models/w_models/weapons/w_eq_painpills.mdl") > -1  )  
                            
                {    
                
PrintToChatAll("%s*************************change*****************************"sModel);

                
char  model[256] = "models/props_interiors/toiletpaperroll.mdl"
                
//SetEntityModel(entity, model); //<- enabling this makes the game crash

                
}


            }
        
    }



__________________
finishlast is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 05-15-2021 , 15:03   Re: Any idea why this makes the game crash?
Reply With Quote #2

Precache your model OnMapStart.
..
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
cravenge
Veteran Member
Join Date: Nov 2015
Location: Chocolate Factory
Old 05-15-2021 , 23:39   Re: Any idea why this makes the game crash?
Reply With Quote #3

You can't change the pills' model by force but what you can do is make it invisible and attach a decoy entity to it with the model you want.
cravenge is offline
finishlast
Senior Member
Join Date: Nov 2018
Location: In Reno with the vitamin
Old 05-16-2021 , 05:28   Re: Any idea why this makes the game crash?
Reply With Quote #4

The innitial crash was in fact the wrong precache, silly me, thank you Andi67.

As for the model change I gave up on replacing the pills attached to the body bc - unlike Silvers, Lux, Marttt and all the other pros - I am too dump to figure out how this stuff works with all this attach entity decoy stuff hahaha

I thought that it is possible to "just" replace the pills that lie on the ground, after the survivor dies but unfortunatelly it is not working as expected.

I only managed to replace all the pills on the map with this approach but not the pills that lie on the ground after death, even though I dont understand the difference between those pills.
Attached Files
File Type: sp Get Plugin or Get Source (l4d1_toiletpaperv3.sp - 50 views - 5.8 KB)
__________________

Last edited by finishlast; 05-16-2021 at 05:58.
finishlast is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 05-16-2021 , 07:06   Re: Any idea why this makes the game crash?
Reply With Quote #5

Well, get the position of the player, loop through the entitys with FindEntityByClassname , create new entity with CreateEntityByName with your model, remove the original model, teleport your new created entity to the last position than use SDKHooks to detect if someone touched it. Should not so hard to get this working....
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<

Last edited by andi67; 05-16-2021 at 07:07.
andi67 is offline
Reply



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 16:03.


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