1. isuelt

    isuelt Shack Builder

    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?
     
  2. Shady757

    Shady757 Master Researcher Plugin Developer

    Here's a snippet example:
    Code (C#):
    [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);
    }
    I tested it and it worked fine for me. Once you spawn it, press f1 and type: "ent who" and it should show you the owner ID.
     
    LaserHydra likes this.
  3. isuelt

    isuelt Shack Builder

    Great !!

    Is there anyway to track this box with a unique ID?
     
  4. Shady757

    Shady757 Master Researcher Plugin Developer


    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.
     
  5. isuelt

    isuelt Shack Builder

    maybe:

    Code (Text):
    box.name = uniqueID
    With the plugin tracking the uniqueID number list. ?
     
  6. k1lly0u

    k1lly0u Grenade Master Plugin Developer

    net.ID
    So in this case
    Code (Text):
    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);
            }
     
  7. Shady757

    Shady757 Master Researcher Plugin Developer

    The only problem with this is that it will reset the list each time the plugin is reloaded, which I suppose isn't a problem if you're not wanting to keep it after server restarts, or making modifications to the plugin.
     
  8. k1lly0u

    k1lly0u Grenade Master Plugin Developer

    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: Feb 19, 2016
    Shady757 likes this.
  9. isuelt

    isuelt Shack Builder

    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 ?
     
  10. Wulf

    Wulf Community Admin Community Admin Oxide Developer

    Create a hook that returns a var in Plugin A, call hook in Plugin B to get that var.
     
  11. isuelt

    isuelt Shack Builder

    DUH ! Sorry for the dumb question! I was just thinking about it wrong.

    Thanks @Wulf
     
  12. Hazzardous

    Hazzardous Naked Wanderer

    its so basic .. uhh brain sore