1. Hi,

    i want to deny admins to build.
    But now nobody can build.
    Code:
            bool CanBuild(Planner plan)
            {
                BasePlayer player = plan.GetOwnerPlayer();
                if (player.IsAdmin())
                {
                    SendReply(player, "Buildung not allowd!");
                    return false;
                }
                else
                {
                    return true;
                }
            }
    Is this the right way?
    Info: I don't want to use the Oxide permission system
     
  2. Wulf

    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.
     
  3. 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?!
     
  4. Wulf

    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.
     
  5. 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;
    }
     
  6. Wulf

    Wulf Community Admin

    I'd store the player once at the start though and check that for null instead of grabbing it twice. ;)
     
  7. writing lazyness :p