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
Solved Name/ID of entities (per Instance)
Discussion in 'Rust Development' started by Quenn1599, Jan 30, 2016.
-
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. -
Thanks for the notice, was about to start designing systems around using instance ID's between restarts
-
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; }
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; }