Hello guys,
I am calling a hook which returns a bool depending on if a dictionary contains a specific key(BasePlayer)
(Here is the hook)
Here is my checkCode:private bool isInGame(BasePlayer player) { Dictionary<BasePlayer, GGPlayer> _players = players; if (player == null || _players == null) return false; if (_players.ContainsKey(player)) return true; return false; }
Now when ever Gp isnt running this returns an error, when its running it works, looks like its failing to get the dictionary info. any ideas? I tried checking if the plugin is loaded first however this doesn't work. I am guessing the fact the plugin is compiled on the spot it causing issues here.Code:[PluginReference("Gp")] Plugin Gp; bool GetPlayerInGame(BasePlayer player) { if (Gp.IsLoaded) { object GetPlayerInGame = Gp?.Call("isInGame", player); return (bool)GetPlayerInGame; } return false; }
Details on how plugins are loaded
Discussion in 'Rust Development' started by Rakeki, Apr 3, 2016.
-
Wulf Community Admin
I don't think it's an issue with how the plugin is loaded. Are you getting compile errors, or just errors during use?
Also, what is the purpose of the isInGame function? Rust already has a player.IsConnected() function. -
It's a Gamemode, meaning it is for checking if the player has joined that game.
-
If its a gamemode and you want to check if a player is in it I just use a list or a class with MonoBehaviour. Examples:
Code:public List<BasePlayer> ActivePlayers = new List<BasePlayer>();if(ActivePlayers.Contains(player)) { //Does contain } else { //Does not contain }[DOUBLEPOST=1459702240][/DOUBLEPOST]The second version of it is mostly used for team based things like TDM or MichealMyers(Which I am creatingCode:private List<MichaelPlayers> MMPlayers = new List<MichaelPlayers>(); class MichaelPlayers : MonoBehaviour { public BasePlayer player; public Team team = Team.Player; public int deaths = 0; public int wins = 0; public int kills = 0; } enum Team { Micheal, Player }
)
