Jump to content
  • 0

OnEntityLeave vs. OnEntityKill


Dr.D.Bug

Question

I want to inform the players, that the Patrolheli was killed or the Patrolheli has leaved the island. Sounds easy ... but in this case i always got the information that the Heli was killed although it just leaves the island... pls. help!
 

void Broadcast(string msg, params object[] args)
{
    PrintToChat(msg, args);
}

void OnEntityLeave(TriggerBase trigger, BaseEntity entity)
{
    if (entity is BaseHelicopter)
    {
        Broadcast("Patrolheli leaves.");
    }
}

void OnEntityKill(BaseNetworkable entity)
{
    if (entity is BaseHelicopter)
    {
        Broadcast("Patrolheli was killed.");
    }
}

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
  • Administrator

The OnEntityLeave hook isn't called for PatrolHelicopterAI but there is a similar hook called OnHelicopterRetire if you only want it to be called when it leaves on its own. That hook will not be called if it's destroyed or ent killed. If you want to trigger for that AND when it leaves then use OnEntityKill.

Example:

        void OnHelicopterRetire(HelicopterAI helicopter)
        {
            // Do your thing. Change to object if you want to override internal method
        }

Internal method:

    public void Retire()
    {
        if (this.isRetiring)
        {
            return;
        }
        if (Interface.CallHook("OnHelicopterRetire", this) != null)
        {
            return;
        }
        this.isRetiring = true;
        base.Invoke(new Action(this.DestroyMe), 240f);
        float size = TerrainMeta.Size.x;
        float single = 200f;
        Vector3 vector3 = Vector3Ex.Range(-1f, 1f);
        vector3.y = 0f;
        vector3.Normalize();
        vector3 = vector3 * (size * 20f);
        vector3.y = single;
        this.ExitCurrentState();
        this.State_Move_Enter(vector3);
    }
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
1.1m

Downloads

Total number of downloads.

5.5k

Customers

Total customers served.

78.6k

Files Sold

Total number of files sold.

1.5m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.