this is what i've done after reading many posts about it. class is :RustPlugin.
registering permission and adding the chat command;
the command:Code:void Init() { permission.RegisterPermission("saltydeath.admin", this); cmd.AddChatCommand("sddisable", this, "DisableCmd"); }
obviously i got it wrong since it does nothing :/Code:private void DisableCmd(IPlayer player, string command, string[] args) { if (player.HasPermission("saltydeath.admin")) { enableSD = false; Puts("SaltyDeath DISABLED!"); player.Reply("SaltyDeath DISABLED!"); } else { Puts("You don't have the permission to use the sddisable command."); player.Reply("You don't have the permission to use the sddisable command."); } }
[DOUBLEPOST=1529076927][/DOUBLEPOST]ok, got it solved:
Code:void Init() { permission.RegisterPermission("saltydeath.admin", this); }how can i check if the player has a permission using BasePlayer?Code:[ChatCommand("sddisable"), Permission("saltydeath.admin")] private void DisableCommand(BasePlayer player, string command, string[] args) { enableSD = false; Puts("SaltyDeath DISABLED!"); }
Solved Registering a chat command?
Discussion in 'Rust Development' started by TheBandolero, Jun 15, 2018.
-
ok, solved too lol
Code:[ChatCommand("sdenable"), Permission("saltydeath.admin")] private void EnableCommand(BasePlayer player, string command, string[] args) { if (permission.UserHasPermission(player.userID.ToString(), "saltydeath.admin")) { enableSD = true; Puts("SaltyDeath has been ENABLED!"); player.ChatMessage("SaltyDeath has been ENABLED!"); } else { player.ChatMessage("You have no permission to use this command."); } }
