-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.lua
More file actions
242 lines (189 loc) · 5.26 KB
/
admin.lua
File metadata and controls
242 lines (189 loc) · 5.26 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
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
tibia.adminList = {132253}
function tibia.isAdmin(player)
for _, usgn in ipairs(tibia.adminList) do
if player.usgn == usgn then
return true
end
end
return false
end
--[[
Admin Commands
!a - teleport forward
!b - broadcast to server with name
!c - teleport player to you
!d - broadcast to server without name
!e - explosion
!i - spawn item
!h - heal player
!l - run lua script (expensive)
!m - summon monster
!n - return npc position
!o - return tile position
!p - return position
!q - earthquake
!s - speedmod
!t - teleport you to player
!u - shutdown
!v - save server
]]
sea.listen("say", function(player, words)
if tibia.isAdmin(player) and words:sub(1,1) =='!' then
local command = words:lower():sub(2,2)
if words:sub(3,3) ~= ' ' and #words ~= 2 then
return
end
print(player.name..' used a command:'..words)
if command =='a' then
local distance = tonumber(words:sub(4))
if distance then
local rot = math.rad(player.rotation - 180)
local x, y = -math.sin(rot)*distance*32, math.cos(rot)*distance*32
player:setPosition(player.x + x, player.y + y)
else
player:message("Teleport forward: \"!a <distance>\"")
end
return 1
elseif command =='b' then
sea.message(0, player.name.." : "..words:sub(4).."@C", "255100100")
return 1
elseif command =='c' then
local targetID = tonumber(words:sub(4))
if targetID then
local target = sea.player[targetID]
if target.exists then
if target == player then
player:message("You may not teleport to yourself!")
end
target:setPosition(player.x, player.y)
return 1
end
end
player:message("Teleport player to you: \"!c <targetid>\"")
return 1
elseif command =='d' then
sea.message(0, words:sub(4).."@C", "255100100")
return 1
elseif command =='e' then
local dmg = tonumber(words:sub(4))
if dmg then
sea.explosion(player.x, player.y, dmg, dmg, player.id)
return 1
end
player:message("Spawn explosion: \"!e <dmg>\"")
return 1
elseif command =='i' then
local itemID = tonumber(words:sub(4))
if itemID then
player:addItem(tibia.Item.create(itemID))
return 1
end
player:message("Spawn item: \"!i <itemid>\"")
return 1
elseif command =='h' then
local s = words:find(' ',4)
local targetID = tonumber(words:sub(4,s))
if targetID then
local target = sea.player[targetID]
if target.exists then
local heal = s and tonumber(words:sub(s+1,words:find(' ',s+1))) or nil
if heal then
sea.explosion(target.x, target.y, 1, -heal)
return 1
end
end
end
player:message("Heal player: \"!h <targetid> <amount>\"")
return 1
elseif command =='l' then
local script = words:sub(4)
if script then
player:message(tostring(assert(loadstring(script))() or 'done!'))
return
end
player:message("Run lua script: \"!l <script>\"")
return 1
elseif command =='m' then
if sea.tile[player.tileX][player.tileY].zone.SAFE then
player:message("You may not spawn a monster in a safe zone.")
return 1
end
local name = words:sub(4)
if name then
for i, v in pairs(tibia.config.monster) do
if v.name:lower() == name:lower() then
local m = deepcopy(v)
m.x, m.y = player(id, 'x'), player(id, 'y')
Monster:new(m)
player:message("Monster "..name.." spawned.")
return 1
end
end
end
player:message("Monster "..name.." does not exist.")
return 1
elseif command =='n' then
player:message("{"..tileToPixel(player.tileX)..", "..tileToPixel(player.tileY)..'}')
return 1
elseif command =='o' then
player:message('{'..player.tileX..', '..player.tileY..'}')
return 1
elseif command =='p' then
player:message('{'..player.x..', '..player.y..'}')
return 1
elseif command =='q' then
local length = tonumber(words:sub(3))
if length then
length = math.min(length * 50, 250)
for _, player in ipairs(sea.Player.get()) do
player:shake(length)
end
for i = 1, 6 do
if math.random(0,1) == 1 then
sea.Player.playSoundForAll("weapons/explode"..i..".wav")
end
end
else
player:message("Earthquake: \"!q <length in seconds, max 5>\"")
end
return 1
elseif command =='s' then
local s = words:find(' ', 4)
local targetID = tonumber(words:sub(4, s))
if targetID then
local target = sea.player[targetID]
if target.exists then
local speed = s and tonumber(words:sub(s + 1, words:find(' ', s + 1))) or nil
if speed then
target.speed = speed
return 1
end
end
end
player:message("Speed modifier: \"!s <targetid> <speedmod, between -100 and 100>\"")
return 1
elseif command =='t' then
local targetID = tonumber(words:sub(3))
if targetID then
local target = sea.player[targetID]
if target.exists then
if target == player then
player:message("You may not teleport to yourself!")
end
player:setPosition(target.x, target.y)
return 1
end
end
player:message("Teleport to player: \"!t <targetid>\"")
return 1
elseif command =='u' then
local delay = tonumber(words:sub(3)) or 0
tibia.shutdown(delay * 1000)
return 1
elseif command =='v' then
sea.game:save()
player:message("Saved server!")
return 1
end
end
end)