Hey guys!
I've got a arena system from this forum, and I want one modification. Here are scripts.
Area_Death (creaturescripts):
and action:
Everything works great, but I need a modification. I've got in map editor PVP tiles and now i want to make that after player dead on arena, he will be teleported to another place, not to the temple.
Can you help me?
Thanks!
I've got a arena system from this forum, and I want one modification. Here are scripts.
Area_Death (creaturescripts):
LUA:
local config = {
reward_position = {x = 472, y = 12, z = 7}, -- Teleport location when Arena is Cleared.
global_storage = 696969, -- any free storage
top_left_corner = {x = 459, y = 15, z = 7}, -- top left corner of arena
bottom_right_corner = {x = 470, y = 18, z = 7}, -- bottom right corner of arena
}
local monsters = { -- All monsters in arena (including joke monster)
[1] = "Fighter",
[2] = "Monster1",
[3] = "Monster2",
[4] = "Monster3"
}
local monster_config_wave_one = { -- wave 1
[1] = {position = {x = 468, y = 16, z = 7}, name = "Monster1"}
}
local monster_config_wave_two = { -- wave 2
[1] = {position = {x = 468, y = 16, z = 7}, name = "Monster2"}
}
local monster_config_wave_three = { -- wave 3
[1] = {position = {x = 468, y = 16, z = 7}, name = "Monster3"}
}
function onKill(cid, target, damage, flags)
-- check if target is player
if isPlayer(target) then
return true
end
-- check if target is on list of monsters in arena
local name = getCreatureName(target):lower()
count = 0
for i = 1, #monsters do
if name == monsters[i]:lower() then
count = count + 1
end
end
if count == 0 then -- if target is not on list
return true
end
-- check if target is in area and add to global storage if it is
for t = config.top_left_corner.x, config.bottom_right_corner.x do
for f = config.top_left_corner.y, config.bottom_right_corner.y do
pos = {x = t, y = f, z = 7}
pid = getTopCreature(pos).uid
if pid == target then
setGlobalStorageValue(global_storage, getGlobalStorageValue(global_storage) + 1)
end
end
end
-- Start checks for waves of arena
-- Wave 1
if getGlobalStorageValue(global_storage) == 1 then
for i = 1, #monster_config_wave_one do
doCreateMonster(monster_config_wave_one[i].name, monster_config_wave_one[i].position)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wave 1.")
end
-- Wave 2
if getGlobalStorageValue(global_storage) == 2 then
for i = 1, #monster_config_wave_two do
doCreateMonster(monster_config_wave_two[i].name, monster_config_wave_two[i].position)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wave 2.")
end
-- Wave 3
if getGlobalStorageValue(global_storage) == 3 then
for i = 1, #monster_config_wave_three do
doCreateMonster(monster_config_wave_three[i].name, monster_config_wave_three[i].position)
end
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wave 3. Final Wave.")
end
-- When final wave ends
-- Teleport player
if getGlobalStorageValue(global_storage) == 4 then
doTeleportThing(cid, config.reward_position)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Congratulations! Go collect your reward.")
setGlobalStorageValue(global_storage, 0)
end
return true
end
and action:
LUA:
---------------------------------- Start Config -------------------------------
local config = {
arena_position = {x = 462, y = 17, z = 7}, -- Player Arena Position
failed_position = {x = 473, y = 10, z = 7}, -- Player took too long position
lever_reset_time = 10, -- in minutes (how long until another player can kick them out)
global_storage = 696969, -- any free storage
top_left_corner = {x = 459, y = 15, z = 7}, -- top left corner of arena
bottom_right_corner = {x = 470, y = 18, z = 7}, -- bottom right corner of arena
joke_monster = "Fighter" -- They will kill this monster to start the waves
}
----------------------------------- End Config --------------------------------
local function reset(p)
doTransformItem(getTileItemById(p, 1946).uid, 1945)
end
local function teleport(cid)
doTeleportThing(cid, config.arena_position)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "---------------------------------------")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Kill the training mate to start Tournament.")
doCreateMonster(config.joke_monster, config.arena_position)
end
function onUse(cid, item, fromPosition, itemEx, toPosition)
-- check if lever is currently used
if item.itemid == 1946 then
return doPlayerSendTextMessage(cid, 22, "Wait for switch to reset. It resets automatically every ".. config.lever_reset_time .." minutes.")
end
-- check for players/monsters in arena, and kick them out/remove them
for t = config.top_left_corner.x, config.bottom_right_corner.x do
for f = config.top_left_corner.y, config.bottom_right_corner.y do
pos = {x = t, y = f, z = 7}
pid = getTopCreature(pos).uid
if isPlayer(pid) then
doTeleportThing(pid, config.failed_position)
doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, "Another player started the arena. You have been removed. Better luck next time!")
end
if isMonster(pid) then
doRemoveCreature(pid)
end
end
end
-- tell player what to do
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Lever resets automatically every ".. config.lever_reset_time .." minutes.")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Once the lever resets another player can start the arena.")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "If your still inside when another player starts, you will be removed from the arena and unable to continue.")
-- reset global storage
setGlobalStorageValue(global_storage, 0)
-- teleport player to arena, send start message, create start/joke monster
addEvent(teleport, 5000, cid)
-- transform lever, and add reset
doTransformItem(item.uid, item.itemid + 1)
addEvent(reset, ((config.lever_reset_time * 60 * 1000) + 5000), toPosition)
return true
end
Everything works great, but I need a modification. I've got in map editor PVP tiles and now i want to make that after player dead on arena, he will be teleported to another place, not to the temple.
Can you help me?
Thanks!