DoesPlayerHaveAccessToCommand: Difference between revisions
(Created page with "Checks whether a player has access to the given command based on the ACL. ==Syntax== {{#tag:pre|{{Template:CSharp_Serverside_namespace}}ACL.DoesPlayerHaveAccessToCommand(Clie...") |
No edit summary |
||
| (5 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Checks whether a player has access to the given command based on the ACL. | Checks whether a player has access to the given command based on the ACL. | ||
{{CSharpContainer| | |||
{{#tag:syntaxhighlight|bool {{Template:CSharp_Serverside_namespace}}ACL.DoesPlayerHaveAccessToCommand(Client player, string cmd);|lang=csharp}} | |||
{{Parameters}} | {{Parameters}} | ||
*'''player:''' parameter input should be in '''Client''' type | *'''player:''' parameter input should be in '''Client''' type | ||
*'''cmd:''' parameter input should be in '''string''' type | |||
{{Example}} | {{Example}} | ||
{{#tag:syntaxhighlight| | |||
[Command("logout", ACLRequired = true)] | [Command("logout", ACLRequired = true)] | ||
public void LogoutCommand(Client sender) | public void LogoutCommand(Client sender) | ||
{ | { | ||
if (! | if (!{{Template:CSharp_Serverside_namespace}}ACL.DoesPlayerHaveAccessToCommand(sender, "logout")) | ||
{ | { | ||
sender.SendChatMessage("~r~You | sender.SendChatMessage("~r~You can't use that command."); | ||
return; | return; | ||
} | } | ||
{{Template:CSharp_Serverside_namespace}}ACL.LogoutPlayer(sender); | |||
sender.SendChatMessage("~g~You have been logged out."); | sender.SendChatMessage("~g~You have been logged out."); | ||
} | } | ||
|lang=csharp}} | |||
}} | }} | ||
[[Category:Serverside API]] | [[Category:Serverside API]] | ||
Latest revision as of 20:41, 27 November 2019
Checks whether a player has access to the given command based on the ACL.
C# Syntax
bool NAPI.ACL.DoesPlayerHaveAccessToCommand(Client player, string cmd);
Parameters
- player: parameter input should be in Client type
- cmd: parameter input should be in string type
Example
[Command("logout", ACLRequired = true)]
public void LogoutCommand(Client sender)
{
if (!NAPI.ACL.DoesPlayerHaveAccessToCommand(sender, "logout"))
{
sender.SendChatMessage("~r~You can't use that command.");
return;
}
NAPI.ACL.LogoutPlayer(sender);
sender.SendChatMessage("~g~You have been logged out.");
}