示例#1
0
    void OnDialogClick(DialogClickArgs args)
    {
        string name = null;
        PermissionSignType type = PermissionSignType.Player;
        if (args.GetWidgetId() == "UsePermissionSign_OK")
        {
            name = args.GetTextBoxValue()[1];
            type = PermissionSignType.Player;

            for (int i = 0; i < server.serverClient.Groups.Count; i++)
            {
                Group g = server.serverClient.Groups[i];
                if (name == g.Name)
                {
                    type = PermissionSignType.Group;
                }
            }
        }
        else if (args.GetWidgetId().StartsWith("PermissionSignGroup"))
        {
            for (int i = 0; i < server.serverClient.Groups.Count; i++)
            {
                Group g = server.serverClient.Groups[i];
                if (args.GetWidgetId() == "PermissionSignGroup" + g.Name)
                {
                    name = g.Name;
                    type = PermissionSignType.Group;
                }
            }
        }
        else
        {
            //Return when dialog is not a sign
            return;
        }

        ClientOnServer c = server.clients[args.GetPlayer()];
        ServerEntityId id = c.editingSign;
        if (name != "")
        {
            c.editingSign = null;
            ServerEntity e = server.GetEntity(id.chunkx, id.chunky, id.chunkz, id.id);
            e.permissionSign.name = name;
            e.permissionSign.type = type;
            server.SetEntityDirty(id);
        }
        else
        {
            server.DespawnEntity(id);
        }
        server.SendDialog(args.GetPlayer(), "UseSign", null);
    }
示例#2
0
 void OnDialogClick(DialogClickArgs args)
 {
     if (args.GetWidgetId() != "UseSign_OK")
     {
         //Return when dialog is not a sign
         return;
     }
     var c = server.clients[args.GetPlayer()];
     string newText = args.GetTextBoxValue()[1];
     ServerEntityId id = c.editingSign;
     if (newText != "")
     {
         c.editingSign = null;
         ServerEntity e = server.GetEntity(id.chunkx, id.chunky, id.chunkz, id.id);
         e.sign.text = newText;
         server.SetEntityDirty(id);
     }
     else
     {
         server.DespawnEntity(id);
     }
     server.SendDialog(args.GetPlayer(), "UseSign", null);
 }