Hooks & Functions - kirillbrest123/deathmatch-unlimited GitHub Wiki

Functions

Notifications & announcements

  • DMU.SendNotification(string text, player ply) - sends a notification (hint) to a player or all players
    • text - text of the notification
    • ply - (optional) receiver of the notification. If not present, the notification will be sent to all players
  • DMU.SendAnnouncement(string text, number length, string sound, player ply) - sends an announcement to a player or all players
    • text - text of the announcement
    • length - duration of the announcement
    • sound - path to sound that will be played when the announcement is received
    • ply - (optional) receiver of the announcement. If not present, the announcement will be sent to all players

End game & end round

  • DMU.EndGame(winner) - ends the match
    • winner - winner of the game. Can be a team index or a player. If not present, team/player (depends on MODE.FFA) with the highest score will be picked as a winner
  • DMU.EndRound(winner) - ends the round
    • winner - winner of the round. Can be a team index or a player. If not present, the round will end without a winner

Player score

  • plymeta:SetScore(number score) - sets the score of this player
  • plymeta:GetScore() - gets the score of this player
  • plymeta:AddScore(number score) - adds this number to the score of this player

Bot objectives

  • DMU.AddBotObjective(entity) - marks the entity as a bot objective. All bots regardless of their team will walk to this entity
  • DMU.RemoveBotObjective(entity)
  • DMU.AddBotTeamObjective(team_i, entity) - marks the entity as a team bot objective. This has a priority over regular bot objectives
  • DMU.RemoveBotTeamObjective(team_i, entity)
  • DMU.AddBotPersonalObjective(ply, entity) - marks the entity as an objective for a specific bot. This has a priority over regular and team bot objectives
  • DMU.RemoveBotPersonalObjective(ply, entity)

3D2D

Functions below are meant for simple 3D2D stuff. Do not use them if you need to update stuff a lot! Code your own solution instead.

  • DMU.Add3D2DEnt(entity ent, string mat, color color) - adds a 3D2D sprite to an entity. Repeated calls will replace current 3D2D sprite
    • ent - 3D2D sprite will be displayed on this entity. Must exist on client!
    • mat - path to material
    • color - color that will be applied to the material
  • DMU.Remove3D2DEnt(entity ent) - removes a 3D2D sprite from an entity
  • DMU.Add3D2DPos(number index, vector pos, string mat, color color) - adds a 3D2D sprite to this position. Repeated calls will replace current 3D2D sprite
    • index - index that will be used to update and remove the 3D2D sprite attached to this position
    • pos - position to attach a 3D2D sprite to
    • mat - same as above
    • color - same as above
  • DMU.Remove3D2DPos(number index) - removes a 3D2D sprite attached to this position
  • DMU.Sync3D2DEnt() and DMU.Sync3D2DPos() - syncs 3D2D entities and positions with client. They are automatically called by 3D2D functions

Medals

  • DMU.RegisterMedal(string name, string printname, path material) - registers a medal to be used by DMU.GiveMedal(). Can be created on server, but it's required on client
  • DMU.GiveMedal(player ply, string medal) - gives player a medal registered with DMU.RegisterMedal()

Misc

  • plymeta:DMU_SetGravity(number gravity_multiplier) - modifies this player's gravity. Unlike plymeta:SetGravity(), this one is properly predicted (players with ping won't experience lagging)
    • gravity_multiplier - player's gravity will be multiplied by this number
  • DMU.AutoAssign(player ply) - automatically assigns a player to a team with least players

Hooks

Shared

  • DMU_GameEnded(winner) - winner can be a player or a team index
  • DMU_RoundEnded(winner) - winner can be a player or a team index
  • DMU_PreRoundStart() - called after the map has been cleaned-up but before players have been respawned and countdown has started
  • DMU_PlayerReceivedMedal(player ply, string medal) - called after a player has receiver a medal

Server

  • DMU_RoundStart() - called after the countdown ended and players have been unfrozen
  • DMU_HoldZoneScore(entity hill, number team) - a controlled hill will call this hook every 1.2 seconds
    • hill - hill entity
    • team - index of the team that control this hill
  • DMU_TagCollected(entity tag, player ply) - called after a tag has been collected
  • DMU_TimeLimitReached() - called after match/round time limit has been reached. Returning true in this hook will cause it to not execute default behavior (ending round without winners/ending match with some winner)
  • DMU_HoldZoneCaptured(capturing_team, new_team, old_team) - called after a hill has been captured, including both when it was partially and fully captured
    • capturing_team - team which has captured the hill
    • new_team - team which now controls the hill (-1 for none)
    • old_team - team which used to control the hill (-1 for none)