Skip to content

Custom scripts

Dat Nardo edited this page Jan 10, 2024 · 2 revisions

To add a custom script, make a script that inherits from CustomMod, then after add it to your GameObject. Make sure you use ModStart for your Start method

  • Make sure it has a SocketView and rpcsender component

Mod Functions

Player GetLocalPlayer(): Returns the local player info Player GetHostPlayer(): Returns the host player info Player GetPlayerInfo(GameObject playerobj): Returns the player info of a GameObject Gameobject GetNearestPlayer: Returns the nearest GameObject with the "Player" tag DamagePlayer(GameObject PlayerObject, object[] options): Damages a Player GameObject:

  • options[0] = sender (string)
  • options[1] = damage (float)

Events

OnWeaponDamage(float Damage){ }: Called when the GameObject is hit with a raycast from a weapon onplayerspawn(){ }: Called on player join For modded events: look at RPCs

Methods on Player object using GameObject.SendMessage

"toggleweapons" - Toggles weapons on the Player

Mod Variables

CustomMod

(You can access all values from within your CustomMod script by referencing the object name) SocketView view: The the current SocketView bool hosting: Returns true if you are the host of a room

SocketView

string owner: The owner ID of the SocketView string moddedowner: The owner ID of the SocketView (set to the same as owner by default) bool islocal: Returns if the SocketView is local string viewid: The ID of the SocketView

Player

GameObject gameObject: Returns the GameObject of the player bool islocal: Returns if the player is local bool hosting: Returns if the player is the host string playerid: Returns the player id string playername: Returns the name of the player float health: Returns the current health of the player int team: Returns the value of which team the player is on bool hasweapons: Returns if weapons are enabled for a specific player bool chatting: True if chatting bool paused: True if paused

CustomScripts (2): Custom Script Example:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using BracketProto.Modding;


[RequireComponent(typeof(SocketView))]
[RequireComponent(typeof(rpcsender))]
public class ModClassName : CustomMod{
  public void ModStart(){
    //your start function
  }
  void Update(){
    //your update function
  }
  public void ReceiveModRPC(ModRPC RPC){
    //receiving RPCs
  }
  public void onplayerspawn(){
    //called on player join
  }
}

Clone this wiki locally