@@ -122,6 +122,7 @@ public partial class MatchZy
122122 Dictionary < int , Dictionary < string , GrenadeThrownData > > nadeSpecificLastGrenadeData = new ( ) ;
123123 Dictionary < int , DateTime > lastGrenadeThrownTime = new ( ) ;
124124 Dictionary < int , PlayerPracticeTimer > playerTimers = new ( ) ;
125+ Dictionary < int , PlayerLocationData > savedPlayerLocationData = new ( ) ;
125126
126127 public Dictionary < byte , List < Position > > spawnsData = GetEmptySpawnsData ( ) ;
127128
@@ -179,6 +180,8 @@ public void StartPracticeMode()
179180 Server . PrintToChatAll ( $ " { ChatColors . Green } Nades: { ChatColors . Default } .loadnade, .savenade, .importnade, .listnades") ;
180181 Server . PrintToChatAll ( $ " { ChatColors . Green } Nade Throw: { ChatColors . Default } .rethrow, .throwindex <index>, .lastindex, .delay <number>") ;
181182 Server . PrintToChatAll ( $ " { ChatColors . Green } Utility & Toggles: { ChatColors . Default } .clear, .fastforward, .last, .back, .solid, .impacts, .traj") ;
183+ // On new line to prevent text cutting off
184+ Server . PrintToChatAll ( $ " { ChatColors . Green } Utility & Toggles: { ChatColors . Default } .savepos, .loadpos") ;
182185 Server . PrintToChatAll ( $ " { ChatColors . Green } Sides & Others: { ChatColors . Default } .ct, .t, .spec, .fas, .god, .dryrun, .break, .exitprac") ;
183186 }
184187
@@ -1438,6 +1441,38 @@ public void OnRethrowCommand(CCSPlayerController? player, CommandInfo? command)
14381441 AddTimer ( lastGrenade . Delay , ( ) => lastGrenade . Throw ( player ) ) ;
14391442 }
14401443
1444+ [ ConsoleCommand ( "css_savepos" , "Saves the player location" ) ]
1445+ public void OnSavePosCommand ( CCSPlayerController ? player , CommandInfo ? command )
1446+ {
1447+ if ( ! isPractice || player == null || ! player . UserId . HasValue || player . PlayerPawn . Value == null ) return ;
1448+
1449+ int userId = player . UserId . Value ;
1450+ var pawn = player . PlayerPawn . Value ;
1451+ Vector position = new ( pawn . AbsOrigin ? . X , pawn . AbsOrigin ? . Y , pawn . AbsOrigin ? . Z ) ;
1452+ QAngle angle = new ( pawn . EyeAngles ? . X , pawn . EyeAngles ? . Y , pawn . EyeAngles ? . Z ) ;
1453+
1454+ savedPlayerLocationData [ userId ] = new PlayerLocationData ( position , angle ) ;
1455+ Log ( $ "[SavePos] Saved position for UserID { userId } , Position: { position } , Angle: { angle } !") ;
1456+ PrintToPlayerChat ( player , Localizer [ "matchzy.pm.savepos" ] ) ;
1457+ }
1458+
1459+ [ ConsoleCommand ( "css_loadpos" , "Loads the last saved player location" ) ]
1460+ public void OnLoadPosCommand ( CCSPlayerController ? player , CommandInfo ? command )
1461+ {
1462+ if ( ! isPractice || player == null || ! player . UserId . HasValue ) return ;
1463+
1464+ int userId = player . UserId . Value ;
1465+ if ( ! savedPlayerLocationData . TryGetValue ( userId , out var playerLocationData ) )
1466+ {
1467+ PrintToPlayerChat ( player , Localizer [ "matchzy.pm.notsavedpos" ] ) ;
1468+ return ;
1469+ }
1470+
1471+ Log ( $ "[LoadPos] LoadPos position for UserID { userId } , Position: { playerLocationData . Position } , Angles: { playerLocationData . Angle } !") ;
1472+ playerLocationData . LoadPosition ( player ) ;
1473+ PrintToPlayerChat ( player , Localizer [ "matchzy.pm.loadpos" ] ) ;
1474+ }
1475+
14411476 [ ConsoleCommand ( "css_throwsmoke" , "Throws the last thrown smoke" ) ]
14421477 [ ConsoleCommand ( "css_rethrowsmoke" , "Throws the last thrown smoke" ) ]
14431478 public void OnRethrowSmokeCommand ( CCSPlayerController ? player , CommandInfo ? command )
0 commit comments