Hi,
i want to deny admins to build.
But now nobody can build.
Is this the right way?Code:bool CanBuild(Planner plan) { BasePlayer player = plan.GetOwnerPlayer(); if (player.IsAdmin()) { SendReply(player, "Buildung not allowd!"); return false; } else { return true; } }
Info: I don't want to use the Oxide permission system
Player can't build #c canbuild
Discussion in 'Rust Development' started by Sir BenSon, Oct 6, 2016.
-
Wulf Community Admin
You should have a default return in there too after the if check. I don't think that code would compile without that.
-
The code compile successfully. but everybody get the info Building not allowd. I'm wondering because it checks if the player is an admin...
[DOUBLEPOST=1475757708][/DOUBLEPOST]Ok only admins get the message with building not allowd. All other players didnt get the message but they cant build too. CanBuild is a bool and i think it must work with return true?! -
Wulf Community Admin
Actually, CanBuild is an object right now, so you'd need to return null for it to allow building. Returning true/false or anything that isn't null will block building. Generally Can hooks are bools, and this one ideally should be, but isn't currently. -
Code:
object CanBuild(Planner plan, Construction prefab) { if (plan == null || plan.GetOwnerPlayer() == null) return null; if (plan.GetOwnerPlayer().IsAdmin()) { SendReply(plan.GetOwnerPlayer(), "You are not allowed to build!"); return false; } return null; } -
Wulf Community Admin
I'd store the player once at the start though and check that for null instead of grabbing it twice.
-
writing lazyness
