1local function onLoadPVPRoom(cid, step)
2 local player = Player(cid)
3 if player then
4 local A = Game.getStorageValue(_PVP_ROOM[01].CONTAGEM_PLAYER) or 0
5 local B = Game.getStorageValue(_PVP_ROOM[02].CONTAGEM_PLAYER) or 0
6 local C = Game.getStorageValue(_PVP_ROOM[03].CONTAGEM_PLAYER) or 0
7 local D = Game.getStorageValue(_PVP_ROOM[04].CONTAGEM_PLAYER) or 0
8 local E = Game.getStorageValue(_PVP_ROOM[05].CONTAGEM_PLAYER) or 0
9 local F = Game.getStorageValue(_PVP_ROOM[06].CONTAGEM_PLAYER) or 0
10
11 if step == 00 then
12 player:sendCancelMessage("@LoadPVP 01 " ..A.. " " ..B.. " " ..C.. " " ..D.. " " ..E.. " " ..F)
13 return false
14 end
15 if step == 01 then
16 if EnableLoad then
17 local players = Game.getPlayers()
18 for _, targetPlayer in ipairs(players) do
19 targetPlayer:sendCancelMessage("@LoadPVP 01 " ..A.. " " ..B.. " " ..C.. " " ..D.. " " ..E.. " " ..F)
20 end
21 else
22 onLoadPVPRoom(player, 00)
23 end
24 return false
25 end
26 end
27 return false
28end
29function onStepIn(creature, item, position, fromPosition)
30 if creature:isPlayer() then
31 local id = 03
32 if creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == 01 then
33 creature:teleportTo({x=4093, y=1167, z=04})
34 creature:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
35 return true
36 end
37
38 Game.setStorageValue(_PVP_ROOM[id].CONTAGEM_PLAYER, nil)
39 local players = Game.getPlayers()
40 for _, cid in ipairs(players) do
41 if cid:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID) == id then
42 cid:setTown(Town(01))
43 cid:removeCondition(CONDITION_OUTFIT)
44 cid:sendCancelMessage("@NoTeleport 00")
45 cid:sendCancelMessage("@CronOff")
46 cid:setStorageValue(_PVP_ROOM[00].PVP_SALA_ID, nil)
47 cid:teleportTo({x=3999, y=991, z=7})
48 cid:getPosition():sendMagicEffect(11)
49 onLoadPVPRoom(cid, 00)
50
51 if cid:getStorageValue(_PVP_ROOM[00].TIME_ID) == 02 then
52 print("[" ..cid:getName().. "] Venceu.")
53 local reward = _PVP_ROOM[id].CRONOMETRO
54 reward = reward * 02
55 if Game.getStorageValue(_GLOBAL_RANDOM.DAILY_EVENTS.STORAGE) == 05 then
56 reward = reward + reward
57 end
58 if cid:getStorageValue(_SYSTEM.PVP_POINTS) < 00 then
59 cid:setStorageValue(_SYSTEM.PVP_POINTS, reward)
60 else
61 cid:setStorageValue(_SYSTEM.PVP_POINTS, (cid:getStorageValue(_SYSTEM.PVP_POINTS) + reward))
62 end
63
64 cid:sendCancelMessage("@LootMSG 3219 05 00 " ..reward)
65 doBackpack(cid, 11)
66 end
67 cid:setStorageValue(_PVP_ROOM[00].TIME_ID, nil)
68 end
69 end
70
71 stopEvent(_PVP_ROOM[id].ADDEVENT_TIMER)
72 _PVP_ROOM[id].ADDEVENT_TIMER = nil
73 end
74 return true
75end
76