1. I'm trying to add players to cupboard with a command but keep getting "Add requires a non null target object" using:

    Code:
    playerSteamID = rust.UserIDFromPlayer(player)
        priv = global.BasePlayer._type:GetField("buildingPrivlidges", rust.PrivateBindingFlag())
        privb = priv:GetValue(player)
        for i = 0, privb.Count -1 do
            bldpriv[i].authorizedPlayers.Add(playerSteamID)
        end
    What am I doing wrong or is it possible? Thanks.
     
    Last edited by a moderator: Sep 29, 2015
  2. Calytic

    Calytic Community Admin Community Mod

    Check out my plugin EntityOwner

    I have code in there which adds a player to the authorization list of all nearby cupboards.
     
    Last edited: Sep 30, 2015
  3. Thanks. I'll take a look at it.
     
  4. is removing a player's authorization just as simple as :
    Code:
     priv.authorizedPlayers.Remove(new ProtoBuf.PlayerNameID()
                                        {
                                            userid = target.userID,
                                            username = target.displayName
                                        });
     
  5. Calytic

    Calytic Community Admin Community Mod

    Nope, you have to loop through all the PlayerNameID instances, find the one that matches your target userID, then remove the instance.

    There may be a shortcut to do this but your approach will most likely lead to the old PlayerNameID remaining in the list.