Skip to content

Commit

Permalink
Merge pull request #15 from CHR15cs/Restore-Projectile-by-id
Browse files Browse the repository at this point in the history
Added parsing for id and restoring in .nades command
  • Loading branch information
CHR15cs authored Nov 17, 2023
2 parents ecab63e + d05e653 commit 5906e9a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CSPracc/CommandHandler/PracticeCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ public override bool PlayerChat(EventPlayerChat @event, GameEventInfo info)
}
case PRACC_COMMAND.NADES:
{
if (args.Length > 0)
{
if (int.TryParse(args, out int id))
{
ProjectileManager.Instance.RestoreSnapshot(player, id);
}
}
ChatMenus.OpenMenu(player, ProjectileManager.Instance.GetNadeMenu(player));
break;
}
Expand Down Expand Up @@ -83,6 +90,7 @@ public override bool PlayerChat(EventPlayerChat @event, GameEventInfo info)
}
case PRACC_COMMAND.WATCHME:
{
//TODO: Utilities.GetPlayers?
var playerEntities = Utilities.FindAllEntitiesByDesignerName<CCSPlayerController>("cs_player_controller");
foreach (var playerEnt in playerEntities)
{
Expand Down
5 changes: 3 additions & 2 deletions CSPracc/DataModules/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public class COMMANDS

public class PRACC_COMMAND
{
public const string MODE = ".menu";
public const string MODE = ".menu";
public const string PRACC = ".pracc";
public const string MATCH = ".match";
public const string PAUSE = ".pause";
public const string UNPAUSE = ".unpause";
public const string UNPAUSE = ".unpause";
public const string READY = ".ready";
public const string UNREADY = ".unready";
public const string FORCEREADY = ".forceready";
Expand Down Expand Up @@ -63,6 +63,7 @@ public class PRACC_COMMAND
public const string SAVELAST = ".savelast";
public const string CHECKPOINT = ".checkpoint";
public const string BACK = ".back";
public const string UserRole = ".userrole";
}
public class Strings
{
Expand Down
7 changes: 5 additions & 2 deletions CSPracc/Managers/ProjectileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ private void RestoreSnapshot(CCSPlayerController player, string grenadeName)
player.PrintToCenter($"Failed to parse protectile id from {idofNade}");
return;
}
else if(CurrentProjectileStorage.Get(snapshotId, out ProjectileSnapshot snapshot))
RestoreSnapshot(player, idofNade);
}
internal void RestoreSnapshot(CCSPlayerController player, int snapshotId)
{
if (CurrentProjectileStorage.Get(snapshotId, out ProjectileSnapshot snapshot))
{
snapshot.Restore(player);
return;
Expand All @@ -134,7 +138,6 @@ private void RestoreSnapshot(CCSPlayerController player, string grenadeName)
return;
}
}

/// <summary>
/// Add grenade to the list
/// </summary>
Expand Down

0 comments on commit 5906e9a

Please sign in to comment.