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

[CS:GO] OnEntityCreated + SDKSpawn


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 10-05-2020 , 15:12   [CS:GO] OnEntityCreated + SDKSpawn
Reply With Quote #1

PHP Code:

public void OnEntityCreated(int entity, const char[] classname)
{
    
SDKHook(entitySDKHook_SpawnSDK_OnEntitySpawn);
}

public 
Action SDK_OnEntitySpawn(int entity)
{
    if (
entity < -1)
    {
        
entity EntRefToEntIndex(entity);
        if (
entity == INVALID_ENT_REFERENCE)
        {
            return 
Plugin_Continue;
        }
    }

    
// here for func_door, door_rotating and movelinear I do this: 
t    // there are some validations, I removed them for this example
    
HookSingleEntityOutput(entity"OnFullyOpen"Output_OnDoorStateChange);
}

public 
void Output_OnDoorStateChange(const char[] outputint callerint activatorfloat delay)
{
    
// here print something for testing purpose

So for func_door, Output_OnDoorStateChange prints the message in most cases, but sometimes it doesn't print anything.
I think there's a problem with entity validation, maybe it's not valid here? Maybe the entity is a reference and if (entity == INVALID_ENT_REFERENCE) return true?

How can I hook entity spawn for every entity? OnEntityCreated doesn't work with func_brushes, I did some testing with it, and I had to do an iteration on round_start.

Also I replaced HookSingleEntityOutput with HookEntityOutput, I hope it will work for my entities and will not trigger different ones (for func_button, HookEntityOutput - OnPressed triggers another entity as well).
__________________
Ilusion9 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 19:23.


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