11IncludeScript (" worldtext_center" )
22
33const TFCO_DONATION_TEXT_NAME = " tfco_donation_text"
4+ const TFCO_DONATION_TEXT_SIZE = 20
45
5- ClearGameEventCallbacks ()
6-
7- function OnGameEvent_teamplay_round_start (params)
6+ local EventsID = UniqueString ()
7+ getroottable ()[EventsID] <-
88{
9- if (! Convars. GetBool (" sm_tfco_donation_enabled" ))
10- return
11-
12- // Resupply Locker
13- local regenerate
14- while (regenerate = Entities. FindByClassname (regenerate, " func_regenerate" ))
9+ OnGameEvent_scorestats_accumulated_update = function (params)
1510 {
16- local prop = NetProps. GetPropEntity (regenerate, " m_hAssociatedModel" )
17- if (prop == null )
18- continue
19-
20- local worldtext = SpawnEntityFromTable (" point_worldtext" ,
21- {
22- targetname = TFCO_DONATION_TEXT_NAME,
23- textsize = " 20" ,
24- origin = prop. GetOrigin (),
25- angles = prop. GetAbsAngles () + QAngle (0 , 180 , 0 ),
26- })
27-
28- EntFireByHandle (worldtext, " SetParent" , " !activator" , - 1 , prop, null )
29- AddThinkToEnt (worldtext, " ResupplyTextThink" )
11+ delete getroottable ()[EventsID]
3012 }
3113
32- // Control Point
33- local point
34- while (point = Entities. FindByClassname (point, " team_control_point" ))
14+ OnGameEvent_teamplay_round_start = function (params)
3515 {
36- local bone = point. LookupBone (" spinner" )
37- if (bone == - 1 )
38- continue
16+ if (! Convars. GetBool (" sm_tfco_donation_enabled" ))
17+ return
3918
40- local worldtext = SpawnEntityFromTable (" point_worldtext" ,
19+ // Resupply Locker
20+ local regenerate
21+ while (regenerate = Entities. FindByClassname (regenerate, " func_regenerate" ))
4122 {
42- targetname = TFCO_DONATION_TEXT_NAME,
43- textsize = " 20" ,
44- origin = point. GetBoneOrigin (bone)
45- })
23+ local prop = NetProps. GetPropEntity (regenerate, " m_hAssociatedModel" )
24+ if (prop == null )
25+ continue
26+
27+ local worldtext = SpawnEntityFromTable (" point_worldtext" ,
28+ {
29+ targetname = TFCO_DONATION_TEXT_NAME,
30+ textsize = TFCO_DONATION_TEXT_SIZE,
31+ origin = prop. GetOrigin (),
32+ angles = prop. GetAbsAngles () + QAngle (0 , 180 , 0 ),
33+ })
34+
35+ EntFireByHandle (worldtext, " SetParent" , " !activator" , - 1 , prop, null )
36+ AddThinkToEnt (worldtext, " ResupplyTextThink" )
37+ }
4638
47- EntFireByHandle (worldtext, " SetParent" , " !activator" , - 1 , point, null )
48- AddThinkToEnt (worldtext, " ControlPointTextThink" )
39+ // Control Point
40+ local point
41+ while (point = Entities. FindByClassname (point, " team_control_point" ))
42+ {
43+ local bone = point. LookupBone (" spinner" )
44+ if (bone == - 1 )
45+ continue
46+
47+ local worldtext = SpawnEntityFromTable (" point_worldtext" ,
48+ {
49+ targetname = TFCO_DONATION_TEXT_NAME,
50+ textsize = TFCO_DONATION_TEXT_SIZE,
51+ origin = point. GetBoneOrigin (bone)
52+ })
53+
54+ EntFireByHandle (worldtext, " SetParent" , " !activator" , - 1 , point, null )
55+ AddThinkToEnt (worldtext, " ControlPointTextThink" )
56+ }
4957 }
5058}
51-
52- __CollectGameEventCallbacks (this )
59+ local EventsTable = getroottable ()[EventsID]
60+ foreach (name, callback in EventsTable) EventsTable[name] = callback. bindenv (this )
61+ __CollectGameEventCallbacks (EventsTable)
5362
5463::ResupplyTextThink <- function()
5564{
@@ -99,4 +108,4 @@ __CollectGameEventCallbacks(this)
99108 worldtext. EmitSound (" Game.HappyBirthdayNoiseMaker" )
100109 }
101110 }
102- }
111+ }
0 commit comments