1. Is there a way to fetch/assign unique instance ID's to instances of entities (i.e. autoturrets and helicopters)?

    EDIT: in fact is there a way to assign an instance ID to any object in the game?

    EDIT 2: found ID field inside the base classes
     
    Last edited by a moderator: Jan 31, 2016
  2. Calytic

    Calytic Community Admin Community Mod

    FYI if you are using the instance IDs to persist anything past a server restart, you will discover that instance ID's are not the same after a server restart.

    If not, disregard this reply. We are working on a solution to this issue I will hopefully have reliable examples soon.
     
  3. Thanks for the notice, was about to start designing systems around using instance ID's between restarts :)
     
  4. Calytic

    Calytic Community Admin Community Mod

    You can reliably find entity ownership using the EntityOwner or Building Owners API.

    Obviously I would recommend using EntityOwner. But the APIs are identical for this purpose.

    For use with EntityOwner:
    Code:
    string FindOwner(BaseEntity entity)
    {
        object returnhook = null; 
        string ownerid = String.Empty;
        returnhook = EntityOwner?.Call("FindEntityData", entity);    if (returnhook != null)
        {
            if (!(returnhook is bool))
            {
                ownerid = Convert.ToString(returnhook);
            } 
        }     return ownerid;
    }
    
    For use with Building Owners:
    Code:
    string FindOwner(BaseEntity entity)
    {
        object returnhook = null; 
        string ownerid = String.Empty;
        returnhook = EntityOwner?.Call("FindBlockData", entity);    if (returnhook != null)
        {
            if (!(returnhook is bool))
            {
                ownerid = Convert.ToString(returnhook);
            } 
        }     return ownerid;
    }