Skip to content

Commit cc7ac94

Browse files
authored
Merge pull request #102 from LiliaFramework/codex/add-should-instakill-hook
Add ShouldInstantKill hook
2 parents e19781f + 97839fc commit cc7ac94

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

instakill/docs/hooks.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
### `ShouldInstantKill`
2+
3+
**Purpose**
4+
`Called before processing a headshot to determine if instant kill should occur.`
5+
6+
**Parameters**
7+
8+
* `player` (`Player`): `Victim receiving the hit.`
9+
* `damageInfo` (`CTakeDamageInfo`): `Damage information object.`
10+
11+
**Realm**
12+
`Server`
13+
14+
**Returns**
15+
`boolean``return false to ignore the instant kill.`
16+
17+
**Example**
18+
19+
```lua
20+
hook.Add("ShouldInstantKill", "ProtectNPCs", function(ply, dmginfo)
21+
if ply:IsNPC() then return false end
22+
end)
23+
```
24+
25+
---
26+
127
### `PlayerPreInstantKill`
228

329
**Purpose**

instakill/libraries/server.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
function MODULE:ScalePlayerDamage(client, hitgroup, dmgInfo)
1+
function MODULE:ScalePlayerDamage(client, hitgroup, dmgInfo)
22
if lia.config.get("instakilling") and hitgroup == HITGROUP_HEAD then
3+
if hook.Run("ShouldInstantKill", client, dmgInfo) == false then return end
4+
35
hook.Run("PlayerPreInstantKill", client, dmgInfo)
46
dmgInfo:SetDamage(client:GetMaxHealth() * 5)
57
hook.Run("PlayerInstantKilled", client, dmgInfo)

0 commit comments

Comments
 (0)