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 Item Class

All Item classes must be placed under namespace Plugin.Items

Some code will not work in 1.1 version. This page will be updated later.

Class Functions

  • Init() - [OPTIONAL] class initialization(called when item spawned, both on Player and ItemPickup).

  • Update() - [OPTIONAL] called every frame on clients.

  • ServerUpdate() - [OPTIONAL] called every frame on server.

  • OnPickup() - [OPTIONAL] called when item pickuped(on Player).

  • OnDrop() - [OPTIONAL] called when item dropped(on Player).

  • OnUse() - [OPTIONAL] called when Player use this item.

  • OnHolster() - [OPTIONAL] called when Player holster this item.

  • OnDestroy() - [OPTIONAL] called on class destroy.

  • [1.1] CanDrop() - [OPTIONAL] return true if item can be dropped [DEFAULT: true].

  • [1.1] CanEquip() - [OPTIONAL] return true if player can equip item [DEFAULT: true].

  • [1.1] CanHolster() - [OPTIONAL] return true if player can holster item [DEFAULT: true].

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

  • GetImage() - [REQUIRED] return image ID that displayed in inventory, return string [DEFAULT: "item"].

  • OnRefine(int type) - [OPTIONAL] return item ID(empty to destroy item) when item used in SCP-914(type: 0 - rough, 1 - coarse, 2 - 1:1, 3 - fine, 4 - very fine), return string [DEFAULT: ""].

  • GetKeyData() - [OPTIONAL] return information about key card, return KeyData class [DEFAULT: null].

Local Properties

  • player - return current Player class, if player contains it in inventory.

  • itemPickup- return current ItemPickup class, if item dropped.

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.Items
{
    public class NewCard : Akequ.Base.Item
    {
        private GameObject model;

        private KeyData keyData = new KeyData()
        {
            containment = 1
        };

        public override void Init()
        {
            model = ResourcesManager.SpawnObject("item_w_key");
            if (player == null)
            {
                model.transform.parent = itemPickup.transform;
                model.transform.localPosition = Vector3.zero;
                model.transform.localRotation = Quaternion.identity;
            }
            else
            {
                model.transform.parent = player.GetBoneTransform("mixamorig:RightHand");
                model.transform.localPosition = new Vector3(-0.002f, 0.165f, 0.032f);
                model.transform.localRotation = Quaternion.Euler(182.021f, -272.248f, -287.107f);
                model.transform.localScale = new Vector3(0.05174018f, 0.06509144f, -0.04974974f);
            }

            model.layer = 6;
            model.GetComponent<MeshRenderer>().sharedMaterial = ResourcesManager.GetObject("mat_key_janitor") as Material;
        }

        public override void OnDrop()
        {
            if (model != null)
            {
                GameObject.Destroy(model);
            }
        }

        public override void OnPickup()
        {
            if (model != null)
            {
                GameObject.Destroy(model);
            }

            if (player.isLocalPlayer)
            {
                model = ResourcesManager.SpawnObject("item_v_key");
                model.transform.parent = player.transform.Find("Recoil/MainCamera");
                model.transform.localPosition = Vector3.zero;
                model.transform.localRotation = Quaternion.identity;
                model.transform.localScale = new Vector3(-0.05f, 0.05f, 0.05f);
                model.GetComponentInChildren<SkinnedMeshRenderer>().sharedMaterial = (Material)ResourcesManager
                    .GetObject(
                        player.playerClass.GetHand());
            }
            else
            {
                model = ResourcesManager.SpawnObject("item_w_key");
                model.transform.parent = player.GetBoneTransform("mixamorig:RightHand");
                model.transform.localPosition = new Vector3(-0.002f, 0.165f, 0.032f);
                model.transform.localRotation = Quaternion.Euler(182.021f, -272.248f, -287.107f);
                model.transform.localScale = new Vector3(0.05174018f, 0.06509144f, -0.04974974f);
            }
            model.GetComponentInChildren<MeshRenderer>().sharedMaterial = ResourcesManager.GetObject("mat_key_janitor") as Material;
            model.SetActive(false);
        }

        public override void OnUse()
        {
            model.SetActive(true);
            player.SetHandAnim(4);
            if (player.isLocalPlayer)
            {
                UIManager.SetMobileButtons(new List<string>(){ "Move", "Rotate", "Pause", "PlayerList", "Interact", "Jump", "Run",
                    "Inventory", "Voice" });
            }
        }
        
        public override void OnHolster()
        {
            model.SetActive(false);
            player.SetHandAnim(0);
            if (player.isLocalPlayer)
            {
                UIManager.SetMobileButtons(new List<string>(){ "Move", "Rotate", "Pause", "PlayerList", "Interact", "Jump", "Run",
                    "Inventory", "Voice" });
            }
        }

        public override string GetName()
        {
            return "NewCard";
        }
        
        public override string GetImage()
        {
            return "inv_key_janitor";
        }
        
        public override KeyData GetKeyData()
        {
            return keyData;
        }

        public override string OnRefine(int mode)
        {
            int rand = Random.Range(0, 100);
            if (mode == 2 && rand < 25)
                return "RecruitCard";
            else if (mode == 2 && rand < 50)
                return "AssistantCard";
            else if (mode == 2 && rand < 75)
                return "JanitorCard";
            else if (mode == 2 && rand <= 100)
                return "FoundationAgentCard";
            else if (mode == 3)
                return "EngineerCard";
            else if (mode == 4 && rand < 75)
                return "ContainmentSpecialistCard";
            return "";
        }
    }
}

Testing

Now we can compile this plugin and move library to server plugins folder according to Folder Structure Now we can spawn our item:

PreviousCreating New Player ClassNextCreating New Room Event

Last updated 2 months ago

Example Solution can be downloaded here:

Link to archive