pvp.lua

main 90 lines · 3.2 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
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 PVP_ROOM = creature:getStorageValue(_PVP_ROOM[00].PVP_SALA_ID)
32 if PVP_ROOM > 00 then
33 if PVP_ROOM == 02 then
34 if creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == 01 then
35 creature:teleportTo(_PVP_ROOM[PVP_ROOM].ARENA_POS[05])
36 else
37 creature:teleportTo(_PVP_ROOM[PVP_ROOM].ARENA_POS[06])
38 end
39 elseif PVP_ROOM == 03 then
40 if creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == 01 then
41 creature:teleportTo(_PVP_ROOM[PVP_ROOM].ARENA_POS[01])
42 else
43 creature:teleportTo(_PVP_ROOM[PVP_ROOM].ARENA_POS[02])
44 end
45 elseif PVP_ROOM == 04 then
46 if Game.getStorageValue(_PVP_ROOM[00].BATTLE_PLAYER) ~= nil then
47 Game.setStorageValue(_PVP_ROOM[00].BATTLE_PLAYER, (Game.getStorageValue(_PVP_ROOM[00].BATTLE_PLAYER) - 01))
48 end
49 creature:setTown(Town(01))
50 creature:sendCancelMessage("@NoTeleport 00")
51 creature:sendCancelMessage("@CronOff")
52 creature:setStorageValue(_PVP_ROOM[00].PVP_SALA_ID, nil)
53 creature:setStorageValue(_PVP_ROOM[00].TIME_ID, nil)
54 creature:teleportTo({x=3999, y=991, z=7})
55 creature:getPosition():sendMagicEffect(11)
56 onLoadPVPRoom(creature, 00)
57 return true
58 else
59 creature:teleportTo(_PVP_ROOM[PVP_ROOM].ARENA_POS[math.random(01, #_PVP_ROOM[PVP_ROOM].ARENA_POS)])
60 end
61 creature:getPosition():sendMagicEffect(11)
62
63 if PVP_ROOM == 03 or PVP_ROOM == 06 then
64 return true
65 end
66 if creature:getStorageValue(_PVP_ROOM[00].TIME_ID) == 01 then
67 _PVP_ROOM[PVP_ROOM].PLACAR[01] = _PVP_ROOM[PVP_ROOM].PLACAR[01] + 01
68 else
69 _PVP_ROOM[PVP_ROOM].PLACAR[02] = _PVP_ROOM[PVP_ROOM].PLACAR[02] + 01
70 end
71 local from = _PVP_ROOM[PVP_ROOM].ARENA_POS[00].POS_X
72 local to = _PVP_ROOM[PVP_ROOM].ARENA_POS[00].POS_Y
73 for A = from.x, to.x do
74 for B = from.y, to.y do
75 for C = from.z, to.z do
76 local tile = Tile(A, B, C)
77 if tile then
78 local creature = tile:getTopCreature()
79 if creature and creature:isPlayer() then
80 creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[PLACAR] RED (" .._PVP_ROOM[PVP_ROOM].PLACAR[01].. ") | (" .._PVP_ROOM[PVP_ROOM].PLACAR[02].. ") BLUE")
81 end
82 end
83 end
84 end
85 end
86 end
87 end
88 return true
89end
90
Top