# Creating New Player Class

{% hint style="warning" %}
All Player Classes must be placed under namespace **Plugin.Classes**
{% endhint %}

### Class Functions

* Init() - <mark style="color:green;">\[OPTIONAL]</mark> class initialization.
* Update() - <mark style="color:green;">\[OPTIONAL]</mark> called every frame.
* OnStop() - <mark style="color:green;">\[OPTIONAL]</mark> called on class destroy.
* OnEscape() - <mark style="color:green;">\[OPTIONAL]</mark> called when players escapes(Trigger on surface at Exit B).
* GetHand() - <mark style="color:yellow;">\[REQUIRED]</mark> return hand material ID(required only for classes that can pickup items).
* GetName() - <mark style="color:yellow;">\[REQUIRED]</mark> displayed class name.
* GetTeamID() - <mark style="color:yellow;">\[REQUIRED]</mark> class team.
* GetClassColor() - <mark style="color:yellow;">\[REQUIRED]</mark> class color in HEX.
* GetPlayerInfo(HitBox) - <mark style="color:green;">\[OPTIONAL]</mark> additional information when player looks at someone,  return string \[DEFAULT: ""].
* GetDeadInfo(DeadBox) - <mark style="color:green;">\[OPTIONAL]</mark> additional information when player looks at dead body,  return string \[DEFAULT: ""].
* OnOpenInventory() - <mark style="color:green;">\[OPTIONAL]</mark> can this class open inventory, return boolean \[DEFAULT: false].
* IgnoreSCP() - <mark style="color:green;">\[OPTIONAL]</mark> is this class ignore all scp mechanics, return boolean \[DEFAULT: false].
* CheckpointPass() - <mark style="color:green;">\[OPTIONAL]</mark> can this class open checkpoints without key card, return boolean \[DEFAULT: false].
* CanTakeDamage() - <mark style="color:green;">\[OPTIONAL]</mark> can this class take damage, return boolean \[DEFAULT: true].
* OnTakeDamage(DamageHandler) - <mark style="color:green;">\[OPTIONAL]</mark> called when player takes damage.

### Local Properties

* player - return current Player class.&#x20;
* playerModel - shared property, that must be assigned from player 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

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

namespace Plugin.Classes
{
    public class ExampleClass : Akequ.Base.PlayerClass
    {
        public override void Init()
        {
            player.InitHealth(100, new Color(1f, 0f, 0f, 1f));
            if (player.isLocalPlayer)
            {
                player.PlayBellSound(1);
                UIManager.SetMobileButtons(new List<string>() { "Move", "Rotate", "Pause", "PlayerList", "Interact", "Jump", "Run",
                    "Inventory", "Voice" });
                TransitionManager.ShowClass("#FF8E00", "Test Class Name", "Test Class Decription");
                player.SetSpeed(3.25f, 8.5f);
                player.SetJumpPower(2.5f);
                player.SetFootsteps(ResourcesManager.GetClips("Step1", "Step2", "Step3", "Step4", "Step5", "Step6",
                    "Step7", "Step8"));
                PlayerUtilities.SetVoiceChat("3D", "", false);
            }
            else
            {
                playerModel = GameObject.Instantiate(ResourcesManager.GetObject("ply_classD")) as GameObject;
                playerModel.transform.parent = player.transform;
                playerModel.transform.localPosition = new Vector3(0f, -1.075f, 0f);
                playerModel.transform.localRotation = Quaternion.identity;
                playerModel.transform.localScale = new Vector3(1.45f, 1.45f, 1.45f);
                PlayerUtilities.SpawnHitboxes(player, playerModel);
            }

            if (player.isServer)
            {
                if (player.isClient)
                {
                    Transform[] points = player.GetSpawnPoints("Zone1", "classDSpawn");
                    Vector3 point = points[Random.Range(0, points.Length)].position;
                    player.Teleport(new Vector3(point.x,point.y+1.25f, point.z));
                }
                else
                {
                    GameObject[] points = GameObject.FindGameObjectsWithTag("classDSpawn");
                    Vector3 point = points[Random.Range(0, points.Length)].transform.position;
                    player.Teleport(new Vector3(point.x,point.y+1.25f, point.z));
                }
                player.SetSpeed(3.25f, 8.5f);
            }
        }

        public override void OnStop()
        {
            if (playerModel != null)
            {
                PlayerUtilities.SpawnRagdoll(player, playerModel);
                GameObject.Destroy(playerModel);
            }
            else
            {
                PlayerUtilities.SpawnRagdoll(player, "ply_classD_ragdoll").transform.localScale =
                    new Vector3(1.45f, 1.45f, 1.45f);
            }
        }

        public override string GetHand()
        {
            return "ClassDHand";
        }

        public override bool OnOpenInventory()
        {
            return true;
        }

        public override string GetName()
        {
            return "Test Class Name";
        }

        public override string GetTeamID()
        {
            return "ClassD";
        }

        public override string GetClassColor()
        {
            return "FF8E00";
        }
    }
}
```

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

### 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 force class:<br>

<figure><img src="/files/HxDHqoS6hA8UUHbq4lq2" 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-player-class.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.
