@@ -4,20 +4,23 @@ include("vgui/spec_dm_loadout.lua")
4
4
include (" cl_stats.lua" )
5
5
include (" cl_quakesounds.lua" )
6
6
7
+ local ghosttable = {}
8
+ local livingtable = {}
9
+
7
10
local showalive = CreateClientConVar (" ttt_specdm_showaliveplayers" , 1 , FCVAR_ARCHIVE )
8
11
9
12
function SpecDM .UpdatePartDrawing (enabled )
10
13
if pac then
11
- for _ , v in ipairs (player .GetHumans ()) do
12
- if not v :IsGhost () then
13
- if enabled and not showalive :GetBool () then
14
+ for _ , v in ipairs (player .GetHumans ()) do
15
+ if not v :IsGhost () then
16
+ if enabled and not showalive :GetBool () then
14
17
pac .TogglePartDrawing (v , false )
15
- continue
16
- end
17
- end
18
- pac .TogglePartDrawing (v , true )
19
- end
20
- end
18
+ continue
19
+ end
20
+ end
21
+ pac .TogglePartDrawing (v , true )
22
+ end
23
+ end
21
24
end
22
25
23
26
if pac then
@@ -50,8 +53,18 @@ net.Receive("SpecDM_GhostJoin", function()
50
53
local joined = net .ReadUInt (1 ) == 1
51
54
local ply = net .ReadEntity ()
52
55
53
- if not LocalPlayer ():IsSpec () or not IsValid (ply ) then return end
54
- if pac and not joined then
56
+ if not IsValid (ply ) then return end
57
+ if joined then
58
+ print (" inserted ghost" .. ply :Nick ())
59
+ table.insert (ghosttable , ply )
60
+ table .RemoveByValue (livingtable , ply )
61
+ else
62
+ print (" removed ghost" .. ply :Nick ())
63
+ table .RemoveByValue (ghosttable , ply )
64
+ table.insert (livingtable , ply )
65
+ end
66
+ if not LocalPlayer ():IsSpec () then return end
67
+ if pac and not joined then
55
68
pac .TogglePartDrawing (ply , false )
56
69
end
57
70
@@ -442,8 +455,14 @@ hook.Add("Initialize", "Initialize_Ghost", function()
442
455
local filt = tbl .filter
443
456
local ignoretbl = {}
444
457
445
- for _ , v in ipairs (player .GetAll ()) do
446
- if (plyghost and not v :IsGhost ()) or (not plyghost and v :IsGhost ()) then
458
+ if plyghost then
459
+ for k , v in ipairs (livingtable ) do
460
+ if !IsValid (v ) then livingtable [k ] = nil continue end
461
+ table.insert (ignoretbl , v )
462
+ end
463
+ else
464
+ for k , v in ipairs (ghosttable ) do
465
+ if !IsValid (v ) then ghosttable [k ] = nil continue end
447
466
table.insert (ignoretbl , v )
448
467
end
449
468
end
@@ -457,10 +476,10 @@ hook.Add("Initialize", "Initialize_Ghost", function()
457
476
table .Add (tbl .filter , ignoretbl )
458
477
elseif isfunction (filt ) then
459
478
tbl .filter = function (ent )
460
- if ignoretbl [ent ] or filt () then
479
+ if ignoretbl [ent ] then
461
480
return false
462
481
end
463
- return true
482
+ return filt ()
464
483
end
465
484
end
466
485
else
@@ -470,6 +489,14 @@ hook.Add("Initialize", "Initialize_Ghost", function()
470
489
end
471
490
end )
472
491
492
+ hook .Add (" TTTBeginRound" , " TTTBeginRound_TableGhost" , function ()
493
+ table .Empty (ghosttable )
494
+ table .Empty (livingtable )
495
+ for _ , v in ipairs (player .GetAll ()) do
496
+ table.insert (livingtable , v )
497
+ end
498
+ end )
499
+
473
500
hook .Add (" HUDShouldDraw" , " SpecDM_TTTPropSpec" , function (name )
474
501
if name == " TTTPropSpec" and LocalPlayer ():IsGhost () and not showalive :GetBool () then
475
502
return false
0 commit comments