本文整理汇总了C#中IRocketPlayer.GetPermissions方法的典型用法代码示例。如果您正苦于以下问题:C# IRocketPlayer.GetPermissions方法的具体用法?C# IRocketPlayer.GetPermissions怎么用?C# IRocketPlayer.GetPermissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRocketPlayer
的用法示例。
在下文中一共展示了IRocketPlayer.GetPermissions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute(IRocketPlayer caller, string[] msg)
{
bool console = (caller is ConsolePlayer);
string[] permnames = { "shop.*", "shop.add", "shop.rem", "shop.chng", "shop.buy" };
bool[] perms = { false, false, false, false, false };
bool anyuse = false;
string message;
foreach (Permission s in caller.GetPermissions())
{
switch (s.Name)
{
case "shop.*":
perms[0] = true;
anyuse = true;
break;
case "shop.add":
perms[1] = true;
anyuse = true;
break;
case "shop.rem":
perms[2] = true;
anyuse = true;
break;
case "shop.chng":
perms[3] = true;
anyuse = true;
break;
case "shop.buy":
perms[4] = true;
anyuse = true;
break;
case "*":
perms[0] = true;
perms[1] = true;
perms[2] = true;
perms[3] = true;
perms[4] = true;
anyuse = true;
break;
}
}
if (!console)
{
if (((UnturnedPlayer)caller).IsAdmin)
{
perms[0] = true;
perms[1] = true;
perms[2] = true;
perms[3] = true;
perms[4] = true;
anyuse = true;
}
}
if (!anyuse)
{
// Assume this is a player
UnturnedChat.Say(caller, "You don't have permission to use the /shop command.");
return;
}
if (msg.Length == 0)
{
message = ZaupShop.Instance.Translate("shop_command_usage", new object[] {});
// We are going to print how to use
this.sendMessage(caller, message, console);
return;
}
if (msg.Length < 2)
{
message = ZaupShop.Instance.Translate("no_itemid_given", new object[] {});
this.sendMessage(caller, message, console);
return;
}
if (msg.Length == 2 && msg[0] != "rem")
{
message = ZaupShop.Instance.Translate("no_cost_given", new object[] { });
this.sendMessage(caller, message, console);
return;
}
else if (msg.Length >= 2)
{
string[] type = Parser.getComponentsFromSerial(msg[1], '.');
if (type.Length > 1 && type[0] != "v")
{
message = ZaupShop.Instance.Translate("v_not_provided", new object[] { });
this.sendMessage(caller, message, console);
return;
}
ushort id;
if (type.Length > 1)
{
if (!ushort.TryParse(type[1], out id)) {
message = ZaupShop.Instance.Translate("invalid_id_given", new object[] { });
this.sendMessage(caller, message, console);
return;
}
} else {
if (!ushort.TryParse(type[0], out id))
{
message = ZaupShop.Instance.Translate("invalid_id_given", new object[] { });
this.sendMessage(caller, message, console);
//.........这里部分代码省略.........