-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcheat.lua
376 lines (363 loc) · 13.2 KB
/
cheat.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
function HandleMoreCommand(Split, Player)
local AddMoreItems = function(OtherPlayer)
local HeldItem = Player:GetEquippedItem()
if HeldItem:IsEmpty() then
if Split[2] then
Player:SendMessageFailure("Player \"" .. OtherPlayer:GetName() .. "\" isn't holding an item")
else
OtherPlayer:SendMessageFailure("Please hold an item")
end
else
HeldItem.m_ItemCount = 64
Player:GetInventory():SetHotbarSlot(Player:GetInventory():GetEquippedSlotNum(), HeldItem)
OtherPlayer:SendMessageSuccess("Held item number set to 64")
if Split[2] then
Player:SendMessageSuccess("Successfully set held item number of player \"" .. OtherPlayer:GetName() .. "\" to 64")
end
end
end
if Split[2] == nil then
AddMoreItems(Player)
elseif Player:HasPermission("es.more.other") then
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], AddMoreItems) then
Player:SendMessageFailure("Player \"" .. Split[2] .. "\" not found")
end
end
return true
end
function HandleRepairCommand(Split, Player)
local Item = Player:GetEquippedItem()
if Item:IsDamageable() then
--Give a new item with the same type than the actual but with 0 damage, this way we avoid relogging
Item.m_ItemDamage = 0
Player:GetInventory():SetHotbarSlot(Player:GetInventory():GetEquippedSlotNum(), Item)
Player:SendMessageSuccess("Successfully repaired item")
else
Player:SendMessageFailure("Please hold a repairable item")
end
return true
end
function HandleFeedCommand(Split, Player)
local Feed = function(OtherPlayer)
OtherPlayer:SetFoodLevel(20)
OtherPlayer:SendMessageSuccess("Your hunger has been satisfied")
if Split[2] and Split[2] ~= "*" and Split[2] ~= "**" then
Player:SendMessageSuccess("Successfully fed player \"" .. OtherPlayer:GetName() .. "\"")
end
end
if Split[2] == nil then
Feed(Player)
elseif Split[2] == "*" or Split[2] == "**" then
cRoot:Get():ForEachPlayer(Feed)
Player:SendMessageInfo("Successfully fed all players")
elseif Player:HasPermission("es.feed.other") then
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], Feed) then
Player:SendMessageFailure("Player \"" .. Split[2] .. "\" not found")
end
end
return true
end
function HandleHealCommand(Split, Player)
local Heal = function(OtherPlayer)
OtherPlayer:SetFoodLevel(20)
OtherPlayer:Heal(20)
OtherPlayer:ClearEntityEffects()
OtherPlayer:SendMessageInfo("You have been healed")
if Split[2] and Split[2] ~= "*" and Split[2] ~= "**" then
Player:SendMessageSuccess("Successfully healed player \"" .. OtherPlayer:GetName() .. "\"")
end
end
if Split[2] == nil then
Heal(Player)
elseif Split[2] == "*" or Split[2] == "**" then
cRoot:Get():ForEachPlayer(Heal)
Player:SendMessageSuccess("Successfully healed all players")
elseif Player:HasPermission("es.heal.other") then
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], Heal) then
Player:SendMessageFailure("Player \"" .. Split[2] .. "\" not found")
end
end
return true
end
function HandleXPCommand(Split, Player)
local HandleXP = function(OtherPlayer)
if Split[2] == "show" then
Player:SendMessageSuccess("The current XP of player \"" .. OtherPlayer:GetName() .. "\" is ".. OtherPlayer:GetCurrentXp())
elseif Split[2] == "set" then
if tonumber(Split[4]) == nil then
Player:SendMessageFailure("\"" .. Split[4] .. "\" is not a valid number")
else
--Set player XP to the specified amount
OtherPlayer:SetCurrentExperience(Split[4])
Player:SendMessageSuccess("Successfully set XP of player \"" .. OtherPlayer:GetName() .. "\" to ".. Split[4])
end
elseif Split[2] == "give" then
if tonumber(Split[4]) == nil then
Player:SendMessageFailure("\"" .. Split[4] .. "\" is not a valid number")
else
OtherPlayer:SetCurrentExperience(Player:GetCurrentXp() + Split[4])
Player:SendMessageSuccess("Successfully gave " .. Split[4] .. " XP to player \"" .. OtherPlayer:GetName() .. "\"")
end
end
end
if Split[2] == nil then
Player:SendMessageInfo("Usage: " .. Split[1] .. " <show|set|give> <player> [value]")
elseif Split[3] == nil or Split[2] ~= "show" and Split[4] == nil then
if Split[2] == "show" then
Player:SendMessageInfo("Usage: " .. Split[1] .. " " .. Split[2] .. " <player>")
else
Player:SendMessageInfo("Usage: " .. Split[1] .. " " .. Split[2] .. " <player> <value>")
end
else
if Split[3] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[3], HandleXP) then
Player:SendMessageFailure("Player \"" .. Split[3] .. "\" not found")
end
end
return true
end
function HandleHatCommand(Split, Player)
local Hat = cItem(Player:GetEquippedItem())
Hat.m_ItemCount = 1
local ArmorSlot = Player:GetInventory():GetArmorSlot(0)
if not ArmorSlot:IsEmpty() then
Player:GetInventory():AddItem(ArmorSlot)
end
--Set chestplate slot to the item the player is holding
if not Player:GetEquippedItem():IsEmpty() then
Player:GetInventory():SetArmorSlot(0, Hat)
Player:GetInventory():RemoveOneEquippedItem()
Player:SendMessageSuccess("Enjoy your new hat!")
else
Player:SendMessageFailure("Please hold an item")
end
return true
end
function HandleSpeedCommand(Split, Player)
local SpeedType = Split[1]:gsub("/", ""):gsub("speed", "")
local Speed = Split[2]
local PlayerName = Split[3]
if Split[1] == "/speed" then
SpeedType = Split[2]
Speed = Split[3]
PlayerName = Split[4]
end
local SetSpeed = function(OtherPlayer)
if tonumber(Speed) == nil then
Player:SendMessageFailure("\"" .. Speed .. "\" is not a valid number")
else
--Set new speed
if tonumber(Speed) > 100 then
Speed = 100
end
if Split[1] == "/flyspeed" or Split[1] == "/speed" and Split[2] == "fly" then
OtherPlayer:SetFlyingMaxSpeed(Speed)
elseif Split[1] == "/walkspeed" or Split[1] == "/speed" and Split[2] == "walk" then
OtherPlayer:SetNormalMaxSpeed(Speed)
elseif Split[1] == "/runspeed" or Split[1] == "/speed" and Split[2] == "run" then
OtherPlayer:SetSprintingMaxSpeed(Speed)
end
OtherPlayer:SendMessageSuccess("Your " .. SpeedType .. " speed has been set to " .. Speed)
if PlayerName then
Player:SendMessageSuccess("Successfully set " .. SpeedType .. " speed of player \"" .. OtherPlayer:GetName() .. "\" to " .. Speed)
end
end
end
if Speed == nil then
if Split[1] == "/speed" then
if SpeedType then
Player:SendMessageInfo("Usage: " .. Split[1] .. " " .. SpeedType .. " <speed> [player]")
else
Player:SendMessageInfo("Usage: " .. Split[1] .. " <fly|walk|run> <speed> [player]")
end
else
Player:SendMessageInfo("Usage: " .. Split[1] .. " <speed> [player]")
end
elseif PlayerName == nil then
SetSpeed(Player)
else
if PlayerName == "" or not cRoot:Get():FindAndDoWithPlayer(PlayerName, SetSpeed) then
Player:SendMessageFailure("Player \"" .. PlayerName .. "\" not found")
end
end
return true
end
function HandleFlyCommand(Split, Player)
local ToggleFly = function(OtherPlayer)
OtherPlayer:SetCanFly(not OtherPlayer:CanFly())
if OtherPlayer:CanFly() then
OtherPlayer:SendMessageSuccess("Fly mode has been enabled")
else
OtherPlayer:SendMessageSuccess("Fly mode has been disabled")
end
if Split[2] then
if OtherPlayer:CanFly() then
Player:SendMessageSuccess("Successfully enabled fly mode for player \"" .. OtherPlayer:GetName() .. "\"")
else
Player:SendMessageSuccess("Successfully disabled fly mode for player \"" .. OtherPlayer:GetName() .. "\"")
end
end
end
if Split[2] == nil then
ToggleFly(Player)
elseif Player:HasPermission("es.fly.other") then
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], ToggleFly) then
Player:SendMessageFailure("Player \"" .. Split[2] .. "\" not found")
end
end
return true
end
function HandleVanishCommand(Split, Player)
local ToggleVanish = function(OtherPlayer)
OtherPlayer:SetVisible(not OtherPlayer:IsVisible())
if OtherPlayer:IsVisible() then
OtherPlayer:SendMessageSuccess("You aren't hidden anymore")
else
OtherPlayer:SendMessageSuccess("You are now hidden")
end
if Split[2] then
if OtherPlayer:IsVisible() then
Player:SendMessageSuccess("Successfully enabled visibility for player \"" .. OtherPlayer:GetName() .. "\"")
else
Player:SendMessageSuccess("Successfully disabled visibility for player \"" .. OtherPlayer:GetName() .. "\"")
end
end
end
if Split[2] == nil then
ToggleVanish(Player)
elseif Player:HasPermission("es.vanish.other") then
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], ToggleVanish) then
Player:SendMessageFailure("Player \"" .. Split[2] .. "\" not found")
end
end
return true
end
function HandlePowertoolCommand(Split, Player)
local HeldItem = Player:GetEquippedItem()
if Split[2] == nil then
Player:SendMessageInfo("Usage: " .. Split[1] .. " <command> [arguments ...]")
elseif not HeldItem:IsEmpty() then
string.startswith = function(self, str)
return self:find("^" .. str) ~= nil
end
if table.concat(Split, " ", 2):startswith("/") then
HeldItem.m_CustomName = table.concat(Split, " ", 2)
else
HeldItem.m_CustomName = "/" .. table.concat(Split, " ", 2)
end
Player:GetInventory():SetHotbarSlot(Player:GetInventory():GetEquippedSlotNum(), HeldItem)
Player:SendMessageSuccess("Successfully bound command to item")
else
--If player doesn't hold an item, notify
Player:SendMessageFailure("Please hold an item")
end
return true
end
function HandleFireballCommand(Split, Player)
local World = Player:GetWorld()
local X = Player:GetPosX()
local Y = Player:GetPosY() + 1.5
local Z = Player:GetPosZ()
local Speed = Player:GetLookVector() * 30
if Split[2] == "small" then
World:CreateProjectile(X, Y, Z, cProjectileEntity.pkFireCharge, Player, Player:GetEquippedItem(), Speed)
else
World:CreateProjectile(X, Y, Z, cProjectileEntity.pkGhastFireball, Player, Player:GetEquippedItem(), Speed)
end
return true
end
function HandleNukeCommand(Split, Player)
local SpawnNuke = function(OtherPlayer)
local X = OtherPlayer:GetPosX()
local Y = OtherPlayer:GetPosY() + 35
local Z = OtherPlayer:GetPosZ()
OtherPlayer:SendMessageInfo("May death rain upon them")
for x = -3, 3, 3 do
for z = -3, 3, 3 do
OtherPlayer:GetWorld():SpawnPrimedTNT(Vector3d(X + x, Y, Z + z), 52)
end
end
if Split[2] then
Player:SendMessageSuccess("Successfully spawned nuke above player " ..OtherPlayer:GetName())
end
end
if Split[2] == nil then
cRoot:Get():ForEachPlayer(SpawnNuke)
else
if not cRoot:Get():FindAndDoWithPlayer(table.concat(Split, " ", 2), SpawnNuke) then
Player:SendMessageFailure("Player \"" .. table.concat(Split, " ", 2) .. "\" not found")
end
end
return true
end
function HandleGodCommand(Split, Player)
local EnableGod = function(OtherPlayer)
if GodModeList[OtherPlayer:GetUUID()] == nil then
OtherPlayer:SetInvulnerableTicks(6048000)
OtherPlayer:SendMessageSuccess("God mode has been enabled")
if Split[2] then
Player:SendMessageSuccess("Successfully enabled God mode for " .. OtherPlayer:GetName())
end
GodModeList[OtherPlayer:GetUUID()] = true
else
OtherPlayer:SetInvulnerableTicks(0)
OtherPlayer:SendMessageSuccess("God mode has been disabled")
if Split[2] then
Player:SendMessageSuccess("Successfully disabled God mode for " .. OtherPlayer:GetName())
end
GodModeList[OtherPlayer:GetUUID()] = nil
end
end
if Split[2] == nil then
EnableGod(Player)
elseif Player:HasPermission("es.god.other") then
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], EnableGod) then
Player:SendMessageFailure("Player \"" .. Split[2] .. "\" not found")
end
end
return true
end
function HandleGamemodeCommand(Split, Player)
local ChangeGamemode = function(OtherPlayer)
if Split[1] == "/adventure" or Split[1] == "/gma" then
if Player:HasPermission("es.gm.adventure.other") then
OtherPlayer:SetGameMode(2)
OtherPlayer:SendMessageInfo("Gamemode set to adventure")
if Split[2] then
Player:SendMessageSuccess("Successfully set gamemode of player \"" .. OtherPlayer:GetName() .. "\" to adventure")
end
end
elseif Split[1] == "/creative" or Split[1] == "/gmc" then
if Player:HasPermission("es.gm.creative.other") then
OtherPlayer:SetGameMode(1)
OtherPlayer:SendMessageInfo("Gamemode set to creative")
if Split[2] then
Player:SendMessageSuccess("Successfully set gamemode of player \"" .. OtherPlayer:GetName() .. "\" to creative")
end
end
elseif Split[1] == "/spectator" or Split[1] == "/gmsp" then
if Player:HasPermission("es.gm.spectator.other") then
OtherPlayer:SetGameMode(3)
OtherPlayer:SendMessageInfo("Gamemode set to spectator")
if Split[2] then
Player:SendMessageSuccess("Successfully set gamemode of player \"" .. OtherPlayer:GetName() .. "\" to spectator")
end
end
elseif Split[1] == "/survival" or Split[1] == "/gms" then
if Player:HasPermission("es.gm.survival.other") then
OtherPlayer:SetGameMode(0)
OtherPlayer:SendMessageInfo("Gamemode set to survival")
if Split[2] then
Player:SendMessageSuccess("Successfully set gamemode of player \"" .. OtherPlayer:GetName() .. "\" to survival")
end
end
end
end
if Split[2] == nil then
ChangeGamemode(Player)
else
if Split[2] == "" or not cRoot:Get():FindAndDoWithPlayer(Split[2], ChangeGamemode) then
Player:SendMessageFailure("Player \"" .. Split[2] .. "\" not found")
end
end
return true
end