Module GM

Primary Gamemode Bootstrap

Module Overview

Hooks

OnEntityCreated(ent) Called when an entity is created.
PlayerBindPress(ply, bind, press) Called when a player presses a bind.
HUDShouldDraw(name) A function to override whether a HUD element should draw.
HUDDrawTargetID() Called when the target ID should be drawn.
RenderScreenspaceEffects() Called when screen space effects should be rendered.
HUDDrawScoreBoard() Called when the scoreboard should be drawn.
DBConnected() Called after the DB connects.
Initialize() Run the gamemode startup procedure.
PlayerSwitchFlashlight(ply, on) Called when a player switches their flashlight on or off.
OnUpdateDatabase() Called whenever the database is updated.
PlayerUse(ply, ent) Called when a player attempts to use an entity.
PlayerDemote(ply, tgt, from, reason) Called when a player is demoting another player.
PlayerPromoteLeader(ply, tgt, from) Called when a player is promoting another player.
PlayerKnockOut(ply, tgt) Called when a player is knocking out another player.
PlayerWakeUp(ply, tgt) Called when a player is waking up another player.
PlayerArrest(ply, tgt) Called when a player is arresting another player.
PlayerHostage(ply, tgt) Called when a player hostages player.
PlayerUnarrest(ply, tgt) Called when a player unarrests player.
PlayerWarrant(ply, tgt, class) Called when a player warrants a player.
PlayerUnwarrant(ply, tgt) Called when a player unwarrants player.
PlayerCanOwnDoor(ply, door) Called when a player owns a door.
PlayerCanViewDoor(ply, door) Called when a player views a door.
PlayerCanHolster(ply, weapon, silent) Called when a player holsters a weapon.
PlayerCanDrop(ply, weapon, silent, attacker) Called when a player drops a weapon.
PlayerCanUseItem(ply, item, silent) Called when a player attempts to use an item.
PlayerCanDropItem(ply, item, amt, pos) Called when a player attempts to drop an item on the ground.
PlayerCanGiveItem(ply, item, amt, to) Called when a player attempts to give an item to another player.
PlayerCanRemoveItem(ply, item) Called when a player attempts to remove an item.
PlayerCanKnockOut(ply, tgt) Called when a player attempts to knock out another player.
PlayerCanWarrant(ply, tgt) Called when a player attempts to warrant another player.
PlayerCanWakeUp(ply, tgt) Called when a player attempts to wake up another player.
PlayerCanRamDoor(ply, door, silent) Called when a player attempts to ram a door.
PlayerCanUseDoor(ply, door) Called when a player attempts to use a door.
PlayerCanJoinTeam(ply, team) Check if a player can join a team.
PlayerCanDemote(ply, tgt) Called when a player attempts to demote another player.
PlayerCanPromote(ply, tgt) Called when a player attempts to promote another player.
InitPostEntity() Called when all of the map entities have been initialized.
PlayerCanHearPlayersVoice(ply, tgt) Hook function called to check if a player can be heard.
PlayerCanSayIC(ply, text) Check if a player can say IC text.
PlayerCanSayOOC(ply, text) Check if a player can say OOC text.
PlayerCanSayLOOC(ply, text) Check if a player can say Local OOC text.
PlayerCanUseCommand(ply, command, arguments) Check if a player can run a command.
PlayerSaidOOC(ply, msg) Called after a player sends a message in OOC.
PlayerSaidLOOC(ply, msg) Called after a player sends a message in Local OOC.
PlayerSaid(ply, msg, msgType) Called after a player sends a message in chat.
PlayerRanCommand(ply, cmd, args) Called after a command is ran.
PlayerRanAdminCommand(ply, cmd, args) Called after an admin command is ran.
PlayerSay(ply, text, public) Hook function for when any message is sent to the server.
CanPlayerSuicide(ply) Called when a player attempts suicide.
VehicleHPChange(ent, delta, cur) Hook function called when vehicle HP changes.
VehicleHPChanged(veh, new, old) Hook function called after vehicle HP changes.
GravGunPunt(ply, ent) Called when a player attempts to punt an entity with the gravity gun.
PhysgunPickup(ply, ent) Called when a player attempts to pick up an entity with the physics gun.
PhysgunDrop(ply, ent) Called when a player attempts to drop an entity with the physics gun.
PlayerCanArrest(ply, tgt) Called when a player attempts to arrest another player.
PlayerCanUnarrest(ply, tgt) Called when a player attempts to unarrest another player.
PlayerShouldTaunt(ply, act) Called when player tries to act something out.
PlayerSpawnNPC(ply, class, weapon) Called when a player attempts to spawn an NPC.
PlayerSpawnProp(ply, model[, state]) Called when a player attempts to spawn a prop.
PlayerSpawnEffect(ply, mdl) Called when a player attempts to spawn an effect.
PlayerSpawnedProp(ply, mdl, ent) Called when a player has spawned a prop.
PlayerSpawnedEffect(ply, mdl, ent) Called when a player has spawned an effect.
OnEntityCreated(ent) Called when an entity is created.
PlayerSpawnRagdoll(ply, model) Called when a player attempts to spawn a ragdoll.
PlayerSpawnedRagdoll(ply, model, ent) Called when a player has spawned a ragdoll.
PlayerSpawnVehicle(ply, model) Called when a player attempts to spawn a vehicle.
CanTool(ply, trace, tool) Called when a player attempts to use their toolgun.
PlayerNoClip(ply, state) Called when a player attempts to noclip.
PlayerInitialSpawn(ply) Called when a player initially spawns.
PlayerDeathThink(ply) Called every frame that a player is dead.
PlayerCanGainFrag(ply, victim) Hook function called when a player gains a kill.
PlayerSpray(ply) Called when a player should be allowed to spray.
PlayerSetModel(ply) Loadout hook function called when a player's model needs to be set.
PlayerSpawn(ply) Called when a player spawns.
PlayerDeath(ply, inflictor, attacker, ragdoll) Called when a player dies.
ShutDown() Called when the server shuts down or the map changes.
ShowHelp(player) Called when a player presses F1.
ShowSpare2(player) Called when a player presses F4.
ShowTeam(ply) Called when a player presses F2.
EntityTakeDamage(ent, damageInfo) Called when an entity takes damage.
PlayerDisconnected(player) Called when a player has disconnected.
CanExitVehicle(veh, ply) Called to check if a player is able to exit a vehicle.
PlayerSpawnSWEP(ply, class, wep) Called when a player attempts to spawn a SWEP.
PlayerGiveSWEP(ply, class, wep) Called when a player attempts to give a SWEP.
PlayerSpawnSENT(ply, class) Called when attempts to spawn a SENT.
KeyPress(ply, key) Called when a player presses a key.
KeyRelease(ply, key) Called when a player releases a key.
PlayerDeathSound() Called to check if the default death sound should be played.
CheckPassword(id64, ipAddr, svPass, clPass, name) Called when a player joins and attempts to check their password.

Functions

IsUsingCamera() Check if the local player is using the camera.
AdjustMaximumWidth(font, text, width, addition, extra) Adjust WIDTH to be maximum value of (width of text (plus a bit)) or (width)
GetScreenCenterBounce([How=8]) Get the bouncing position of the screen's center.
DrawInformation(text, font, x, y, color, alpha[, left=false[, callback[, shadow=false]]]) Draw Information.
CalculateTime(seconds) Convert seconds to a hours, minutes format.
printf(str, ...) Formatted print to console.
sprintf(str, ...) Formatted return.
ConnectToDatabase() Create DB_MAIN and load our DB instance.
UpdateDatabase() Update the database and player's data.
PlyCanPickupRegular(ply, ent) Can a regular player pickup this entity?
PlyCanPickupAdmin(ply, ent) Can a player with extended access (admin/mod) pickup this entity?
SetupSalary(ply) Set up a player's salary timer.

Tables

entities A table that will hold entities that were there when the map started.
cityrp_server_rules Table for storing the rules.

Hooks

OnEntityCreated(ent)
Called when an entity is created.

Parameters:

  • ent Update the local player variables.
PlayerBindPress(ply, bind, press)
Called when a player presses a bind.

Parameters:

  • ply Player Player pressing the bind.
  • bind string The bind being pressed.
  • press bool If the bind was depressed or unpressed.
HUDShouldDraw(name)
A function to override whether a HUD element should draw.

Parameters:

  • name string HUD element name to draw.
HUDDrawTargetID()
Called when the target ID should be drawn.
RenderScreenspaceEffects()
Called when screen space effects should be rendered.
HUDDrawScoreBoard()
Called when the scoreboard should be drawn.
DBConnected()
Called after the DB connects.

See also:

Initialize()
Run the gamemode startup procedure.
PlayerSwitchFlashlight(ply, on)
Called when a player switches their flashlight on or off.

Parameters:

  • ply Player The player switching their flashlight.
  • on bool The requested flashlight state.
OnUpdateDatabase()
Called whenever the database is updated.

See also:

PlayerUse(ply, ent)
Called when a player attempts to use an entity.

Parameters:

  • ply Player The player using an entity.
  • ent Entity The entity being used.
PlayerDemote(ply, tgt, from, reason)
Called when a player is demoting another player.

Parameters:

  • ply Player The player demoting the target.
  • tgt Player The player being demoted.
  • from number The team they're being demoted from.
  • reason string The reason they're being demoted.
PlayerPromoteLeader(ply, tgt, from)
Called when a player is promoting another player.

Parameters:

  • ply Player The player promoting the target.
  • tgt Player The player being promoted.
  • from number The team they're being promoted to.
PlayerKnockOut(ply, tgt)
Called when a player is knocking out another player.

Parameters:

  • ply Player The player knocking out.
  • tgt Player The player being knocked out.
PlayerWakeUp(ply, tgt)
Called when a player is waking up another player.

Parameters:

  • ply Player The player waking up.
  • tgt Player The player being woken up.
PlayerArrest(ply, tgt)
Called when a player is arresting another player.

Parameters:

  • ply Player The player arresting.
  • tgt Player The player being arrested.
PlayerHostage(ply, tgt)
Called when a player hostages player.

Parameters:

  • ply Player The player hostaging.
  • tgt Player The player being hostaged.
PlayerUnarrest(ply, tgt)
Called when a player unarrests player.

Parameters:

  • ply Player The player unarresting.
  • tgt Player The player being unarrested.
PlayerWarrant(ply, tgt, class)
Called when a player warrants a player.

Parameters:

  • ply Player The player warranting.
  • tgt Player The player being warranted.
  • class string The warrant class.
PlayerUnwarrant(ply, tgt)
Called when a player unwarrants player.

Parameters:

  • ply Player The player unwarranting.
  • tgt Player The player being unwarranted.
PlayerCanOwnDoor(ply, door)
Called when a player owns a door.

Parameters:

  • ply Player The player owning the door.
  • door Entity The door being owned.
PlayerCanViewDoor(ply, door)
Called when a player views a door.

Parameters:

  • ply Player The player viewing the door.
  • door Entity The door being viewed.
PlayerCanHolster(ply, weapon, silent)
Called when a player holsters a weapon.

Parameters:

  • ply Player The player holstering a weapon.
  • weapon Entity The weapon being holstered.
  • silent bool If the holster is silent.
PlayerCanDrop(ply, weapon, silent, attacker)
Called when a player drops a weapon.

Parameters:

  • ply Player The player dropping a weapon.
  • weapon Entity The weapon being dropped.
  • silent bool If the drop is silent.
  • attacker Player The attacker for the player.
PlayerCanUseItem(ply, item, silent)
Called when a player attempts to use an item.

Parameters:

  • ply Player The player using an item.
  • item string The item being used.
  • silent bool If the use is silent.
PlayerCanDropItem(ply, item, amt, pos)
Called when a player attempts to drop an item on the ground.

Parameters:

  • ply Player The player dropping the item.
  • item string The uniqueID of the item being dropped.
  • amt number The amount of items being dropped.
  • pos Vector The position that the items would be created at.
PlayerCanGiveItem(ply, item, amt, to)
Called when a player attempts to give an item to another player.

Parameters:

  • ply Player The player giving the item.
  • item string The uniqueID of the item being given.
  • amt number The amount of items being given.
  • to Player The player being given the items.
PlayerCanRemoveItem(ply, item)
Called when a player attempts to remove an item.

Parameters:

  • ply Player The player removing the item.
  • item string The uniqueID of the item being removed.
PlayerCanKnockOut(ply, tgt)
Called when a player attempts to knock out another player.

Parameters:

  • ply Player The player knocking out.
  • tgt Player The player being knocked out.
PlayerCanWarrant(ply, tgt)
Called when a player attempts to warrant another player.

Parameters:

  • ply Player The player warranting.
  • tgt Player The player being warranted.
PlayerCanWakeUp(ply, tgt)
Called when a player attempts to wake up another player.

Parameters:

  • ply Player The player waking up.
  • tgt Player The player being woken up.
PlayerCanRamDoor(ply, door, silent)
Called when a player attempts to ram a door.

Parameters:

  • ply Player The player ramming the door.
  • door Entity The door being rammed.
  • silent bool If the ram is silent.
PlayerCanUseDoor(ply, door)
Called when a player attempts to use a door.

Parameters:

  • ply Player The player using the door.
  • door Entity The door being used.
PlayerCanJoinTeam(ply, team)
Check if a player can join a team.

Parameters:

  • ply Player The player changing team.
  • team number The new team.
PlayerCanDemote(ply, tgt)
Called when a player attempts to demote another player.

Parameters:

  • ply Player The player demoting the target.
  • tgt Player The player being demoted.
PlayerCanPromote(ply, tgt)
Called when a player attempts to promote another player.

Parameters:

  • ply Player The player promoting the target.
  • tgt Player The player being promoted.
InitPostEntity()
Called when all of the map entities have been initialized.
PlayerCanHearPlayersVoice(ply, tgt)
Hook function called to check if a player can be heard.

Parameters:

  • ply Player The player listening.
  • tgt Player The player speaking.
PlayerCanSayIC(ply, text)
Check if a player can say IC text.

Parameters:

  • ply Player The player talking.
  • text string The words said.
PlayerCanSayOOC(ply, text)
Check if a player can say OOC text.

Parameters:

  • ply Player The player talking.
  • text string The words said.
PlayerCanSayLOOC(ply, text)
Check if a player can say Local OOC text.

Parameters:

  • ply Player The player talking.
  • text string The words said.
PlayerCanUseCommand(ply, command, arguments)
Check if a player can run a command.

Parameters:

  • ply Player The calling player.
  • command string The command being ran.
  • arguments tab The arguments table.
PlayerSaidOOC(ply, msg)
Called after a player sends a message in OOC.

Parameters:

  • ply The player talking in OOC.
  • msg The message which was sent.
PlayerSaidLOOC(ply, msg)
Called after a player sends a message in Local OOC.

Parameters:

  • ply The player talking in LOOC.
  • msg The message which was sent.
PlayerSaid(ply, msg, msgType)
Called after a player sends a message in chat.

Parameters:

  • ply The player talking in LOOC.
  • msg The message which was sent.
  • msgType The type of message sent.
PlayerRanCommand(ply, cmd, args)
Called after a command is ran.

Parameters:

  • ply The player running the command.
  • cmd The command ran.
  • args The arguments list.
PlayerRanAdminCommand(ply, cmd, args)
Called after an admin command is ran.

Parameters:

  • ply The player running the command.
  • cmd The command ran.
  • args The arguments list.
PlayerSay(ply, text, public)
Hook function for when any message is sent to the server.

Parameters:

  • ply Player The talking player.
  • text string The message being sent.
  • public bool If the message is sent in team or global chat.
CanPlayerSuicide(ply)
Called when a player attempts suicide.

Parameters:

  • ply Player Suiciding player.
VehicleHPChange(ent, delta, cur)
Hook function called when vehicle HP changes.

Parameters:

  • ent Entity Vehicle to which the HP change is occuring.
  • delta int HP change
  • cur int Current HP.
VehicleHPChanged(veh, new, old)
Hook function called after vehicle HP changes.

Parameters:

  • veh Vehicle Vehicle to which the change occured.
  • new int Current HP
  • old int Old HP
GravGunPunt(ply, ent)
Called when a player attempts to punt an entity with the gravity gun.

Parameters:

  • ply Player Punting player.
  • ent Entity Punted entity.
PhysgunPickup(ply, ent)
Called when a player attempts to pick up an entity with the physics gun.

Parameters:

  • ply Player Picking up player.
  • ent Entity The entity being picked up.
PhysgunDrop(ply, ent)
Called when a player attempts to drop an entity with the physics gun.

Parameters:

  • ply Player Dropping player.
  • ent Entity The entity being dropped.
PlayerCanArrest(ply, tgt)
Called when a player attempts to arrest another player.

Parameters:

PlayerCanUnarrest(ply, tgt)
Called when a player attempts to unarrest another player.

Parameters:

  • ply Player Picking up player.
  • tgt Player The entity being picked up.
PlayerShouldTaunt(ply, act)
Called when player tries to act something out. Coded by Voluptious

Parameters:

PlayerSpawnNPC(ply, class, weapon)
Called when a player attempts to spawn an NPC.

Parameters:

  • ply Player The player spawning an NPC.
  • class string The NPC class.
  • weapon string The NPCs weapon.
PlayerSpawnProp(ply, model[, state])
Called when a player attempts to spawn a prop.

Parameters:

  • ply Player The player spawning the prop.
  • model string The model path being spawned.
  • state string Optional state data. (optional)
PlayerSpawnEffect(ply, mdl)
Called when a player attempts to spawn an effect.

Parameters:

  • ply Player The player spawning the prop.
  • mdl string The model path being spawned.
PlayerSpawnedProp(ply, mdl, ent)
Called when a player has spawned a prop.

Parameters:

  • ply Player The player spawning the prop.
  • mdl string The model path being spawned.
  • ent Entity The spawned entity.
PlayerSpawnedEffect(ply, mdl, ent)
Called when a player has spawned an effect.

Parameters:

  • ply Player The player spawning the effect.
  • mdl string The model path being spawned.
  • ent Entity The spawned entity.
OnEntityCreated(ent)
Called when an entity is created.

Parameters:

  • ent Entity The created entity.
PlayerSpawnRagdoll(ply, model)
Called when a player attempts to spawn a ragdoll.

Parameters:

  • ply Player Spawning player.
  • model string The model being spawned.
PlayerSpawnedRagdoll(ply, model, ent)
Called when a player has spawned a ragdoll.

Parameters:

  • ply Player The player spawning the ragdoll.
  • model string The model path being spawned.
  • ent Entity The spawned entity.
PlayerSpawnVehicle(ply, model)
Called when a player attempts to spawn a vehicle.

Parameters:

  • ply Player Spawning player.
  • model string The model being spawned.
CanTool(ply, trace, tool)
Called when a player attempts to use their toolgun.

Parameters:

  • ply Player Calling player.
  • trace tab TraceResult structure.
  • tool string The active toolmode.
PlayerNoClip(ply, state)
Called when a player attempts to noclip.

Parameters:

  • ply Player Player changing state.
  • state bool The requested noclip state.
PlayerInitialSpawn(ply)
Called when a player initially spawns.

Parameters:

  • ply
PlayerDeathThink(ply)
Called every frame that a player is dead.

Parameters:

PlayerCanGainFrag(ply, victim)
Hook function called when a player gains a kill.

Parameters:

  • ply Player Player gaining a kill.
  • victim Player Player who was killed.
PlayerSpray(ply)
Called when a player should be allowed to spray.

Parameters:

  • ply Player Player attempting to spray.
PlayerSetModel(ply)
Loadout hook function called when a player's model needs to be set.

Parameters:

  • ply Player Player's whos model is being set.
PlayerSpawn(ply)
Called when a player spawns.

Parameters:

PlayerDeath(ply, inflictor, attacker, ragdoll)
Called when a player dies.

Parameters:

  • ply Player Dying player.
  • inflictor Player Killing player.
  • attacker Entity Entity which inflicted the damage.
  • ragdoll Unknown
ShutDown()
Called when the server shuts down or the map changes.
ShowHelp(player)
Called when a player presses F1.

Parameters:

  • player
ShowSpare2(player)
Called when a player presses F4.

Parameters:

  • player
ShowTeam(ply)
Called when a player presses F2.

Parameters:

  • ply
EntityTakeDamage(ent, damageInfo)
Called when an entity takes damage.

Parameters:

  • ent Entity Entity which took damage.
  • damageInfo DamageInfo Information about the damage.
PlayerDisconnected(player)
Called when a player has disconnected.

Parameters:

  • player Remove the players knockout to give them their weapons back.
CanExitVehicle(veh, ply)
Called to check if a player is able to exit a vehicle.

Parameters:

  • veh
  • ply
PlayerSpawnSWEP(ply, class, wep)
Called when a player attempts to spawn a SWEP.

Parameters:

  • ply Player The spawning player.
  • class string The SWEP class.
  • wep tab The weapon table.
PlayerGiveSWEP(ply, class, wep)
Called when a player attempts to give a SWEP.

Parameters:

  • ply Player The spawning player.
  • class string The SWEP class.
  • wep tab The weapon table.
PlayerSpawnSENT(ply, class)
Called when attempts to spawn a SENT.

Parameters:

  • ply Player The spawning player.
  • class string The SENT class.
KeyPress(ply, key)
Called when a player presses a key.

Parameters:

  • ply Player The player who pressed the key.
  • key number The key enum pressed.
KeyRelease(ply, key)
Called when a player releases a key.

Parameters:

  • ply Player Player who pressed the key.
  • key number KEY_ enum which was pressed.
PlayerDeathSound()
Called to check if the default death sound should be played.
CheckPassword(id64, ipAddr, svPass, clPass, name)
Called when a player joins and attempts to check their password.

Parameters:

  • id64 string 64bit SteamID
  • ipAddr string IP address.
  • svPass string Server's Password
  • clPass string Client's Provided Password.
  • name string Steam Name of the client.

Functions

IsUsingCamera()
Check if the local player is using the camera.

Returns:

    bool
AdjustMaximumWidth(font, text, width, addition, extra)
Adjust WIDTH to be maximum value of (width of text (plus a bit)) or (width)

Parameters:

  • font string Font name.
  • text string Text.
  • width number Maximum width to set to.
  • addition number Post-check text padding size.
  • extra number Pre-check text padding.
GetScreenCenterBounce([How=8])
Get the bouncing position of the screen's center.

Parameters:

  • How number much the screen should bounce by. (default 8)
DrawInformation(text, font, x, y, color, alpha[, left=false[, callback[, shadow=false]]])
Draw Information.

Parameters:

  • text string Information to draw.
  • font string The font to draw.
  • x number X position to draw at.
  • y number Y position to draw at.
  • color Color Colour to draw in.
  • alpha number Alpha to draw at.
  • left bool If the x is the left or center point. (default false)
  • callback function function(x, y, width, height): x, y - Callback function to overwrite the x and y positions. (optional)
  • shadow bool If a shadow should be drawn. (default false)

Returns:

    int New y position.
CalculateTime(seconds)
Convert seconds to a hours, minutes format.

Parameters:

  • seconds number

Returns:

  1. int hours
  2. int minutes
printf(str, ...)
Formatted print to console.

Parameters:

  • str string Formatting string input.
  • ... vararg Formatter arguments.
sprintf(str, ...)
Formatted return.

Parameters:

  • str string Formatting string input.
  • ... vararg Formatter arguments.

Returns:

    string Formatted string.
ConnectToDatabase()
Create DB_MAIN and load our DB instance.
UpdateDatabase()
Update the database and player's data.
PlyCanPickupRegular(ply, ent)
Can a regular player pickup this entity?

Parameters:

  • ply Player Picking up player.
  • ent Entity The entity being picked up.

Returns:

    optional boolean If the pickup was allowed.
PlyCanPickupAdmin(ply, ent)
Can a player with extended access (admin/mod) pickup this entity?

Parameters:

  • ply Player Picking up player.
  • ent Entity The entity being picked up.

Returns:

    optional boolean If the pickup was allowed.
SetupSalary(ply)
Set up a player's salary timer.

Parameters:

Tables

entities
A table that will hold entities that were there when the map started.
cityrp_server_rules
Table for storing the rules.