1+ if (! (" Entities" in this )) return
2+
3+ IncludeScript (" paintgun/helper.nut" )
4+
5+ function PG_scriptInit () {
6+ if (GetPlayer () != null ) {
7+ // check if the script has already been initialised
8+ if (Entities. FindByName (null , " paintgun_setupdone" ) != null ) {
9+ PG_Dev. msgDeveloper (" Setup has already been completed, skipping..." )
10+ return
11+ } else {
12+ // check if paint is enabled, if not, enable it and restart the map
13+ if (! IsPaintEnabled ()) {
14+ PG_Dev. msgError (" Paint is not enabled! Enabling paint and restarting map..." )
15+
16+ local serverCommand = CreateEntityByName (" point_servercommand" , {})
17+ PG_Dev. EntFireByHandleCompressed (serverCommand, " Command" , " sv_cheats 1; sv_force_enable_paint_in_map 1; restart" , FrameTime ())
18+
19+ return
20+ }
21+
22+ PG_GivePaintgun ()
23+
24+ // spawn initialisation marker entity
25+ local hasBeenSetupEntity = CreateEntityByName (" info_target" , {
26+ targetname = " paintgun_setupdone"
27+ })
28+
29+ PG_Dev. msgDeveloper (" Script initialised." )
30+ }
31+ } else {
32+ PG_Dev. msgError (" Player entity not found!" )
33+ }
34+ }
35+
36+ function PG_GivePaintgun () {
37+ PG_Dev. msg (" Giving player the paintgun..." )
38+
39+ // give paintgun with all paints
40+ UpgradePlayerPaintgun ()
41+
42+ // allow cubes to become visibly painted
43+ SendToConsole (" sv_force_upgrade_weighted_cube 1" )
44+
45+ // kill any weapon_portalgun entities in the map
46+ for (local pgun = null ; pgun = Entities. FindByClassname (pgun, " weapon_portalgun" );) {
47+ PG_Dev. EntFireByHandleCompressed (pgun, " Kill" )
48+ }
49+ }
50+
51+ // override these functions to not do anything to prevent the player being given a portal gun too soon (and prevent console errors!)
52+ function GivePlayerPortalgun () {
53+ PG_Dev. msg (" Preventing player from receiving a portal gun..." )
54+ }
55+ function UpgradePlayerPortalgun () {
56+ PG_Dev. msg (" Preventing player from receiving a portal gun upgrade..." )
57+ }
58+
59+ PG_auto <- CreateEntityByName(" logic_auto" , {spawnflags = 1 })
60+ PG_auto. ConnectOutput (" OnMapSpawn" , " PG_scriptInit" )
0 commit comments