Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add cooldown to command "!entity refresh"
for prevent cheating...
  • Loading branch information
foogs committed Aug 26, 2018
commit 659c28bddce5ffbfb5a9c18ea1c4bfe47c14b037
21 changes: 21 additions & 0 deletions Essentials/Commands/EntityModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,34 @@ public class EntityModule : CommandModule
private static Action<MyReplicationServer, IMyReplicable, Endpoint> _forceReplicable;
#pragma warning restore 649

private static Dictionary<ulong,DateTime> _commandtimeout = new Dictionary<ulong,DateTime>();

[Command("refresh", "Resyncs all entities for the player running the command.")]
[Permission(MyPromoteLevel.None)]
public void Refresh()
{
if (Context.Player == null)
return;

var steamid = Context.Player.SteamUserId;
if (_commandtimeout.TryGetValue(steamid, out DateTime lastcommand))
{
TimeSpan difference = DateTime.Now - lastcommand;
if (difference.TotalMinutes < 1)
{
Context.Respond($"Cooldown! You must wait 1 minute.");
return;
}
else
{
_commandtimeout[steamid] = DateTime.Now;
}
}
else
{
_commandtimeout.Add(steamid, DateTime.Now);
}

var playerEndpoint = new Endpoint(Context.Player.SteamUserId, 0);
var replicationServer = (MyReplicationServer)MyMultiplayer.ReplicationLayer;
var clientDataDict = _clientStates.Invoke(replicationServer);
Expand Down