Lua hooks

Rafaël De Jongh edited this page Nov 13, 2016 · 4 revisions

In this section you will find information about internal CAP lua hooks, special functions and variables. This can be useful for server owners and addon developers.

This section is under construction.


Contents


Internal CAP lua hooks

This hooks was created to control the actions of CAP devices. Most hooks should return FALSE for disabled actions, or return NIL. You should never return TRUE in hooks, or this will break all other hooks after it calls your hook. For example this code will prevent you to kill admins with a Naquadah Bomb:

-- this calls before kill player by ply:Kill() function hook.Add("StarGate.GateNuke.KillPlayer","GateNuke.Admins",function(ply) if (IsValid(ply) and ply:IsAdmin()) then return false end end)

-- this one calls before damage player/ent in explosion radius. hook.Add("StarGate.GateNuke.DamageEnt","GateNuke.Admins",function(ent) if (IsValid(ent) and ent:IsPlayer() and ent:IsAdmin()) then return false end end)

Stargate hooks

StarGate.Player.CanDialGate
Arguments: player, entity
This hook called before open dial menu by pressing E on stargate/dhd/mobile dhd etc. Entity is stargate on what player trying to open menu. Return false for disallow.
StarGate.Player.CanModifyGate
Arguments: player, entity
This hook called before open stargate menu for modify gate info. Return false for disallow modifications.
StarGate.Player.CanModifyProtectedGate
Arguments: player, entity
Similar to StarGate.Player.CanModifyGate, except calls when player use gatespawner protected entity. Return false for disallow modifications.
StarGate.Player.CanToolOnProtectedGate
Arguments: player, entity, tool name
This hook called when player trying tool on protected entity. Return true or false for override default stage.
StarGate.Player.DialledGate
Arguments: player, entity, address, fast dial, nox dial
This hook called when player started dial stargate via menu. Return nothing.
StarGate.Player.ClosedGate
Arguments: player, entity
This hook called when player abort dial or close stargate via menu. Return nothing.
StarGate.Dial
Arguments: entity, target, address, dialmode
This hook called when someone start dial from stargate to another one. Return false for disallow dial.
StarGate.SetGateAddress
Arguments: entity, old address, new address
This hook called when someone set new address for stargate. Return "" or another address if you want override it.
StarGate.SetGateGroup
Arguments: entity, old group, new group
This hook called when someone set new group for stargate. Return "" or another group if you want override it.
StarGate.SetGateName
Arguments: entity, old name, new name
This hook called when someone set new name for stargate. Return "" or another name if you want override it.
StarGate.SetPrivate
Arguments: entity, old value, new value
This hook called when someone set private stage for stargate. Return true or false if you want override stage.
StarGate.SetLocal
Arguments: entity, old value, new value
This hook called when someone set local stage for stargate. Return true or false if you want override stage. Note: only works with group system type.
StarGate.SetGalaxy
Arguments: entity, old value, new value
This hook called when someone set galaxy stage for stargate. Return true or false if you want override stage. Note: only works with galaxy system type.
StarGate.SetBlocked
Arguments: entity, old value, new value
This hook called when someone set blocked stage for stargate. Return true or false if you want override stage.

Misc hooks

StarGate.Player.DropWeapon
Arguments: player, weapon
This hook called when player tried to drop his weapon throuch cap drop weapon function (allow drop weapons feature is settings). Return false for disallow drop this weapon. Note: weapon is entity, not class. Use weapon:GetClass() for this.
StarGate.Player.KeyEvent
Arguments: player, name, key, is pressed
This hook called when player press some special key what registered by cap (ships, malp etc). Return false for disallow pressing or releasing this key.
StarGate.Player.KeyPressed
Arguments: player, name, key
This hook called when player pressed some special key what registered by cap. Return false for disallow pressing this key.
StarGate.Player.KeyReleased
Arguments: player, name, key
This hook called when player released some special key what registered by cap. Return false for disallow releasing this key.
StarGate.HandDevice.Push
Arguments: entity, attacker
This hook called before hand device doing push. Attacked - is owner of weapon, entity - entity what should be pushed. Return false for disallow push this ent.
StarGate.GateNuke.KillPlayer
Arguments: entity
This hook called before kill player by naquadah explosion (used in device like naquadah bomb, tampered zmp etc). Return false for disallow kill player. Please note - player still will die if you didn't return false in StarGate.GateNuke.DamageEnt hook.
StarGate.GateNuke.DamageEnt
Arguments: entity
This hook called before damage entity by naquadah explosion. Return false for disallow damage this ent.
StarGate.SatBlast.DamageEnt
Arguments: entity
This hook called before damage entity or player by ag3 blast wave. Return false for disallow damage this ent.
StarGate.BlackHole.RemoveEnt
Arguments: entity, black hole
This hook called before remove entity or kill player/npc by black hole. Return false for disallow remove this ent.
StarGate.BlackHole.PushEnt
Arguments: entity, black hole
This hook called before push entity by black hole. Return false for disallow push this ent.
StarGate.Transporter.TeleportEnt
Arguments: entity, transporter
This hook called before teleport entity/player by asgard transporter. Return false for disallow teleport this ent.
StarGate.Rings.TeleportEnt
Arguments: entity, rings
This hook called before teleport entity/player by rings. Return false for disallow teleport this ent.
StarGate.AtlantisTransporter.TeleportEnt
Arguments: entity, transporter
This hook called before teleport entity/player by atlantis transporter. Return false for disallow teleport this ent.
StarGate.WraithBomb.Stun
Arguments: player, bomb
This hook called before stun player by wraith bomb. Return false for disallow stun this player.
StarGate.Player.Stun
Arguments: player, attacker
This hook called before stun player by wraith blaster or ronon gun. Return false for disallow stun this player.
StarGate.DarakaWave.Disintegrate
Arguments: entity, darakawave
This hook called before disintegrate entity/player by dakara wave. Return false for disallow disintegration.
StarGate.AntiPrior.Noclip
Arguments: player, anti prior
This hook called before disable noclip by anti prior device. Return false for prevent disabling noclip for this player.
StarGate.Bullet
Arguments: entity, bullet, trace
This hook called when some ent fire bullets (for example after teleportation through event horizon). Return any value for override it. Note: not really sure for what this hook needed.
StarGate.Harvester.Ent
Arguments: entity, harvester
This hook called before get player/entity into harvester. Return false for prevent this.
StarGate.Jumper.KillPlayer
Arguments: player, jumper
This hook called before kill player near jumper by explosion. Return false for prevent kill player.
StarGate.Player.CanModify.Ring
Arguments: player, ring
This hook called before open edit menu or modify ring. Return false for prevent modify ring.
StarGate.Player.CanModify.AtlantisTransporter
Arguments: player, transporter
This hook called before open edit menu or modify atlantis transporter. Return false for prevent modify atlantis transporter.

Internal CAP special functions

entity:CAPOnShieldTouch
Arguments: shield
This function will be called when CAP shield (from stools) touch your SENT if this functions exists on your SENT. For example this functions used for energy_pulse in cap for prevent going shoots through shield.

Internal CAP special variables

entity.CAP_EH_NoTouchTeleport
If your SENT has this variable, and it is true, then your SENT will teleport through event horizon on touch without model clipping.
entity.CAP_EH_NoTouch
If your SENT has this variable, and it is true, then your SENT will never touch event horizon.
entity.NoAutoClose
If your SENT has this variable, and it is true, then your SENT will not auto close stargate after teleportation through event horizon.
entity.CAP_NotSave
If your SENT has this variable, and it is true, then your SENT will not be saved with gmod saving system.
entity.Untouchable
If your SENT has this variable, and it is true, then players can't touch your SENT by physgun/gravgun, can't tool etc.
entity.GateSpawnerSpawned
Returns true if this entity spawner by gatespawner.
entity.GateSpawnerProtected
Returns true if this entity protected by gatespawner.
entity.NoDissolve
If your SENT has this variable, and it is true, then kawoosh will not destroy this entity.