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

CreatureEvent Arena PVP

tigerx2

New Member
Joined
Apr 5, 2010
Messages
104
Reaction score
2
here i am, first thread xD

Code:
local config = {
  script = arena pvp
  autor = tigerx2
  version tested = 8.60 / tfs 0.4
  infos = {
    here contains 2 scripts, of the lever to teleport the two players to arena and the creature script to heal hp/mana and teleport to the exit (who dies)
  }
  obs = don't lose any stats when die
}

WARNING: the arena needs to be covered by the pvp zone tool of your map editor (rme in this case).

Creaturescripts.xml
Code:
		<event type="preparedeath" name="Arena" event="script" value="arena.lua"/>

Creaturescripts/scripts
Code:
function onPrepareDeath(cid)

	-- CONFIG --
	local a = {
	l = {x=997,y=1019,z=7}, -- top left pos of arena
	r = {x=999,y=1021,z=7}, -- bot right pos of arena
	e = {x=995,y=1017,z=7} -- loser 'll be teleported in this pos when dies
	}
	-- CONFIG --
	local p = getCreaturePosition(cid) -- don't touch

	if isInRange(p, a.l, a.r)  then
		doSendMagicEffect(p, CONST_ME_STUN)
		doTeleportThing(cid, a.e)
		doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
		doCreatureAddMana(cid, getCreatureMaxMana(cid))
		return FALSE
	end
	return true
end

add in creaturescripts/scripts/login.lua
Code:
	registerCreatureEvent(cid, "Arena")

in actions/actions.xml
Code:
		<action actionid="4521" event="script" value="arena.lua"/>

now in actions/scripts
Code:
local config = {
	oldpos = {
		{x=1000,y=1021,z=7}, --pos where the player 1 needs to be to teleport the players
		{x=1000,y=1019,z=7}  --pos where the player 2 needs to be to teleport the players
	},
	newpos = {
		{x=997,y=1019,z=7},  --pos where the player 1 'll be teleported (in arena)
		{x=999,y=1021,z=7}   --pos where the player 2 'll be teleported (in arena)
	}
}

function onUse(cid, item, pos)
	if item.itemid == 1946 then
		doTransformItem(item.uid, 1945)
	else
		doTransformItem(item.uid, 1946)
	end
	local p = {}
	for i,v in ipairs(config.oldpos) do
		local pid = getTopCreature(v).uid
		if pid == 0 or not isPlayer(pid) then
			doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
			return true
		end
		table.insert(p, pid)
	end
	for i,v in ipairs(p) do
		doSendMagicEffect(config.oldpos[i], CONST_ME_POFF)
		doTeleportThing(v, config.newpos[i], false)
	end
	return true
end

Credits: tigerx2 & TFS (looked the loop of anihi)
Any bug, question or anything, please post here.
 
Code:
[06/07/2012 20:43:35] [Error - CreatureScript Interface] 
[06/07/2012 20:43:35] data/creaturescripts/scripts/arena.lua:onPrepareDeath
[06/07/2012 20:43:35] Description: 
[06/07/2012 20:43:35] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value)
[06/07/2012 20:43:35] stack traceback:
[06/07/2012 20:43:35] 	data/lib/032-position.lua:2: in function 'isInRange'
[06/07/2012 20:43:35] 	data/creaturescripts/scripts/arena.lua:12: in function <data/creaturescripts/scripts/arena.lua:1>
I use TFS 0.3.6 PL1 8.54.

##Edit:
Ok, i fixed this, but when looser is teleported, winner is still on arena, i want teleport him under arena, how i can do that?
~~zabka229 from Poland :)
 
Last edited:
Back
Top