• 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!

Lua PVP Arena!

Sweddy

Well-Known Member
Joined
Feb 14, 2009
Messages
2,907
Reaction score
93
Location
Sweden
People Gets 0 HP but dont die Please Help Im Using Slawkens Pvparena script...

Im using TFS 0.3.6

arenalever.lua:
Lua:
local arenas = {
	[7001] = {
		fromPos ={
			{x = 1040, y = 989, z = 8}, --player 1 start pos
			{x = 1040, y = 987, z = 8} --player 2 start pos
											--you can add how much you want, there are no limits
		},
		toPos = {
			{x = 1048, y = 988, z = 9}, --player 1 teleport position
			{x = 1045, y = 988, 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 2 players 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

Arena.lua:
Lua:
local arenas =
{
	{ --Arena 1 - enigma city
		fromPosition = {x = 1041, y = 985, z = 9},
		toPosition = {x = 1052, y = 991, z = 9},
		exitPosition = {x = 1038, y = 988, 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

Actions.xml:

Code:
<action uniqueid="7001" event="script" value="other/arenalever.lua"/>

creaturescripts.xml:

Code:
<event type="prepareDeath" name="PVPArena" script="arena.lua"/>

login.lua:

Lua:
registerCreatureEvent(cid, "PVPArena")

constants.lua:

Lua:
Arenas_Positions = {
	{ startPosition = { x = 1041, y = 985, z = 9 }, endPosition = { x = 1052, y = 991, z = 9 }, position = { x = 1038, y = 988, z = 8 } },
}

Please Help!
 
Lua:
local arenas =
{
	{ --Arena 1 - enigma city
		fromPosition = {x = 1041, y = 985, z = 9},
		toPosition = {x = 1052, y = 991, z = 9},
		exitPosition = {x = 1038, y = 988, 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, deathList)
	local tmp = getCreaturePosition(cid)
	for _, arena in ipairs(arenas) do
		if isInRange(tmp, arena.fromPosition, arena.toPosition) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "[PVPArena] You have been defeated by " .. getCreatureName(deathList[1]) .. ".")
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
			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
If it still doesn't work, then it's probably because of the bug with onPrepareDeath in 0.3.6
 
i test the script, but have some bug..
when people in arena die, he goes to exitpos, but when he arrived, he die. :S

Can someone fix it?!
 
Back
Top