I'm trying to add players to cupboard with a command but keep getting "Add requires a non null target object" using:
What am I doing wrong or is it possible? Thanks.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
Adding cupboard auth list?
Discussion in 'Rust Development' started by insane8472, Sep 29, 2015.
-
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 -
Thanks. I'll take a look at it.
-
is removing a player's authorization just as simple as :
Code:priv.authorizedPlayers.Remove(new ProtoBuf.PlayerNameID() { userid = target.userID, username = target.displayName }); -
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.
