ralke
(҂ ͠❛ ෴ ͡❛)ᕤ
Hi again! I have this system for a PVP arena, made here
And I need to ask a little modification. Anyone can help me making that players from the same town, can't attack each other if they're inside this arena?, and return to their normal condition if they exit or "die" (dying is handled by event). Here's the script:
Regards!
TFS [1.X] Infinite PVP Arena
Hi! Here's a system made by @Itutorial all credits to him. I wanted to share this in case someone want to use it. This system is a request made in the following thread: Lua - Don't waste potions and runes on area (frompos topos)...
otland.net
And I need to ask a little modification. Anyone can help me making that players from the same town, can't attack each other if they're inside this arena?, and return to their normal condition if they exit or "die" (dying is handled by event). Here's the script:
Lua:
local config = {
-- TownID Pos enter arena pos exit arena
[1] = {
tileEnterPos = Position(1011, 968, 7), -- entrada kilika
tileExitPos = Position(187, 759, 9),
enterPos = Position(189, 761, 9),
exitPos = Position(1008, 971, 7)
},
[2] = {
tileEnterPos = Position(1239, 867, 7),
tileExitPos = Position(244, 727, 9),
enterPos = Position(246, 729, 9),
exitPos = Position(1241, 867, 7)
}
}
-- Globalevent used to teleport players out of arena when server shuts down --
local globaleventPvPArena = GlobalEvent("PvP_Arena_Global")
function globaleventPvPArena.onShutdown()
for _, player in pairs(Game.getPlayers()) do
if player and player:isPvPArenaPlayer() then
local town = config[player:getTown():getId()]
if town then
player:teleportTo(town.exitPos)
end
end
end
return true
end
globaleventPvPArena:register()
-- Prepare death. Handles players dying in arena. --
local creatureeventPvPArena = CreatureEvent("PvP_Arena_PrepareDeath")
function creatureeventPvPArena.onPrepareDeath(creature, killer)
if not creature:isPlayer() then return true end
if not creature:isPvPArenaPlayer() then return true end
local town = config[creature:getTown():getId()]
if not town then return true end
creature:say("Ahhh Ahhha ahhhh")
creature:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
db.query("UPDATE players SET arenaKills = arenaKills + 1 WHERE id = '" .. killer:getGuid() .. "';")
db.query("UPDATE players SET arenaDeaths = arenaDeaths + 1 WHERE id = '" .. creature:getGuid() .. "';")
creature:teleportTo(town.exitPos)
creature:addHealth(creature:getMaxHealth())
creature:addMana(creature:getMaxMana())
-- print("PVP") --
creature:setPvPArenaPlayer(false)
return false
end
creatureeventPvPArena:register()
-- Moveevent used to teleport players in and out of the arena --
local movementPvPArena = MoveEvent()
movementPvPArena:type("stepin")
function movementPvPArena.onStepIn(player, item, position, fromPosition)
if not player then return true end
local town = config[player:getTown():getId()]
if not town then
player:sendCancelMessage("You do not have a town set. Report to GM.")
player:teleportTo(fromPosition, true)
return true
end
if not player:isPvPArenaPlayer() then
if position ~= town.tileEnterPos then
player:sendCancelMessage("You do not have the correct town to enter here.")
player:teleportTo(fromPosition, true)
return true
end
player:teleportTo(town.enterPos)
town.enterPos:sendMagicEffect(CONST_ME_TELEPORT)
player:setPvPArenaPlayer(true)
else
if position ~= town.tileExitPos then
player:sendCancelMessage("You do not have the correct town to exit here.")
player:teleportTo(fromPosition, true)
return true
end
player:teleportTo(town.exitPos)
town.exitPos:sendMagicEffect(CONST_ME_TELEPORT)
player:setPvPArenaPlayer(false)
end
return true
end
movementPvPArena:aid(55235)
movementPvPArena:register()
-- New /c command --
local TalkSetMana = TalkAction("/c")
function TalkSetMana.onSay(player, words, param)
if not player:getGroup():getAccess() then
return false
end
if param == "" then
player:sendCancelMessage("Usage: /c name")
return false
end
local target = Player(param)
if not target then
player:sendCancelMessage("Player is not online or doesn't exist.")
return false
end
if target:isPvPArenaPlayer() then
target:setPvPArenaPlayer(false)
end
target:teleportTo(player:getPosition())
target:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
return false
end
TalkSetMana:separator(" ")
TalkSetMana:register()
local look = EventCallback
look.onLook = function(self, player, position, distance, description)
if not player:isPlayer() then
return description
end
local kills = player:getArenaKills()
local deaths = player:getArenaDeaths()
local adr
if deaths == 0 then
adr = kills
description = string.format("%s\nThis player killed %s and died %s times in arena. Their KDR is %s", description, kills, deaths, adr)
return description
end
adr = kills/deaths
description = string.format("%s\nThis player killed %s and died %s times in arena. Their KDR is %s", description, kills, deaths, ADR)
return description
end
look:register(5)
Regards!