Hooks

Methods

Methods

object OnClientConnected(ClientProxy clientProxy)

  • Description: Invoked when a client has connected to the server.

object OnClientDisconnected(ClientProxy clientProxy)

  • Description: Invoked when a client has disconnected.

object OnDamageToPlayerCalculated(float damage, float hitDistance, IEntityProxy entity, string itemIdentifier, PlayerHitType hitType)

  • Description: Called after damage to player has been calculated.
  • Parameters:
    • hitDistance: distance from player camera position to hit validation point, which may not necessarilybe the actual point on the model

object OnHandleChatCommand(ClientProxy clientProxy, List<string> args)

  • Description: Called before handling a user's chat command, return non-null to cancel default behaviour. Note that it is not recommended to cancel default commands.

object OnBeforePickRandomPlayerForCrateSpawn(List<PlayerProxy> players)


object OnTeamNameOverride(PlayerTeam team)


object OnRoundEnded()


object OnZombiesSelected(List<PlayerProxy> randomPlayers)

  • Description: Called when players have been selected in the zombie gamemode. Return List to override selected zombies. You could use this to e.g. give certain players reduced chance to become zombie after they just were zombies, or other custom selection logic.

object OnMapGamemodePoolInitialized(List<MapGamemodePair> mapGamemodePool)

  • Description: Called when the map/gamemode pool has been initialized. This is useful if you want to exclude some maps or gamemodes via script. Return a list of to override the initialized pool, the initialized pool will be then used for random maps in map votes.

object OnMapVoteStart(List<MapGamemodePair> mapGamemodePairs)

  • Description: Called right before the map vote starts. Note that there is a maximum number of votemap entries, and extra entries are removed. Return a list of to override the maps used for the map vote.

object Tick()

  • Description: Called every server tick. This could be used for e.g. timers, state machine logic, visibility checks, distance checks.

object OnAnyPlayerDestroyed(PlayerProxy playerProxy)

  • Description: Called when the player object is destroyed. This can happen if e.g. client disconnects or starts spectating.

object OnPlayerRespawnTimerStart(PlayerProxy playerProxy)

  • Description: Called right before player's respawn timer is started. Return an integer to override the respawn time.

object OnPlayerRespawned(PlayerProxy playerProxy)

  • Description: Called when the player respawns (not for the first spawn!).

object OnPlayerDied(PlayerProxy playerProxy)

  • Description: Called when player dies.

object OnSelectTeam(PlayerProxy playerProxy, PlayerTeam team)

  • Description: Called when player's next team is being set. Return a PlayerTeam value to override the team. This is the hook used forcing zombie team in zombie gamemode.

object OnSpawnPlayer(PlayerProxy playerProxy)

  • Description: Called right before spawning player at a position. Return a Vector3 to override the spawnpoint.

object OnAnyPlayerSpawned(PlayerProxy playerProxy)

  • Description: Called when the player is spawned for the first time.

object OnSetSpawnProtectionTimer(PlayerProxy playerProxy, float default_spawn_protection_time)

  • Description: Called when the player's spawn protection timer is being set. Return a float value to override the default spawn protection time for the specific player.

object OnAnyPlayerDamaged(PlayerProxy playerProxy, float health, float damageAmount)


object OnAnyPlayerHealed(PlayerProxy playerProxy, float newHealth, float healAmount)


object OnFallDamageCalculated(PlayerProxy playerProxy, float fallDamage, float y_distance)

  • Description: Called after fall damage has been calculated for a player. Return a float value to override the fall damage. Return exactly 0 to cancel the fall damage.

object OnSelectClass(PlayerProxy playerProxy, string identifier)

  • Description: Called when trying to initialize player to use new class. Returning class identifier string will override the used class (and for the moment select some default items and blueprints). This is useful for when you want to force player to use certain class when player respawns (e.g.zombie).

object CanJoinTeam(PlayerTeam newTeam, int clientId)

  • Description: Called when players next team is being selected. Return true to allow joining to team. Return string to disallow joining to team (string will be used as error message)

object OnPreGameEnvironmentAndConfigurationReset()

  • Description: Called right before reseting game environment and configuration. This is useful if you need e.g. change available classes for next round.

object OnGameEnvironmentAndConfigurationReset()

  • Description: Called when round has started and game environment and configuration has been reset.

object CanSelectClass(string identifier)


object OnVoteOutcomeDetermined(List<int> votes, int indexOfMaxVotes, VoteType voteType)

  • Description: Return negative integer to cancel the vote. Return a non-negative integer that is index to the votes list to override the outcome of the vote.

object OnPlayerDestroyVoxels(PlayerProxy playerProxy, List<Vector3Int> destroyVoxelsList)

  • Description: Called right before actually destroying voxels. Modify the list to change which voxels will be destroyed. Useful for e.g. protecting a certain area from destruction. Note: this only protects against direct destruction (not necessarily against structure collapse)

object OnPlayerDestroyedVoxels(PlayerProxy playerProxy, List<Vector3Int> destroyVoxelsList)

  • Description: Invoked when voxels are destroyed. Note: this includes only voxels directly destroyed by player, not falling voxels.

object OnPlayerDestroyedVoxelsAmount(PlayerProxy playerProxy, int numDestroyedVoxels)

  • Description: Invoked after player has destroyed voxels (at least 1). This has all of the voxels including falling voxels.

object OnPlayerPlacedVoxels(PlayerProxy playerProxy, List<Vector3Int> placedVoxelPositions, Color color)

  • Description: Invoked when player places voxels using block or block gun.

object OnPlayerPlacedVoxelStructure(PlayerProxy playerProxy, List<Vector3Int> placedVoxelPositions, Color color)

  • Description: Invoked when player places voxel structure (blueprint) for example a wall or a tower.

object OnHitscanTurretFireAtEntity(float damage)

  • Description: Invoked when hitscan (ie. bullet) turret is going to fire and damage an entity. Return a float to override the damage.

object OnWorldLoaded(string mapName)

  • Description: Called right after the world has been loaded.
  • Parameters:
    • mapName: name of the loaded map

object OnDamaged(IEntityProxy initiator, IEntityProxy target, DamageAmount damageAmount, DamageType damageType, OwnerInfo ownerInfo, string used_item_identifier)

  • Description: Invoked if entity is damaged. Every entity damage event invokes this callback.
  • Parameters:
    • initiator: initiator entity who initiated the damage. this may be null e.g. if server is the initiator
    • target: damage receiver
    • ownerInfo: owner info of the owner of the damage, this may or may not be the initiator. if for example turret shoots at player, initiator is the turret but owner info is the turrets owner (player, bot, etc.)
    • used_item_identifier: used item identifier, this may be null

object OnKilled(IEntityProxy initiator, IEntityProxy target, DamageAmount damageAmount, DamageType damageType, OwnerInfo ownerInfo, SystemKillReason systemKillReason, string used_item_identifier)

  • Description: Invoked when entity is killed.
  • Parameters:
    • initiator: may be null if e.g. server is the initiator
    • ownerInfo: owner info of the owner of the damage, this may or may not be the initiator. if for example turret shoots at player, initiator is the turret but owner info is the turrets owner (player, bot, etc.)
    • systemKillReason: kill reason, this is non default only when killed by the system (e.g. player switched teams)
    • used_item_identifier: used item identifier, this may be null

object OnExplosion(Vector3 position, IExplosionData explosionData, OwnerInfo ownerInfo, IEntityProxy initiatorEntity, string used_item_identifier)

  • Description: Called right before explosion is about to happen. Return non-null to cancel the explosion.
  • Parameters:
    • ownerInfo: Owner of the explosion.
    • initiatorEntity: Initiator of the explosion (may be null)
    • used_item_identifier: Item used for the explosion (may be null)

object OnExploded(Vector3 position, IExplosionData explosionData, OwnerInfo ownerInfo, IEntityProxy initiatorEntity, string used_item_identifier)

  • Description: Called right after explosion occured.
  • Parameters:
    • ownerInfo: Owner of the explosion.
    • initiatorEntity: Initiator of the explosion (may be null)
    • used_item_identifier: Item used for the explosion (may be null)

object OnCanRegenerateCheck(IEntityProxy entityProxy)

  • Description: Called when checking if the entity can auto regenerate health. Return non-null to cancel default behaviour.
  • Parameters:
    • entityProxy: Entity that is about to regenerate health.