-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathjails.lua
104 lines (100 loc) · 3.68 KB
/
jails.lua
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function HandleJailCommand(Split, Player)
local JailPlayer = function(OtherPlayer)
if Jailed[OtherPlayer:GetUUID()] then
Player:SendMessageFailure("Player \"" .. OtherPlayer:GetName() .. "\" is jailed")
end
if OtherPlayer:GetWorld():GetName() ~= Jails[Split[3]]["w"] then
OtherPlayer:MoveToWorld(cRoot:Get():GetWorld(Jails[Split[3]]["w"]), true, Vector3d(Jails[Split[3]]["x"] + 0.5, Jails[Split[3]]["y"], Jails[Split[3]]["z"] + 0.5))
else
OtherPlayer:TeleportToCoords(Jails[Split[3]]["x"] + 0.5, Jails[Split[3]]["y"], Jails[Split[3]]["z"] + 0.5)
end
UsersINI:SetValue(OtherPlayer:GetUUID(), "Jailed", "true")
UsersINI:WriteFile("users.ini")
Jailed[OtherPlayer:GetUUID()] = true
OtherPlayer:SendMessageInfo("You have been jailed")
end
if Split[2] == nil then
HandleListJailCommand(Split, Player)
elseif Split[3] == nil then
Player:SendMessageInfo("Usage: " .. Split[1] .. " <player> <jail>")
elseif Jails[Split[3]] == nil then
Player:SendMessageFailure("Jail \"" .. Split[3] .. "\" is invalid")
else
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], JailPlayer) then
Player:SendMessageFailure("Player \"" .. Split[2] .. "\" not found")
end
end
return true
end
function HandleUnJailCommand(Split, Player)
local UnjailPlayer = function(OtherPlayer)
local World = OtherPlayer:GetWorld()
OtherPlayer:TeleportToCoords(World:GetSpawnX(), World:GetSpawnY(), World:GetSpawnZ())
UsersINI:SetValue(OtherPlayer:GetUUID(), "Jailed", "false")
UsersINI:WriteFile("users.ini")
Jailed[OtherPlayer:GetUUID()] = false
OtherPlayer:SendMessageInfo("You have been unjailed")
Player:SendMessageSuccess("Successfully unjailed player \"" .. OtherPlayer:GetName() .. "\"")
end
if Split[2] == nil then
Player:SendMessageInfo("Usage: " .. Split[1] .. " <player> <jail>")
else
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], UnjailPlayer) then
Player:SendMessageFailure("Player \"" .. Split[2] .. "\" not found")
end
end
return true
end
function HandleSetJailCommand(Split, Player)
local World = Player:GetWorld():GetName()
local PosX = math.floor(Player:GetPosX())
local PosY = math.floor(Player:GetPosY())
local PosZ = math.floor(Player:GetPosZ())
if Split[2] == nil then
Player:SendMessageInfo("Usage: " .. Split[1] .. " <name>")
return true
end
if Jails[Split[2]] == nil then
Jails[Split[2]] = {}
end
if JailsINI:FindKey(Split[2])<0 then
Jails[Split[2]]["w"] = World
Jails[Split[2]]["x"] = PosX
Jails[Split[2]]["y"] = PosY
Jails[Split[2]]["z"] = PosZ
JailsINI:AddKeyName(Split[2])
JailsINI:SetValue(Split[2] , "w" , World)
JailsINI:SetValue(Split[2] , "x" , PosX)
JailsINI:SetValue(Split[2] , "y" , PosY)
JailsINI:SetValue(Split[2] , "z" , PosZ)
JailsINI:WriteFile("jails.ini")
Player:SendMessageSuccess("Jail \"" .. Split[2] .. "\" set to world:\"" .. World .. "\", X:" .. PosX .. ", Y:" .. PosY .. ", Z:" .. PosZ)
else
Player:SendMessageFailure("Jail \"" .. Split[2] .. "\" already exists")
end
return true
end
function HandleDelJailCommand(Split, Player)
if Split[2] == nil then
Player:SendMessageInfo("Usage: " .. Split[1] .. " <jail>")
return true
end
Jails[Split[2]] = nil
if JailsINI:FindKey(Split[2])>-1 then
JailsINI:DeleteKey(Split[2])
JailsINI:WriteFile("jails.ini")
else
Player:SendMessageFailure("Jail \"" .. Split[2] .. "\" was not found")
return true
end
Player:SendMessageSuccess("Successfully removed jail \"" .. Split[2] .. "\"")
return true
end
function HandleListJailCommand(Split, Player)
local JailName = ""
for k, v in pairs (Jails) do
JailName = JailName .. k .. ", "
end
Player:SendMessageInfo("Jails: " .. cChatColor.LightGreen .. JailName:sub(1, JailName:len() - 2))
return true
end