Skip to content

Commit 3d9fe10

Browse files
committed
> Fixes for null errors
1 parent b49205d commit 3d9fe10

File tree

2 files changed

+35
-21
lines changed

2 files changed

+35
-21
lines changed

Clockwork/garrysmod/gamemodes/clockwork/framework/sh_kernel.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,7 @@ if (SERVER) then
12771277

12781278
if (ragdoll and entity != ragdoll) then
12791279
hook.Call("EntityTakeDamage", Clockwork, ragdoll, damageInfo);
1280+
12801281
damageInfo:SetDamage(0);
12811282

12821283
return true;
@@ -1290,14 +1291,15 @@ if (SERVER) then
12901291
local curTime = CurTime();
12911292

12921293
if (damageInfo:IsDamageType(DMG_CRUSH)) then
1293-
if (entity.cwNextFallDamage
1294-
and curTime < entity.cwNextFallDamage) then
1294+
if (entity.cwNextFallDamage and curTime < entity.cwNextFallDamage) then
12951295
damageInfo:SetDamage(0);
12961296
return true;
12971297
end;
12981298

12991299
amount = hook.Call("GetFallDamage", Clockwork, player, velocity);
1300+
13001301
entity.cwNextFallDamage = curTime + 1;
1302+
13011303
damageInfo:SetDamage(amount)
13021304
end;
13031305
end;

Clockwork/garrysmod/gamemodes/clockwork/framework/sv_kernel.lua

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,21 +3412,23 @@ function Clockwork:PlayerDeath(player, inflictor, attacker, damageInfo)
34123412
end;
34133413
end;
34143414

3415-
if (attacker:IsPlayer()) then
3416-
if (IsValid(attacker:GetActiveWeapon())) then
3417-
local weapon = attacker:GetActiveWeapon();
3418-
local itemTable = cwItem:GetByWeapon(weapon);
3419-
3420-
if (IsValid(weapon) and itemTable) then
3421-
cwKernel:PrintLog(LOGTYPE_CRITICAL, attacker:Name().." has dealt "..tostring(math.ceil(damageInfo:GetDamage())).." damage to "..player:Name().." with "..itemTable("name")..", killing them!");
3415+
if (damageInfo) then
3416+
if (attacker:IsPlayer()) then
3417+
if (IsValid(attacker:GetActiveWeapon())) then
3418+
local weapon = attacker:GetActiveWeapon();
3419+
local itemTable = cwItem:GetByWeapon(weapon);
3420+
3421+
if (IsValid(weapon) and itemTable) then
3422+
cwKernel:PrintLog(LOGTYPE_CRITICAL, attacker:Name().." has dealt "..tostring(math.ceil(damageInfo:GetDamage())).." damage to "..player:Name().." with "..itemTable("name")..", killing them!");
3423+
else
3424+
cwKernel:PrintLog(LOGTYPE_CRITICAL, attacker:Name().." has dealt "..tostring(math.ceil(damageInfo:GetDamage())).." damage to "..player:Name().." with "..cwPly:GetWeaponClass(attacker)..", killing them!");
3425+
end;
34223426
else
3423-
cwKernel:PrintLog(LOGTYPE_CRITICAL, attacker:Name().." has dealt "..tostring(math.ceil(damageInfo:GetDamage())).." damage to "..player:Name().." with "..cwPly:GetWeaponClass(attacker)..", killing them!");
3427+
cwKernel:PrintLog(LOGTYPE_CRITICAL, attacker:Name().." has dealt "..tostring(math.ceil(damageInfo:GetDamage())).." damage to "..player:Name()..", killing them!");
34243428
end;
34253429
else
3426-
cwKernel:PrintLog(LOGTYPE_CRITICAL, attacker:Name().." has dealt "..tostring(math.ceil(damageInfo:GetDamage())).." damage to "..player:Name()..", killing them!");
3430+
cwKernel:PrintLog(LOGTYPE_CRITICAL, attacker:GetClass().." has dealt "..tostring(math.ceil(damageInfo:GetDamage())).." damage to "..player:Name()..", killing them!");
34273431
end;
3428-
else
3429-
cwKernel:PrintLog(LOGTYPE_CRITICAL, attacker:GetClass().." has dealt "..tostring(math.ceil(damageInfo:GetDamage())).." damage to "..player:Name()..", killing them!");
34303432
end;
34313433
end;
34323434

@@ -3619,18 +3621,21 @@ function Clockwork:EntityTakeDamage(entity, damageInfo)
36193621
entity.cwDamageImmunity = curTime + 1;
36203622

36213623
damageInfo:SetDamage(0);
3624+
36223625
return false;
36233626
end;
36243627

36253628
if (IsValid(attacker) and attacker:GetClass() == "worldspawn"
36263629
and entity.cwDamageImmunity and entity.cwDamageImmunity > curTime) then
36273630
damageInfo:SetDamage(0);
3631+
36283632
return false;
36293633
end;
36303634

36313635
if ((IsValid(inflictor) and inflictor:IsBeingHeld())
36323636
or attacker:IsBeingHeld()) then
36333637
damageInfo:SetDamage(0);
3638+
36343639
return false;
36353640
end;
36363641
end;
@@ -3676,13 +3681,17 @@ function Clockwork:EntityTakeDamage(entity, damageInfo)
36763681

36773682
if (damageInfo:GetDamage() > 0) then
36783683
cwKernel:CalculatePlayerDamage(player, lastHitGroup, damageInfo);
3684+
36793685
player:SetVelocity(cwKernel:ConvertForce(damageInfo:GetDamageForce() * 32, 200));
36803686

36813687
if (player:Alive() and player:Health() == 1) then
36823688
player:SetFakingDeath(true);
3683-
hook.Call("DoPlayerDeath", self, player, attacker, damageInfo);
3684-
hook.Call("PlayerDeath", self, player, inflictor, attacker, damageInfo);
3685-
cwKernel:CreateBloodEffects(damageInfo:GetDamagePosition(), 1, player, damageInfo:GetDamageForce());
3689+
3690+
hook.Call("DoPlayerDeath", self, player, attacker, damageInfo);
3691+
hook.Call("PlayerDeath", self, player, inflictor, attacker, damageInfo);
3692+
3693+
cwKernel:CreateBloodEffects(damageInfo:GetDamagePosition(), 1, player, damageInfo:GetDamageForce());
3694+
36863695
player:SetFakingDeath(false, true);
36873696
else
36883697
local bNoMsg = cwPlugin:Call("PlayerTakeDamage", player, inflictor, attacker, lastHitGroup, damageInfo);
@@ -3709,6 +3718,7 @@ function Clockwork:EntityTakeDamage(entity, damageInfo)
37093718
end;
37103719

37113720
damageInfo:SetDamage(0);
3721+
37123722
player.cwLastHitGroup = nil;
37133723
end;
37143724
else
@@ -3735,11 +3745,13 @@ function Clockwork:EntityTakeDamage(entity, damageInfo)
37353745

37363746
if (player:Alive() and player:Health() == 1) then
37373747
player:SetFakingDeath(true);
3738-
player:GetRagdollTable().health = 0;
3739-
player:GetRagdollTable().armor = 0;
3740-
3741-
hook.Call("DoPlayerDeath", self, player, attacker, damageInfo);
3742-
hook.Call("PlayerDeath", self, player, inflictor, attacker, damageInfo);
3748+
3749+
player:GetRagdollTable().health = 0;
3750+
player:GetRagdollTable().armor = 0;
3751+
3752+
hook.Call("DoPlayerDeath", self, player, attacker, damageInfo);
3753+
hook.Call("PlayerDeath", self, player, inflictor, attacker, damageInfo);
3754+
37433755
player:SetFakingDeath(false, true);
37443756
elseif (player:Alive()) then
37453757
local bNoMsg = cwPlugin:Call("PlayerTakeDamage", player, inflictor, attacker, hitGroup, damageInfo);

0 commit comments

Comments
 (0)