Code:object OnRunCommand(ConsoleSystem.Arg arg) { string message = arg.GetString(0); BasePlayer player = arg.connection.player as BasePlayer; if (permission.UserHasPermission(player.UserIDString, "commandblock.have")) { if (message.StartsWith("/")) { SendReply(player,"You are expelled. Chat commands don't work for you."); } return true; } return null; }
Want to just restrict every command for someone who got the perm .
Commands still run :s
Blocking all commands if permission set?
Discussion in 'Rust Development' started by Crushed, May 22, 2016.
-
Wulf Community Admin
You'll likely need to hook into OnPlayerChat if you are trying to handle chat commands, the OnRunCommand hook is only for console commands.
-
Did that change?
The docs still state: "Useful for intercepting commands before they get to their intended target (like chat.say)" -
Wulf Community Admin
That is a console command. -
Sure, but all chat commands (and chat messages) are effectively executed as chat.say (or atleast they used to), meaning OnRunCommand can (could?) handle chat commands and chat messages as well.
I'm not saying that it'd be the best approach, since OnPlayerChat exists, but I'm wondering whether it's still the case that OnRunCommand can be used to work with all chat messages and commands. -
Wulf Community Admin
You can, you'd just need to handle it using a check like you mentioned. The hooks will all be getting overhauled for Covalence, so this is something we'll likely tidy up. -
OnPlayerChat
void OnPlayerChat(ConsoleSystem.Arg arg)
{
Puts("OnPlayerChat works!");
}
- Called when a player sends chat to the server
- Returning true overrides default behavior of chat, not commands
- Not commands..... so.... its useless for what i wanted it? -
-snip-
OnPlayerChat for chat commands, OnRunCommand for commands.
OnRunCommand can be used for both as well. -
Wulf Community Admin
Chat commands are chat, and can be handled in that hook. You can use OnRunCommand thought like @sqroot mentioned, you'd just need to check for chat.say as the command as well as check the message from the chat to see what command it is. If you want to just handle chat commands, then it would work with either hook. -
aaaaaah..... i got it wrong. xd yea. " not commands" there are ment the console ones. Allright. Thanks
