Show message when oil rig crate spawns?
I want to make a system that types a message to the console when the crate on oil rig respawns but I can't figure out how to do it as I can't use the onentityspawns command as it will only tell me when the oil rig entity is spawned when the map is first loads. 

How do I make it so that it will put a message to the console when the crate on oil rig respawns?
void OnEntitySpawned(BaseEntity entity)
{
  NextTick(() =>
   {
        if (entity == null) return;
        if (entity is HackableLockedCrate)
        {
        Puts("I like cheese");
        }
   });
}

Something like that.... although that would call for the ch47 on the crate drop but meh... one step at a time

Merged post

suppose you could add a bool thats triggered with OnCrateDropped to weed that out..

Merged post

yeah that worked on my dev machine.

public bool ch47 = false;

        void OnEntitySpawned(BaseEntity entity)
        {
            NextTick(() =>
            { 
                if (entity == null)
                    return;
                if (entity is HackableLockedCrate)
                    if (ch47 == false)
                    {
                        Puts("I like cheese");
                    }
                    else
                    {
                        ch47 = false;
                        return;
                    }
                });
        }
        void OnCrateDropped(HackableLockedCrate crate)
        {
            ch47 = true;
        }


Merged post

oooooooo.... 

you need to add an 

if (entity is CargoShip) return;

aswell..... as there are 3 or 4 hackable locked crates on them too...

Thanks for the help