PLUGIN Title Rick Anti Cheat PLUGIN Description PLUGIN Author Rick PLU

 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
PLUGIN.Title = "Rick Anti Cheat"
PLUGIN.Description = ""
PLUGIN.Author = "Rick"
PLUGIN.Version = "0.3a"
PLUGIN.RID = "403"
-- Contacts: bearz.ru/rick
function PLUGIN:Init()
self:LoadConfig()
self:updateCheck()
playerCoords = {}
timer.Repeat( 2, function() self:EverySecond() end )
end
function PLUGIN:LoadConfig()
local b, res = config.Read("RickAC")
self.Config = res or {}
if (not b) then
self:LoadDefaultConfig()
if (res) then
config.Save("RickAC")
end
end
end
function PLUGIN:OnUserConnect( netuser )
name = netuser.displayName
playerCoords[name] = netuser.playerClient.lastKnownPosition
end
function PLUGIN:EverySecond()
local netusers = rust.GetAllNetUsers()
for k,netuser in pairs(netusers) do
local coords = netuser.playerClient.lastKnownPosition
local dist1 = self.Config.dist1
local dist2 = self.Config.dist2
local dist3 = self.Config.dist3
name = netuser.displayName
if playerCoords[name].x ~= 0 then
dist = math.floor(math.sqrt( math.pow(coords.x-(playerCoords[name].x), 2) + math.pow(coords.z-(playerCoords[name].z), 2) ))
if dist >= dist1 and dist < dist3 then
if (self.Config.log == 1) then
print (self.Title..": "..name.." moved "..dist.." meters in 2 seconds.")
end
if (self.Config.chat == 1) then
rust.BroadcastChat (self.Config.chatName, name.." moved "..dist.." meters in 2 seconds.")
end
if (self.Config.kick == 1 and dist >= dist2) then
rust.RunServerCommand("kick "..name.."")
rust.BroadcastChat (self.Config.chatName, name.." has been kicked.")
print (self.Title..": "..name.." has been kicked.")
end
end
end
if ( netuser.playerClient ) then
playerCoords[name] = netuser.playerClient.lastKnownPosition
else
return
end
end
end
function PLUGIN:LoadDefaultConfig()
self.Config.chatName = "RickAC"
self.Config.dist1 = 25
self.Config.dist2 = 30
self.Config.dist3 = 100
self.Config.log = 1
self.Config.chat = 0
self.Config.kick = 0
end
function PLUGIN:updateCheck()
local b = webrequest.Send("http://rust.bearz.ru/update/"..self.RID..".txt", function(code, response)
if (code == 200) then
if (response ~= self.Version) then
print(self.Title..": Please update to version "..response.." at http://forum.rustoxide.com/resources/"..self.RID)
else
print(self.Title..": Update check passed.")
end
end
end )
if (not b) then
print(self.Title..": Update check failed.")
end
end