SCP: Classified Site Plugin API
  • Quick Start
  • DOCS
    • Folder Structure
    • Creating Plugin Project
    • Creating New Player Class
    • Creating New Item Class
    • Creating New Room Event
    • Creating Additional Networked Class
    • Creating New Admin Panel Menu
    • Abilities
    • Replacing Game Logic
    • Plugin Classes/Game Classes Limitations
  • ID's
    • Inventory Image ID
    • Material ID
    • Team ID
    • Hook ID
  • Game C# Classes
    • ACES
    • AdminPanel
    • Button
    • Config
    • CustomLogger
    • DamageHandler
    • DeadBox
    • DoorManager
    • HitBox
    • HookManager
    • IInteractable
    • InputController
    • ItemPickup
    • Lever
    • NetRoom
    • NetworkedButton
    • NetworkedEvent
    • Player
    • PlayerUtilities
    • ResourcesManager
    • ScriptHelper
    • Trigger
    • UIManager
    • Door
    • SupportManager
    • RoundManager
    • Elevator
  • Another C# Classes
    • Rooms
    • Player Classes
    • Items
    • Admin Panel
Powered by GitBook
On this page
  • Class Functions
  • Local Properties
  • Local Functions
  • Example
  • Testing
  1. DOCS

Creating New Admin Panel Menu

All Admin Panel classes must be placed under namespace Plugin.AdminPanel

Class Functions

  • Init() - [OPTIONAL] class initialization.

  • OnOpen() - [OPTIONAL] called when player clicks on tab.

  • GetName() - [REQUIRED] return displayed tab name, return string [DEFAULT: "Unknown"].

Local Properties

  • adminPanel - return AdminPanel class.

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

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);
            }
        }
    }
}

Testing

Now we can compile this plugin and move library to server plugins folder according to Folder Structure Now we can see our new window in admin panel:

PreviousCreating Additional Networked ClassNextAbilities

Last updated 2 months ago

Example Solution can be downloaded here:

Link to archive