warzone.lua

main 326 lines · 16.7 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1local condition = Condition(CONDITION_OUTFIT)
2local SPEED_MOUNT = 150
3local function onCronometroTime()
4 if Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_START_WARZONE) == 01 then
5 if _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] == 0 and _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] == 0 then
6 local WINNER_ID = 0
7 local players = Game.getPlayers()
8
9 if Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_BLUE_TEAM) > Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_RED_TEAM) then
10
11 WINNER_ID = 01
12 elseif Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_RED_TEAM) > Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_BLUE_TEAM) then
13
14 WINNER_ID = 02
15 else
16
17 WINNER_ID = 03
18 end
19
20 db.query("DELETE FROM `player_storage` WHERE `player_storage`.`key` = " .._GLOBAL_RANDOM.WARZONE.EXP_STORAGE.. ";")
21 for _, targetPlayer in ipairs(players) do
22 if targetPlayer:getStorageValue(_SYSTEM.WARZONE) > 00 then
23 local DELIVERY_POINTS = 0
24 -- DESAFIO
25 if targetPlayer:getStorageValue(_DESAFIOS[00].DESAFIO_ID) > 00 then
26 onPlayerDesafios(targetPlayer, 74, 01)
27 end
28 if WINNER_ID == 03 then
29 DELIVERY_POINTS = _GLOBAL_RANDOM.WARZONE.EMPATE_POINTS
30 if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) == 09 then
31 DELIVERY_POINTS = _GLOBAL_RANDOM.WARZONE.EMPATE_POINTS * 02
32 end
33 if targetPlayer:getStorageValue(_SYSTEM.PVP_POINTS) < 00 then
34 targetPlayer:setStorageValue(_SYSTEM.PVP_POINTS, ((targetPlayer:getStorageValue(_SYSTEM.PVP_POINTS) + DELIVERY_POINTS) + 01))
35 else
36 targetPlayer:setStorageValue(_SYSTEM.PVP_POINTS, (targetPlayer:getStorageValue(_SYSTEM.PVP_POINTS) + DELIVERY_POINTS))
37 end
38
39
40 targetPlayer:sendCancelMessage("@LootMSG 3219 05 00 " ..DELIVERY_POINTS)
41 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_01, nil)
42 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_02, nil)
43 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_03, nil)
44 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_04, nil)
45 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_05, nil)
46 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_06, nil)
47 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_07, nil)
48 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_08, nil)
49 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_09, nil)
50 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_10, nil)
51 targetPlayer:setStorageValue(_GLOBAL_RANDOM.WARZONE.EXP_STORAGE, nil)
52
53 doInventario(targetPlayer, 00, 04, 00)
54 doBackpack(targetPlayer, 11)
55 targetPlayer:sendCancelMessage("@StarCliente")
56 else
57 if targetPlayer:getStorageValue(_SYSTEM.WARZONE) == WINNER_ID then
58 DELIVERY_POINTS = _GLOBAL_RANDOM.WARZONE.WINNER_POINTS
59 if Game.getStorageValue(_GLOBAL_RANDOM.EVENTOS_TABLE[00].EVENT_ID) == 09 then
60 DELIVERY_POINTS = _GLOBAL_RANDOM.WARZONE.WINNER_POINTS * 02
61 end
62 if targetPlayer:getStorageValue(_SYSTEM.PVP_POINTS) < 00 then
63 targetPlayer:setStorageValue(_SYSTEM.PVP_POINTS, ((targetPlayer:getStorageValue(_SYSTEM.PVP_POINTS) + DELIVERY_POINTS) + 01))
64 else
65 targetPlayer:setStorageValue(_SYSTEM.PVP_POINTS, (targetPlayer:getStorageValue(_SYSTEM.PVP_POINTS) + DELIVERY_POINTS))
66 end
67
68 targetPlayer:sendCancelMessage("@LootMSG 3219 05 00 " ..DELIVERY_POINTS)
69 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_01, nil)
70 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_02, nil)
71 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_03, nil)
72 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_04, nil)
73 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_05, nil)
74 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_06, nil)
75 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_07, nil)
76 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_08, nil)
77 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_09, nil)
78 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_10, nil)
79
80 if targetPlayer:getStorageValue(_GLOBAL_RANDOM.WARZONE.EXP_STORAGE) < 00 then
81 targetPlayer:setStorageValue(_GLOBAL_RANDOM.WARZONE.EXP_STORAGE, 01)
82 else
83 targetPlayer:setStorageValue(_GLOBAL_RANDOM.WARZONE.EXP_STORAGE, (targetPlayer:getStorageValue(_GLOBAL_RANDOM.WARZONE.EXP_STORAGE) + 01))
84 end
85
86
87
88 doInventario(targetPlayer, 00, 04, 00)
89 doBackpack(targetPlayer, 11)
90 targetPlayer:sendCancelMessage("@StarCliente")
91 else
92
93 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_01, nil)
94 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_02, nil)
95 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_03, nil)
96 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_04, nil)
97 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_05, nil)
98 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_06, nil)
99 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_07, nil)
100 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_08, nil)
101 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_09, nil)
102 targetPlayer:setStorageValue(_SYSTEM.INVENTARIO[04].UID_10, nil)
103 targetPlayer:setStorageValue(_GLOBAL_RANDOM.WARZONE.EXP_STORAGE, nil)
104
105 doInventario(targetPlayer, 00, 04, 00)
106 targetPlayer:sendCancelMessage("@StarCliente")
107 end
108 end
109
110 addEvent(function()
111 if targetPlayer:getStorageValue(_QUESTLOG[163].UID_01) == 01 then
112 targetPlayer:setStorageValue(_QUESTLOG[163].UID_01, 100)
113
114 PlayerGoldCoins(targetPlayer, 02, 3500)
115 targetPlayer:addExperience(35000, true, true)
116 targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Seu Quest Log foi atualizado.")
117 end
118 targetPlayer:sendCancelMessage("@TutorShow 44")
119 end, 3000)
120 targetPlayer:sendCancelMessage("@TutorShow 44")
121 targetPlayer:setTown(Town(01))
122 targetPlayer:removeCondition(CONDITION_OUTFIT)
123 targetPlayer:changeSpeed(targetPlayer:getBaseSpeed())
124 targetPlayer:setMaxHealth((targetPlayer:getLevel() * 10) + 140)
125 targetPlayer:sendCancelMessage("@NoTeleport 00")
126 targetPlayer:setStorageValue(_SYSTEM.WARZONE, nil)
127 targetPlayer:setStorageValue(_GLOBAL_RANDOM.WARZONE.LOBBY_TIMER, nil)
128 targetPlayer:teleportTo({x=3999, y=991, z=7})
129 targetPlayer:getPosition():sendMagicEffect(11)
130 else
131 if targetPlayer:getStorageValue(_GLOBAL_RANDOM.WARZONE.EXP_STORAGE) > 00 then
132
133 end
134 targetPlayer:setStorageValue(_GLOBAL_RANDOM.WARZONE.EXP_STORAGE, nil)
135 end
136
137 targetPlayer:sendCancelMessage("@EndAlert 01")
138 end
139
140 Game.broadcastMessage("A Warzone foi finalizada.")
141 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_START_WARZONE, nil)
142 return false
143 elseif _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] > 0 and _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] > 0 then
144 _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] = _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] - 1
145 elseif _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] > 0 and _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] == 0 then
146 _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] = 59
147 _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] = _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] - 1
148 elseif _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] == 0 and _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] > 0 then
149 _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] = _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] - 1
150 end
151
152 if _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] == 20 and _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] == 59 then
153 local players = Game.getPlayers()
154 for _, targetPlayer in ipairs(players) do
155 if targetPlayer:getLevel() >= _GLOBAL_RANDOM.WARZONE.LEVEL then
156 if targetPlayer:getStorageValue(_SYSTEM.WARZONE) < 01 then
157 targetPlayer:sendCancelMessage("@EndAlert 02")
158 end
159 if targetPlayer:getStorageValue(_SYSTEM.WARZONE) > 00 then
160
161 end
162 end
163 end
164 end
165 if _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] == 19 and _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] == 59 then
166 if Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_COUNT_PLAYER) < 04 then
167 local players = Game.getPlayers()
168 for _, targetPlayer in ipairs(players) do
169 if targetPlayer:getLevel() >= _GLOBAL_RANDOM.WARZONE.LEVEL then
170 if targetPlayer:getStorageValue(_SYSTEM.WARZONE) > 00 then
171 targetPlayer:setTown(Town(01))
172 targetPlayer:removeCondition(CONDITION_OUTFIT)
173 targetPlayer:changeSpeed(targetPlayer:getBaseSpeed())
174 targetPlayer:setMaxHealth((targetPlayer:getLevel() * 10) + 140)
175 targetPlayer:sendCancelMessage("@NoTeleport 00")
176 targetPlayer:setStorageValue(_SYSTEM.WARZONE, nil)
177 targetPlayer:setStorageValue(_GLOBAL_RANDOM.WARZONE.LOBBY_TIMER, nil)
178 targetPlayer:teleportTo({x=3999, y=991, z=7})
179 targetPlayer:getPosition():sendMagicEffect(11)
180 targetPlayer:sendCancelMessage("@EndAlert 01")
181 targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "A Warzone foi cancelada por falta de jogadores.")
182 end
183 end
184 end
185
186 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_START_WARZONE, nil)
187 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_COUNT_PLAYER, 00)
188 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_BLUE_TEAM, 00)
189 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_RED_TEAM, 00)
190 _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] = _GLOBAL_RANDOM.WARZONE.TIMER[01]
191 _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] = _GLOBAL_RANDOM.WARZONE.TIMER[02]
192 return true
193 else
194 local players = Game.getPlayers()
195 local lobPlayers = {}
196 for _, targetPlayer in ipairs(players) do
197 if targetPlayer:getLevel() >= _GLOBAL_RANDOM.WARZONE.LEVEL then
198 if targetPlayer:getStorageValue(_SYSTEM.WARZONE) > 00 then
199 table.insert(lobPlayers, targetPlayer:getLevel())
200 end
201 end
202 end
203
204 table.sort(lobPlayers, function(a, b) return a > b end)
205 if #lobPlayers > 01 then
206 for X = 01, #lobPlayers do
207 for _, tid in ipairs(players) do
208 if tid:getLevel() >= _GLOBAL_RANDOM.WARZONE.LEVEL then
209 if tid:getStorageValue(_SYSTEM.WARZONE) > 00 then
210 if tid:getLevel() == lobPlayers[X] then
211 local BLUE_PARTY = Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_BLUE_PLAYER)
212 local RED_PARTY = Game.getStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_RED_PLAYER)
213 if BLUE_PARTY == nil or BLUE_PARTY < 00 then
214 BLUE_PARTY = 00
215 end
216 if RED_PARTY == nil or RED_PARTY < 00 then
217 RED_PARTY = 00
218 end
219 if RED_PARTY > BLUE_PARTY then
220 print("[" ..tid:getLevel().. "] NAME: " ..tid:getName().. " (BLUE)")
221 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_BLUE_PLAYER, (BLUE_PARTY + 01))
222 tid:teleportTo(_GLOBAL_RANDOM.WARZONE.POS_BLUE_TIME)
223 tid:getPosition():sendMagicEffect(11)
224 tid:setStorageValue(_SYSTEM.WARZONE, 01)
225 tid:setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_BLUE_PLAYER, 01)
226 tid:changeSpeed(SPEED_MOUNT)
227 _GLOBAL_RANDOM.WARZONE.TIME_SIDE = 01
228
229 condition:setOutfit({lookType = tid:getOutfit().lookType, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = tid:getOutfit().lookAddons})
230 condition:setTicks(-1)
231 tid:addCondition(condition)
232
233 elseif BLUE_PARTY > RED_PARTY then
234 print("[" ..tid:getLevel().. "] NAME: " ..tid:getName().. " (RED)")
235 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_RED_PLAYER, (RED_PARTY + 01))
236 tid:teleportTo(_GLOBAL_RANDOM.WARZONE.POS_RED_TIME)
237 tid:getPosition():sendMagicEffect(11)
238 tid:setStorageValue(_SYSTEM.WARZONE, 02)
239 tid:setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_RED_PLAYER, 01)
240 tid:changeSpeed(SPEED_MOUNT)
241 _GLOBAL_RANDOM.WARZONE.TIME_SIDE = 02
242
243 condition:setOutfit({lookType = tid:getOutfit().lookType, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = tid:getOutfit().lookAddons})
244 condition:setTicks(-1)
245 tid:addCondition(condition)
246 else
247 if _GLOBAL_RANDOM.WARZONE.TIME_SIDE == 01 then
248 print("[" ..tid:getLevel().. "] NAME: " ..tid:getName().. " (BLUE)")
249 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_BLUE_PLAYER, (BLUE_PARTY + 01))
250 tid:teleportTo(_GLOBAL_RANDOM.WARZONE.POS_BLUE_TIME)
251 tid:getPosition():sendMagicEffect(11)
252 tid:setStorageValue(_SYSTEM.WARZONE, 01)
253 tid:setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_BLUE_PLAYER, 01)
254 tid:changeSpeed(SPEED_MOUNT)
255 _GLOBAL_RANDOM.WARZONE.TIME_SIDE = 02
256
257 condition:setOutfit({lookType = tid:getOutfit().lookType, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86, lookTypeEx = 0, lookAddons = tid:getOutfit().lookAddons})
258 condition:setTicks(-1)
259 tid:addCondition(condition)
260 else
261 print("[" ..tid:getLevel().. "] NAME: " ..tid:getName().. " (RED)")
262 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_RED_PLAYER, (RED_PARTY + 01))
263 tid:teleportTo(_GLOBAL_RANDOM.WARZONE.POS_RED_TIME)
264 tid:getPosition():sendMagicEffect(11)
265 tid:setStorageValue(_SYSTEM.WARZONE, 02)
266 tid:setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_RED_PLAYER, 01)
267 tid:changeSpeed(SPEED_MOUNT)
268 _GLOBAL_RANDOM.WARZONE.TIME_SIDE = 01
269
270 condition:setOutfit({lookType = tid:getOutfit().lookType, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94, lookTypeEx = 0, lookAddons = tid:getOutfit().lookAddons})
271 condition:setTicks(-1)
272 tid:addCondition(condition)
273 end
274 end
275 end
276 end
277 end
278 end
279 end
280 else
281 print("Fim da Warzone")
282 return true
283 end
284 end
285 end
286 addEvent(onCronometroTime, 1000)
287 end
288end
289local function StartedWarzone()
290 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_START_WARZONE, 01)
291 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.STORAGE_COUNT_PLAYER, 00)
292 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_BLUE_TEAM, 00)
293 Game.setStorageValue(_GLOBAL_RANDOM.WARZONE.PLACAR_RED_TEAM, 00)
294 _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[01] = _GLOBAL_RANDOM.WARZONE.TIMER[01]
295 _GLOBAL_RANDOM.WARZONE.LEFT_TIMER[02] = _GLOBAL_RANDOM.WARZONE.TIMER[02]
296
297 local players = Game.getPlayers()
298 for _, targetPlayer in ipairs(players) do
299 if targetPlayer:getLevel() >= _GLOBAL_RANDOM.WARZONE.LEVEL then
300 targetPlayer:sendCancelMessage("@WarzoneStart 00")
301 end
302 end
303
304 addEvent(onCronometroTime, 1000)
305 return false
306end
307local function WarzoneWarning(time)
308 local remaningTime = tonumber(time) - 60000
309
310
311 if remaningTime > 60000 then
312 addEvent(WarzoneWarning, 60000, remaningTime)
313 else
314
315 addEvent(StartedWarzone, 60000)
316 end
317end
318function onTime(interval)
319 local remaningTime = configManager.getNumber(configKeys.SERVER_SAVE_NOTIFY_DURATION) * 60000
320 if configManager.getBoolean(configKeys.SERVER_SAVE_NOTIFY_MESSAGE) then
321
322 end
323
324 addEvent(WarzoneWarning, 60000, remaningTime)
325 return true
326end
Top