forked from cartman-2000/FPSCap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommandLimitTPS.cs
More file actions
70 lines (63 loc) · 2.03 KB
/
Copy pathCommandLimitTPS.cs
File metadata and controls
70 lines (63 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using Rocket.API;
using Rocket.Core.Logging;
using Rocket.Unturned.Chat;
namespace FPSCap
{
public class CommandLimitTPS : IRocketCommand
{
public AllowedCaller AllowedCaller
{
get { return AllowedCaller.Both; }
}
public string Name
{
get { return "limittps"; }
}
public string Help
{
get { return "Limits the server tps/fps to the value set in the command. 0 disables the TPS cap."; }
}
public string Syntax
{
get { return "<TPS>"; }
}
public List<string> Aliases
{
get { return new List<string>() { "ltps" }; }
}
public List<string> Permissions
{
get { return new List<string> { "fpscap.ltps" }; }
}
public void Execute(IRocketPlayer caller, string[] command)
{
if (command.Length == 0)
{
UnturnedChat.Say(caller, FPSCap.Instance.Translations.Instance.Translate("ltps_command_help"));
return;
}
int limitTPS;
if (command.Length == 1 && int.TryParse(command[0], out limitTPS))
{
//limit the minimum tps that can be used above a value of 0, but less than 10, to 10.
if (limitTPS > 0 && limitTPS < 10)
{
limitTPS = 10;
}
UnityEngine.Application.targetFrameRate = limitTPS;
if (!(caller is ConsolePlayer))
{
UnturnedChat.Say(caller, FPSCap.Instance.Translations.Instance.Translate("tps_set", limitTPS));
}
Logger.Log(FPSCap.Instance.Translations.Instance.Translate("tps_set", limitTPS));
}
else
{
UnturnedChat.Say(caller, FPSCap.Instance.Translations.Instance.Translate("invalid_arg"));
return;
}
}
}
}