@@ -18,8 +18,8 @@ public void PlayerReset(CCSPlayerController? player, CommandInfo command)
1818
1919 // To-do: players[userid].Timer.Reset() -> teleport player
2020 playerList [ player . UserId ?? 0 ] . Timer . Reset ( ) ;
21- if ( CurrentMap . StartZone != new Vector ( 0 , 0 , 0 ) )
22- Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StartZone , new QAngle ( 0 , 0 , 0 ) , new Vector ( 0 , 0 , 0 ) ) ) ;
21+ if ( CurrentMap . StartZone != new Vector ( 0 , 0 , 0 ) )
22+ Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StartZone , new QAngle ( 0 , 0 , 0 ) , new Vector ( 0 , 0 , 0 ) ) ) ;
2323 return ;
2424 }
2525
@@ -32,10 +32,10 @@ public void PlayerResetStage(CCSPlayerController? player, CommandInfo command)
3232
3333 // To-do: players[userid].Timer.Reset() -> teleport player
3434 Player SurfPlayer = playerList [ player . UserId ?? 0 ] ;
35- if ( SurfPlayer . Timer . Stage != 0 && CurrentMap . StageStartZone [ SurfPlayer . Timer . Stage ] != new Vector ( 0 , 0 , 0 ) )
36- Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StageStartZone [ SurfPlayer . Timer . Stage ] , CurrentMap . StageStartZoneAngles [ SurfPlayer . Timer . Stage ] , new Vector ( 0 , 0 , 0 ) ) ) ;
35+ if ( SurfPlayer . Timer . Stage != 0 && CurrentMap . StageStartZone [ SurfPlayer . Timer . Stage ] != new Vector ( 0 , 0 , 0 ) )
36+ Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StageStartZone [ SurfPlayer . Timer . Stage ] , CurrentMap . StageStartZoneAngles [ SurfPlayer . Timer . Stage ] , new Vector ( 0 , 0 , 0 ) ) ) ;
3737 else // Reset back to map start
38- Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StartZone , new QAngle ( 0 , 0 , 0 ) , new Vector ( 0 , 0 , 0 ) ) ) ;
38+ Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StartZone , new QAngle ( 0 , 0 , 0 ) , new Vector ( 0 , 0 , 0 ) ) ) ;
3939 return ;
4040 }
4141
@@ -47,7 +47,7 @@ public void PlayerGoToStage(CCSPlayerController? player, CommandInfo command)
4747 return ;
4848
4949 int stage = Int32 . Parse ( command . ArgByIndex ( 1 ) ) - 1 ;
50- if ( stage > CurrentMap . Stages - 1 )
50+ if ( stage > CurrentMap . Stages - 1 && CurrentMap . Stages > 0 )
5151 stage = CurrentMap . Stages - 1 ;
5252
5353 // Must be 1 argument
@@ -60,28 +60,243 @@ public void PlayerGoToStage(CCSPlayerController? player, CommandInfo command)
6060 player . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } Invalid arguments. Usage: { ChatColors . Green } !s <stage>") ;
6161 return ;
6262 }
63-
6463 else if ( CurrentMap . Stages <= 0 )
6564 {
6665 player . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } This map has no stages.") ;
6766 return ;
6867 }
6968
70- if ( CurrentMap . StageStartZone [ stage ] != new Vector ( 0 , 0 , 0 ) )
69+ if ( CurrentMap . StageStartZone [ stage ] != new Vector ( 0 , 0 , 0 ) )
7170 {
7271 if ( stage == 0 )
73- Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StartZone , CurrentMap . StartZoneAngles , new Vector ( 0 , 0 , 0 ) ) ) ;
72+ Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StartZone , CurrentMap . StartZoneAngles , new Vector ( 0 , 0 , 0 ) ) ) ;
7473 else
75- Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StageStartZone [ stage ] , CurrentMap . StageStartZoneAngles [ stage ] , new Vector ( 0 , 0 , 0 ) ) ) ;
76-
74+ Server . NextFrame ( ( ) => player . PlayerPawn . Value ! . Teleport ( CurrentMap . StageStartZone [ stage ] , CurrentMap . StageStartZoneAngles [ stage ] , new Vector ( 0 , 0 , 0 ) ) ) ;
75+
7776 playerList [ player . UserId ?? 0 ] . Timer . Reset ( ) ;
78- playerList [ player . UserId ?? 0 ] . Timer . StageMode = true ;
77+ playerList [ player . UserId ?? 0 ] . Timer . IsStageMode = true ;
7978
8079 // To-do: If you run this while you're in the start zone, endtouch for the start zone runs after you've teleported
8180 // causing the timer to start. This needs to be fixed.
8281 }
8382
84- else
83+ else
8584 player . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } Invalid stage provided. Usage: { ChatColors . Green } !s <stage>") ;
8685 }
86+
87+ [ ConsoleCommand ( "css_spec" , "Moves a player automaticlly into spectator mode" ) ]
88+ public void MovePlayerToSpectator ( CCSPlayerController ? player , CommandInfo command )
89+ {
90+ if ( player == null || player . Team == CsTeam . Spectator )
91+ return ;
92+
93+ player . ChangeTeam ( CsTeam . Spectator ) ;
94+ }
95+
96+ /*
97+ #########################
98+ Reaplay Commands
99+ #########################
100+ */
101+ [ ConsoleCommand ( "css_replaybotpause" , "Pause the replay bot playback" ) ]
102+ [ ConsoleCommand ( "css_rbpause" , "Pause the replay bot playback" ) ]
103+ public void PauseReplay ( CCSPlayerController ? player , CommandInfo command )
104+ {
105+ if ( player == null || player . Team != CsTeam . Spectator )
106+ return ;
107+
108+ foreach ( ReplayPlayer rb in CurrentMap . ReplayBots )
109+ {
110+ if ( ! rb . IsPlayable || ! rb . IsPlaying || ! playerList [ player . UserId ?? 0 ] . IsSpectating ( rb . Controller ! ) )
111+ continue ;
112+
113+ rb . Pause ( ) ;
114+ }
115+ }
116+
117+ [ ConsoleCommand ( "css_replaybotflip" , "Flips the replay bot between Forward/Backward playback" ) ]
118+ [ ConsoleCommand ( "css_rbflip" , "Flips the replay bot between Forward/Backward playback" ) ]
119+ public void ReverseReplay ( CCSPlayerController ? player , CommandInfo command )
120+ {
121+ if ( player == null || player . Team != CsTeam . Spectator )
122+ return ;
123+
124+ foreach ( ReplayPlayer rb in CurrentMap . ReplayBots )
125+ {
126+ if ( ! rb . IsPlayable || ! rb . IsPlaying || ! playerList [ player . UserId ?? 0 ] . IsSpectating ( rb . Controller ! ) )
127+ continue ;
128+
129+ rb . FrameTickIncrement *= - 1 ;
130+ }
131+ }
132+
133+ [ ConsoleCommand ( "css_pbreplay" , "Allows for replay of player's PB" ) ]
134+ public void PbReplay ( CCSPlayerController ? player , CommandInfo command )
135+ {
136+ if ( player == null )
137+ return ;
138+
139+ int maptime_id = playerList [ player ! . UserId ?? 0 ] . Stats . PB [ playerList [ player . UserId ?? 0 ] . Timer . Style ] . ID ;
140+ if ( command . ArgCount > 1 )
141+ {
142+ try
143+ {
144+ maptime_id = int . Parse ( command . ArgByIndex ( 1 ) ) ;
145+ }
146+ catch { }
147+ }
148+
149+ if ( maptime_id == - 1 || ! CurrentMap . ConnectedMapTimes . Contains ( maptime_id ) )
150+ {
151+ player . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } No time was found") ;
152+ return ;
153+ }
154+
155+ for ( int i = 0 ; i < CurrentMap . ReplayBots . Count ; i ++ )
156+ {
157+ if ( CurrentMap . ReplayBots [ i ] . Stat_MapTimeID == maptime_id )
158+ {
159+ player . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } A bot of this run already playing") ;
160+ return ;
161+ }
162+ }
163+
164+ CurrentMap . ReplayBots = CurrentMap . ReplayBots . Prepend ( new ReplayPlayer ( ) {
165+ Stat_MapTimeID = maptime_id ,
166+ Stat_Prefix = "PB"
167+ } ) . ToList ( ) ;
168+
169+ Server . NextFrame ( ( ) => {
170+ Server . ExecuteCommand ( $ "bot_quota { CurrentMap . ReplayBots . Count } ") ;
171+ } ) ;
172+ }
173+
174+ /*
175+ ########################
176+ Saveloc Commands
177+ ########################
178+ */
179+ [ ConsoleCommand ( "css_saveloc" , "Save current player location to be practiced" ) ]
180+ public void SavePlayerLocation ( CCSPlayerController ? player , CommandInfo command )
181+ {
182+ if ( player == null || ! player . PawnIsAlive || ! playerList . ContainsKey ( player . UserId ?? 0 ) )
183+ return ;
184+
185+ Player p = playerList [ player . UserId ?? 0 ] ;
186+ if ( ! p . Timer . IsRunning )
187+ {
188+ p . Controller . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } Cannot save location while not in run") ;
189+ return ;
190+ }
191+
192+ var player_pos = p . Controller . Pawn . Value ! . AbsOrigin ! ;
193+ var player_angle = p . Controller . PlayerPawn . Value ! . EyeAngles ;
194+ var player_velocity = p . Controller . PlayerPawn . Value ! . AbsVelocity ;
195+
196+ p . SavedLocations . Add ( new SavelocFrame {
197+ Pos = new Vector ( player_pos . X , player_pos . Y , player_pos . Z ) ,
198+ Ang = new QAngle ( player_angle . X , player_angle . Y , player_angle . Z ) ,
199+ Vel = new Vector ( player_velocity . X , player_velocity . Y , player_velocity . Z ) ,
200+ Tick = p . Timer . Ticks
201+ } ) ;
202+ p . CurrentSavedLocation = p . SavedLocations . Count - 1 ;
203+
204+ p . Controller . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Green } Saved location! { ChatColors . Default } use !tele { p . SavedLocations . Count - 1 } to teleport to this location") ;
205+ }
206+
207+ [ ConsoleCommand ( "css_tele" , "Teleport player to current saved location" ) ]
208+ public void TeleportPlayerLocation ( CCSPlayerController ? player , CommandInfo command )
209+ {
210+ if ( player == null || ! player . PawnIsAlive || ! playerList . ContainsKey ( player . UserId ?? 0 ) )
211+ return ;
212+
213+ Player p = playerList [ player . UserId ?? 0 ] ;
214+
215+ if ( p . SavedLocations . Count == 0 )
216+ {
217+ p . Controller . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } No saved locations") ;
218+ return ;
219+ }
220+
221+ if ( ! p . Timer . IsRunning )
222+ p . Timer . Start ( ) ;
223+
224+ if ( ! p . Timer . IsPracticeMode )
225+ {
226+ p . Controller . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } Timer now on practice") ;
227+ p . Timer . IsPracticeMode = true ;
228+ }
229+
230+ if ( command . ArgCount > 1 )
231+ try
232+ {
233+ int tele_n = int . Parse ( command . ArgByIndex ( 1 ) ) ;
234+ if ( tele_n < p . SavedLocations . Count )
235+ p . CurrentSavedLocation = tele_n ;
236+ }
237+ catch { }
238+ SavelocFrame location = p . SavedLocations [ p . CurrentSavedLocation ] ;
239+ Server . NextFrame ( ( ) => {
240+ p . Controller . PlayerPawn . Value ! . Teleport ( location . Pos , location . Ang , location . Vel ) ;
241+ p . Timer . Ticks = location . Tick ;
242+ } ) ;
243+
244+ p . Controller . PrintToChat ( $ "{ PluginPrefix } Teleported #{ p . CurrentSavedLocation } ") ;
245+ }
246+
247+ [ ConsoleCommand ( "css_teleprev" , "Teleport player to previous saved location" ) ]
248+ public void TeleportPlayerLocationPrev ( CCSPlayerController ? player , CommandInfo command )
249+ {
250+ if ( player == null || ! player . PawnIsAlive || ! playerList . ContainsKey ( player . UserId ?? 0 ) )
251+ return ;
252+
253+ Player p = playerList [ player . UserId ?? 0 ] ;
254+
255+ if ( p . SavedLocations . Count == 0 )
256+ {
257+ p . Controller . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } No saved locations") ;
258+ return ;
259+ }
260+
261+ if ( p . CurrentSavedLocation == 0 )
262+ {
263+ p . Controller . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } Already at first location") ;
264+ }
265+ else
266+ {
267+ p . CurrentSavedLocation -- ;
268+ }
269+
270+ TeleportPlayerLocation ( player , command ) ;
271+
272+ p . Controller . PrintToChat ( $ "{ PluginPrefix } Teleported #{ p . CurrentSavedLocation } ") ;
273+ }
274+
275+ [ ConsoleCommand ( "css_telenext" , "Teleport player to next saved location" ) ]
276+ public void TeleportPlayerLocationNext ( CCSPlayerController ? player , CommandInfo command )
277+ {
278+ if ( player == null || ! player . PawnIsAlive || ! playerList . ContainsKey ( player . UserId ?? 0 ) )
279+ return ;
280+
281+ Player p = playerList [ player . UserId ?? 0 ] ;
282+
283+ if ( p . SavedLocations . Count == 0 )
284+ {
285+ p . Controller . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } No saved locations") ;
286+ return ;
287+ }
288+
289+ if ( p . CurrentSavedLocation == p . SavedLocations . Count - 1 )
290+ {
291+ p . Controller . PrintToChat ( $ "{ PluginPrefix } { ChatColors . Red } Already at last location") ;
292+ }
293+ else
294+ {
295+ p . CurrentSavedLocation ++ ;
296+ }
297+
298+ TeleportPlayerLocation ( player , command ) ;
299+
300+ p . Controller . PrintToChat ( $ "{ PluginPrefix } Teleported #{ p . CurrentSavedLocation } ") ;
301+ }
87302}
0 commit comments