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. |
- 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:
- 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:
- PlayerPromoteLeader(ply, tgt, from)
-
Called when a player is promoting another player.
Parameters:
- PlayerKnockOut(ply, tgt)
-
Called when a player is knocking out another player.
Parameters:
- PlayerWakeUp(ply, tgt)
-
Called when a player is waking up another player.
Parameters:
- PlayerArrest(ply, tgt)
-
Called when a player is arresting another player.
Parameters:
- PlayerHostage(ply, tgt)
-
Called when a player hostages player.
Parameters:
- PlayerUnarrest(ply, tgt)
-
Called when a player unarrests player.
Parameters:
- PlayerWarrant(ply, tgt, class)
-
Called when a player warrants a player.
Parameters:
- PlayerUnwarrant(ply, tgt)
-
Called when a player unwarrants player.
Parameters:
- 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:
- PlayerCanUseItem(ply, item, silent)
-
Called when a player attempts to use an item.
Parameters:
- PlayerCanDropItem(ply, item, amt, pos)
-
Called when a player attempts to drop an item on the ground.
Parameters:
- PlayerCanGiveItem(ply, item, amt, to)
-
Called when a player attempts to give an item to another player.
Parameters:
- PlayerCanRemoveItem(ply, item)
-
Called when a player attempts to remove an item.
Parameters:
- PlayerCanKnockOut(ply, tgt)
-
Called when a player attempts to knock out another player.
Parameters:
- PlayerCanWarrant(ply, tgt)
-
Called when a player attempts to warrant another player.
Parameters:
- PlayerCanWakeUp(ply, tgt)
-
Called when a player attempts to wake up another player.
Parameters:
- 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:
- PlayerCanPromote(ply, tgt)
-
Called when a player attempts to promote another player.
Parameters:
- 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:
- PlayerCanSayIC(ply, text)
-
Check if a player can say IC text.
Parameters:
- PlayerCanSayOOC(ply, text)
-
Check if a player can say OOC text.
Parameters:
- PlayerCanSayLOOC(ply, text)
-
Check if a player can say Local OOC text.
Parameters:
- PlayerCanUseCommand(ply, command, arguments)
-
Check if a player can run a command.
Parameters:
- 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:
- 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:
- 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:
- PlayerSpawnProp(ply, model[, state])
-
Called when a player attempts to spawn a prop.
Parameters:
- PlayerSpawnEffect(ply, mdl)
-
Called when a player attempts to spawn an effect.
Parameters:
- PlayerSpawnedProp(ply, mdl, ent)
-
Called when a player has spawned a prop.
Parameters:
- PlayerSpawnedEffect(ply, mdl, ent)
-
Called when a player has spawned an effect.
Parameters:
- 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:
- PlayerSpawnedRagdoll(ply, model, ent)
-
Called when a player has spawned a ragdoll.
Parameters:
- PlayerSpawnVehicle(ply, model)
-
Called when a player attempts to spawn a vehicle.
Parameters:
- CanTool(ply, trace, tool)
-
Called when a player attempts to use their toolgun.
Parameters:
- 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:
- ply Player Dead player.
- PlayerCanGainFrag(ply, victim)
-
Hook function called when a player gains a kill.
Parameters:
- 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:
- ply Player Spawning Player.
- PlayerDeath(ply, inflictor, attacker, ragdoll)
-
Called when a player dies.
Parameters:
- 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:
- PlayerGiveSWEP(ply, class, wep)
-
Called when a player attempts to give a SWEP.
Parameters:
- PlayerSpawnSENT(ply, class)
-
Called when attempts to spawn a SENT.
Parameters:
- 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:
- 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:
- 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:
- int hours
- 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:
- ply Player Player to setup.