Raised This Month: $ Target: $400
 0% 

Any idea why this makes the game crash?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



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 17:26.


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