I need to add a null check to this code, incase it doesn't find a player but don't know how to do it. plz help.
var player = BasePlayer.FindByID(cupboard.OwnerID); var player = BasePlayer.FindByID(cupboard.OwnerID); if (BasePlayer.FindByID(cupboard.OwnerID) == null)
return;As you'd probably want to check to see if the player exists before setting the var player.
It would make more sense to set that in a variable, and then check that variable for null before use otherwise you are performing the lookup multiple times.JamieGB
I haven't tested the code, but I assume this would work:if (BasePlayer.FindByID(cupboard.OwnerID) == null) return;As you'd probably want to check to see if the player exists before setting the var player.
var player = BasePlayer.FindByID(cupboard.OwnerID);
if (player == null)
return;