If we create a box using "GameManager.server.CreateEntity" how can we uniquely identify it (since it doesn't belong to a player OR assign it to a player?
Solved GameManager.server.CreateEntity
Discussion in 'Rust Development' started by isuelt, Feb 19, 2016.
-
Here's a snippet example:
Code:[ChatCommand("boxhere")] private void cmdBoxHere(BasePlayer player, string command, string[] args) { var box = GameManager.server.CreateEntity("assets/prefabs/deployable/large wood storage/box.wooden.large.prefab", player.transform.position, new Quaternion(), true); box.OwnerID = player.userID; box.Spawn(true); }
-
Great !!
Is there anyway to track this box with a unique ID? -
I'm not sure if there's a native way to track entities, but you could make it in a plugin much like Entity Owner does, but in this case, just for boxes. -
maybe:
Code:box.name = uniqueID
-
net.ID
So in this case
Code:List<uint> boxIDs = new List<uint>(); [ChatCommand("boxhere")] private void cmdBoxHere(BasePlayer player, string command, string[] args) { var box = GameManager.server.CreateEntity("assets/prefabs/deployable/large wood storage/box.wooden.large.prefab", player.transform.position, new Quaternion(), true); box.OwnerID = player.userID; box.Spawn(true); boxIDs.Add(box.net.ID); }
-
-
Sorry, I thought that the need to save that data was obvious. I was merely telling isuelt what to use for a unique ID, the question didn't ask what to do with it once he has it
Last edited by a moderator: Feb 19, 2016 -
Thanks for the help guys !
Another question: How do I access vars in one plugin that are set in another.
For instance: Plugin A (LUA) has an array var that Plugin B (C#) need to check
Or is it just better to have Plugin A set a value in a file/DB in which Plugin B can check ? -
Wulf Community Admin
-
DUH ! Sorry for the dumb question! I was just thinking about it wrong.
Thanks @Wulf