# Creating New Admin Panel Menu

{% hint style="warning" %}
All Admin Panel classes must be placed under namespace **Plugin.AdminPanel**
{% endhint %}

### Class Functions

* Init() - <mark style="color:green;">\[OPTIONAL]</mark> class initialization.
* OnOpen() - <mark style="color:green;">\[OPTIONAL]</mark> called when player clicks on tab.
* GetName() - <mark style="color:yellow;">\[REQUIRED]</mark> return displayed tab name, return string \[DEFAULT: "Unknown"].

### Local Properties

* adminPanel - return AdminPanel class.&#x20;

### Local Functions

* SendToEveryone(string FunctionName, params object\[] arguments) - send command to every player to call function with arguments.
* SendToClient(string FunctionName, NetworkConnection connection, params object\[] arguments) - send command to player with connection to call function with arguments.
* SendToServer(string FunctionName, params object\[] arguments) - send command to server to call function with arguments.
* Invoke(Function, float seconds) - same logic as UnityEngine.Object.Invoke, call function after time.

### Example

```csharp
using System.Collections.Generic;
using UnityEngine;

namespace Plugin.AdminPanel
{
    public class NewPanel : Akequ.Base.AdminPanel
    {
        Transform gridLayout;

        public override string GetName()
        {
            return "New Panel";
        }

        public override void OnOpen()
        {
            gridLayout = adminPanel.CreateGridLayout().transform;
            gridLayout.parent.parent.localPosition = new Vector3(0, 44.2f, 0);
            gridLayout.parent.parent.GetComponent<RectTransform>().sizeDelta = new Vector2(511, 340);
            GameObject button = gridLayout.GetChild(0).gameObject;
            int randomItemCount = Random.Range(5, 15);
            for (int i = 0; i < randomItemCount; i++)
            {
                GameObject b = GameObject.Instantiate(button, gridLayout);
                string itemName = "Item_" + i;
                b.name = "Item_" + i;
                b.SetActive(true);
                b.GetComponentInChildren<UnityEngine.UI.Text>().text = itemName;
                UIManager.BindAction(b.GetComponent<UnityEngine.UI.Button>().onClick, () => { ItemPressed(itemName); });
            }
            Transform giveMe = adminPanel.CreateButtonWithHeader("Press Me", "Press Me X2").transform;
            giveMe.localPosition = new Vector3(0, -185, 0);
            UIManager.BindAction(giveMe.GetComponent<UnityEngine.UI.Button>().onClick, GiveMe);
        }

        void GiveMe()
        {
            SendToServer("TestServer", "PRESSED X2");
        }

        void ItemPressed(string str)
        {
            SendToServer("TestServer", str);
        }

        public void TestServer(string item, Mirror.NetworkConnectionToClient conn)
        {
            Player admin = PlayerUtilities.GetServerPlayer(conn);
            if (admin.isAdmin)
            {
                Debug.Log("Got from client item: " + item);
            }
        }
    }
}
```

Example Solution can be downloaded here:\
[Link to archive](https://drive.google.com/file/d/1VqLwyp9sPjwGg9c818mNnxuyP1deiCQh/view?usp=drive_link)

### Testing

Now we can compile this plugin and move library to server plugins folder according to [Folder Structure](/scp-classified-site-plugin-api/docs/folder-structure.md)\
\
Now we can see our new window in admin panel:

<figure><img src="/files/7MWmmtLKzBCNtnzwGlhm" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://akequ.gitbook.io/scp-classified-site-plugin-api/docs/creating-new-admin-panel-menu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
