-
Notifications
You must be signed in to change notification settings - Fork 21
/
PlayerInfoLibPComponent.cs
45 lines (41 loc) · 1.12 KB
/
PlayerInfoLibPComponent.cs
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
using Rocket.Unturned.Player;
using System;
namespace PlayerInfoLibrary
{
public class PlayerInfoLibPComponent : UnturnedPlayerComponent
{
private bool start;
private DateTime startTime;
private PlayerData pData;
private float ping;
protected override void Load()
{
start = false;
}
internal void Start(PlayerData pdata)
{
startTime = DateTime.Now;
pData = pdata;
start = true;
}
public void FixedUpdate()
{
if (start)
{
ping = Player.Ping;
if (ping == 0)
ping = 1;
if ((DateTime.Now - startTime).TotalSeconds >= 3 + (ping * 10))
{
start = false;
if (Player.CSteamID.GetIP() != pData.IP)
{
pData.IP = Player.CSteamID.GetIP();
PlayerInfoLib.Database.SaveToDB(pData);
}
enabled = false;
}
}
}
}
}