• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Action PVP Arena lever!

slaw

Software Developer
Joined
Aug 27, 2007
Messages
3,657
Solutions
125
Reaction score
1,103
Location
Germany
GitHub
slawkens
arena_1.PNG

arena_2.PNG


PVP Arena lever.

You can add as much as you want.

It not must be arena, it can be anything, quest etc!

Its simple! Just add line with uid to actions.xml, and edit 'arenas'.

data/actions/scripts/arenalever.lua
Lua:
local arenas = {
	[7667] = {
		fromPos ={
			{x = 2240, y = 1287, z = 8},	--player 1 start pos
			{x = 2240, y = 1289, z = 8}		--player 2 start pos
											--you can add how much you want, there are no limits
		},
		toPos = {
			{x = 2243, y = 1288, z = 9},	--player 1 teleport position
			{x = 2250, y = 1288, z = 9}		--player 2 teleport position
											--you can add how much you want, there are no limits
		}
	}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(item.itemid == 1946) then
		doTransformItem(item.uid, 1945)
		return TRUE
	end

	local arena = arenas[item.uid]
	if(not arena) then
		return FALSE
	end

	local players = {}
	for _, pos in pairs(arena.fromPos) do
		pos.stackpos = STACKPOS_TOP_CREATURE
		local tmp = getThingfromPos(pos).uid
		if(tmp > 0 and isCreature(tmp) == TRUE) then
			table.insert(players, tmp)
		end
	end

	if(table.maxn(players) < table.maxn(arena.fromPos)) then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need more creatures for duel.")
		return TRUE
	end

	for i, pid in pairs(players) do
		doSendMagicEffect(arena.fromPos[i], CONST_ME_POFF)
		doTeleportThing(pid, arena.toPos[i])
		doSendMagicEffect(arena.toPos[i], CONST_ME_TELEPORT)
		doPlayerSendTextMessage(pid, MESSAGE_INFO_DESCR, "FIGHT!")
	end

	return TRUE
end

actions.xml
Code:
<action uniqueid="7667" script="arenalever.lua" />
 
Haha noooouuuu xd I didn't saw that. but ty!

Btw. Sorry for high image size.. but i musted save it as .PNG, because my photoshop died, and I used paint ;@
 
It was already somewhere released, but here you have:
Code:
local arenas =
{
	{ --Arena 1 - enigma city
		fromPosition = {x = 2241, y = 1285, z = 9},
		toPosition = {x = 2252, y = 1291, z = 9},
		exitPosition = {x = 2239, y = 1288, z = 8}
	},
--[[
	{ --Arenatest - enigma city
		fromPosition = {x = 2197, y = 1304, z = 7},
		toPosition = {x = 2202, y = 1307, z = 7},
		exitPosition = {x = 2200, y = 1298, z = 7}
	},]]--
}

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
	local tmp = getCreaturePosition(cid)
	for _, arena in ipairs(arenas) do
		if(isInRange(tmp, arena.fromPosition, arena.toPosition) == TRUE) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PVPArena] You have been defeated by " .. getCreatureName(lastHitKiller) .. ".")
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
			doRemoveCondition(cid, CONDITION_INFIGHT)
			--doPlayerSetPzLocked(cid, FALSE)
			doTeleportThing(cid, arena.exitPosition)
			doSendMagicEffect(tmp, CONST_ME_POFF)
			doSendMagicEffect(arena.exitPosition, CONST_ME_TELEPORT)
			return FALSE
		end
	end

	return TRUE
end
 
Thanks Slawkens, Very happy to have you on the TFS team.
Also nice to see nice scripts coming from you. Thanks
 
Where would I add this and Is there any other Line to add in XML
document?
Thanks



It was already somewhere released, but here you have:
Code:
local arenas =
{
	{ --Arena 1 - enigma city
		fromPosition = {x = 2241, y = 1285, z = 9},
		toPosition = {x = 2252, y = 1291, z = 9},
		exitPosition = {x = 2239, y = 1288, z = 8}
	},
--[[
	{ --Arenatest - enigma city
		fromPosition = {x = 2197, y = 1304, z = 7},
		toPosition = {x = 2202, y = 1307, z = 7},
		exitPosition = {x = 2200, y = 1298, z = 7}
	},]]--
}

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
	local tmp = getCreaturePosition(cid)
	for _, arena in ipairs(arenas) do
		if(isInRange(tmp, arena.fromPosition, arena.toPosition) == TRUE) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PVPArena] You have been defeated by " .. getCreatureName(lastHitKiller) .. ".")
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
			doRemoveCondition(cid, CONDITION_INFIGHT)
			--doPlayerSetPzLocked(cid, FALSE)
			doTeleportThing(cid, arena.exitPosition)
			doSendMagicEffect(tmp, CONST_ME_POFF)
			doSendMagicEffect(arena.exitPosition, CONST_ME_TELEPORT)
			return FALSE
		end
	end

	return TRUE
end
 
How i can use for example

I step on one of those floors

Then it automaticly teleports me to a pvp zone

Srry for my english
 
I have a little problem..
I made arenalever.lua in actions/scripts and added to actions.xml:

Code:
        <action uniqueid="7667" script="arenalever.lua" />

Then I made arenas.lua in creaturescripts/scripts and added to creaturescripts.xml :

Code:
        <event type="preparedeath" name="arenas" event="script" value="arenas.lua"/>

I changed directions for my map, made switch on the map (1946) and it doesn't work.

Help pls!

PS. I'm Polish..
 
slawkenz. i'm getting this error.

Code:
[16:25:51.361] [Error - Luainterface::loadfile] data/actions/arena.lua:13: unexpected symbol near '}'


and heres mine atm.
Code:
local arenas =
    { --Arena 1 - enigma city
        fromPosition = {x = 1046, y = 1002, z = 8},
        toPosition = {x = 1046, y = 1006, z = 9},
        exitPosition = {x = 1046, y = 999, z = 8}
    },
--[[
    { --Arenatest - enigma city
        fromPosition = {x = 1048, y = 1002, z = 8},
        toPosition = {x = 1049, y = 1006, z = 9},
        exitPosition = {x = 1048, y = 999, z = 8}
    },]]--
}

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    local tmp = getCreaturePosition(cid)
    for _, arena in ipairs(arenas) do
        if(isInRange(tmp, arena.fromPosition, arena.toPosition) == TRUE) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PVPArena] You have been defeated by " .. getCreatureName(lastHitKiller) .. ".")
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
            doRemoveCondition(cid, CONDITION_INFIGHT)
            --doPlayerSetPzLocked(cid, FALSE)
            doTeleportThing(cid, arena.exitPosition)
            doSendMagicEffect(tmp, CONST_ME_POFF)
            doSendMagicEffect(arena.exitPosition, CONST_ME_TELEPORT)
            return FALSE
        end
    end

    return TRUE
end
 
slawkenz. i'm getting this error.

Code:
[16:25:51.361] [Error - Luainterface::loadfile] data/actions/arena.lua:13: unexpected symbol near '}'


and heres mine atm.
Code:
local arenas =
    { --Arena 1 - enigma city
        fromPosition = {x = 1046, y = 1002, z = 8},
        toPosition = {x = 1046, y = 1006, z = 9},
        exitPosition = {x = 1046, y = 999, z = 8}
    },
--[[
    { --Arenatest - enigma city
        fromPosition = {x = 1048, y = 1002, z = 8},
        toPosition = {x = 1049, y = 1006, z = 9},
        exitPosition = {x = 1048, y = 999, z = 8}
    },]]--
}

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    local tmp = getCreaturePosition(cid)
    for _, arena in ipairs(arenas) do
        if(isInRange(tmp, arena.fromPosition, arena.toPosition) == TRUE) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PVPArena] You have been defeated by " .. getCreatureName(lastHitKiller) .. ".")
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE)
            doRemoveCondition(cid, CONDITION_INFIGHT)
            --doPlayerSetPzLocked(cid, FALSE)
            doTeleportThing(cid, arena.exitPosition)
            doSendMagicEffect(tmp, CONST_ME_POFF)
            doSendMagicEffect(arena.exitPosition, CONST_ME_TELEPORT)
            return FALSE
        end
    end

    return TRUE
end

You're missing one more "{" right after "local arenas =".

And there are actually 2 scripts:

1) action (posted in first post)
- for using lever + teleporting players

2) creatureevent (posted here)
- for teleporting back when someone is killed.

So, script you posted should go into creaturescripts folder, and in creaturescripts.xml you need to add:
Code:
<event type="prepareDeath" name="PVPArena" script="arena.lua">

and, in login.lua add:
registerCreatureEvent(cid, "PVPArena")
 
Back
Top