• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

[0.3.6] Need PVP Arena!

wesoly136

Member
Joined
Jul 30, 2009
Messages
562
Reaction score
9
Hi!
I need working pvp arena for TFS 0.3.6 because all which I found don't work
The error in most scripts is
Code:
[05/07/2010 12:28:44] [Error - CreatureScript Interface] 
[05/07/2010 12:28:44] data/creaturescripts/scripts/arena.lua:onStatsChange
[05/07/2010 12:28:44] Description: 
[05/07/2010 12:28:44] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
[05/07/2010 12:28:44] stack traceback:
[05/07/2010 12:28:44] 	data/lib/032-position.lua:2: in function 'isInRange'
[05/07/2010 12:28:44] 	data/creaturescripts/scripts/arena.lua:33: in function <data/creaturescripts/scripts/arena.lua:22>
I tried also with storages(lever gives you storage, onpreparedeath remove it) and then it worked I was TPing to exit but I died there(it didnt heal me :/)
Thanks :)
 
storages, useless. 1 onpreparedeath is enough

LUA:
local upperleft = {x=1234,y=1234,z=1234} 
local lowerright = {x=1234,y=1234,z=1234}  

function onPrepareDeath(cid, deathlist)
    if isPlayer(cid) and isInRange(getThingPos(cid), upperleft, lowerright) then
        doRemoveConditions(cid)
        doCreatureAddHealth(cid,getCreatureMaxHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid)-getCreatureMana(cid))
        doTeleportThing(cid,getTownTemplePosition(getPlayerTown(cid)))
        return false    
    end
return true
end
 
For PVP arena in creaturescript you need to use somthing like this:
PHP:
function onStatsChange(cid, attacker, type, combat, value)
	if ARENA_CHECK then
		if getCreatureHealth(cid) < value then
			--What should happen to player if he dies?
			doTeleportThing(cid, EXIT??)
			return false
		end
	end	
	return true
end
 
why not this?:
Code:
local fromPos, toPos =
	{x = 100, y = 200, z = 7},
	{x = 100, y = 200, z = 7}

local teleportPos = {
	{x = 100, y = 200, z = 7},
	{x = 100, y = 200, z = 7}
}

local oldPosition = {
	{x = 100, y = 200, z = 7},
	{x = 100, y = 200, z = 7}
}

local function check()
	local list = {}
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			local creature = getTopCreature({x = x, y = y, z = fromPos.z}).uid
			if isPlayer(creature) then
				table.insert(list, creature)
			end
		end
	end
	for _, creature in ipairs(list) do
		if getCreatureHealth(creature) < getCreatureMaxHealth(creature) then
			doTeleportThing(creature, getTownTemplePosition(getPlayerTown(creature)), true)
			doCreatureAddHealth(creature, getCreatureMaxHealth(creature), false)
			doCreatureAddMana(creature, getCreatureMaxMana(creature), false)
		end
	end
	addEvent(function() if #list > 0 then return true end end, 100)
	return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local players = ""
	for x = fromPos.x, toPos.x do
		for y = fromPos.y, toPos.y do
			local player = getTopCreature({x= x, y = y, z = fromPos.z}).uid
			if player == 2 then
				players = players .. "" .. (players == "" and "" or " and ") .. "" .. getCreatureName(player)
			elseif player == 1 then
				players = getCreatureName(player)
			end
			if players ~= "" then
				return doPlayerSendTextMessage(cid, 27, "Wait for: " .. players .. " to finish.")
			end
		end
	end
	local list = {}
	for _, p in ipairs(oldPosition) do
		local k = getTopCreature(p).uid
		if k > 0 then
			table.insert(list, k)
		end
	end
	if #list == 1 then
		return doPlayerSendTextMessage(cid, 27, "You need one more player to enter.")
	elseif #list >= 2 then
		for i, k in ipairs(list) do
			doSendMagicEffect(getThingPos(k), CONST_ME_POFF)
			doTeleportThing(k, teleportPos[i], true)
			doSendMagicEffect(teleportPos[i], CONST_ME_TELEPORT)
		end
		check()
	end
	return true
end
 
Last edited:
Summ
The problem is this arena check, because isinRange doesnt work for my tfs :/
Fallon
This is a lever script? It doesnt work anyway :/

Someone said about function in map editor, I want to try it but I don't know what is it :(
 
fromPos = top left position (where they play)
toPos = buttom right position (where they play too)
teleportPos where they get tped
oldPosition their old position when they click on the switch
 
ok what about when u die? it should teleport & add mana/health also u can simply do this by making it Pvp area in the map editor
 
Back
Top