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

Arena script

Quickshot

Member
Joined
Nov 8, 2008
Messages
595
Reaction score
8
hi, is there anyone who can make me a arena script for my ot version 0.2 i need this badly i have the arena mapped out and all the scripts i have tried haven't worked
 
Here is one with 2 Arena pos

write in data/creaturescripts/scipts/arenawar.lua
PHP:
Arenas_Positions = {
{ 
startPosition = {x = 943,y=944,z=7}, 
endPosition = {x=979,y=954,z=7},
startPosition2 = {x= 949,y=955,z=7}, 
endPosition2 = {x= 979,y=960,z=7},  
position = {x=944,y=958,z=7}},
}

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
	local tmp = getCreaturePosition(cid)
	for _, arena in ipairs(Arenas_Positions) do
		if(isInArea(tmp, arena.startPosition, arena.endPosition) == TRUE) then
			if getPlayerSex(cid) == 1 then
				doCreateItem(6080, 1, tmp)
			elseif getPlayerSex(cid) == 2 then
				doCreateItem(6081, 1, tmp)
			end 
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have been defeated by " .. getCreatureName(lastHitKiller) .. ".")
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE)
			doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid), TRUE)
			doTeleportThing(cid, arena.position, TRUE)
			doSendMagicEffect(tmp, CONST_ME_POFF)
			doSendMagicEffect(arena.position,10)
			return FALSE
		elseif(isInArea(tmp, arena.startPosition2, arena.endPosition2) == TRUE) then
			if getPlayerSex(cid, 1) == TRUE then
				doCreateItem(tmp ,3128)
			elseif getPlayerSex(cid, 2) == TRUE then
				doCreateItem(tmp, 6081)
			end 
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have been defeated by " .. getCreatureName(lastHitKiller) .. ".")
			doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid), TRUE)
			doTeleportThing(cid, arena.position, TRUE)
			doSendMagicEffect(tmp, CONST_ME_POFF)
			doSendMagicEffect(arenaLeave, CONST_ME_TELEPORT)
			return FALSE
		end
	end
	return TRUE
end

then add in data/creaturescripts.xml
PHP:
	<event type="preparedeath" name="ArenaWar" script="arenawar.lua"/>

and in data/creaturescripts/scipts/login.lua
PHP:
	registerCreatureEvent(cid, "ArenaWar")
 
it doesnt work i get a error

[11/02/2009 15:30:35] Lua Script Error: [CreatureScript Interface]
[11/02/2009 15:30:35] data/creaturescripts/scripts/arenawar.lua:eek:nPrepareDeath

[11/02/2009 15:30:35] data/creaturescripts/scripts/arenawar.lua:13: attempt to call global 'isInArea' (a nil value)
[11/02/2009 15:30:35] stack traceback:
[11/02/2009 15:30:35] data/creaturescripts/scripts/arenawar.lua:13: in function <data/creaturescripts/scripts/arenawar.lua:10>
 
Add the following function at data/lib/ and open functions.lua any where add this:

PHP:
function isInArea(pos, fromPos, toPos)
--Function by Colandus
	if pos.x >= fromPos.x and pos.x <= toPos.x then
		if pos.y >= fromPos.y and pos.y <= toPos.y then
			if pos.z >= fromPos.z and pos.z <= toPos.z then
				return TRUE
			end
		end
	end
	return FALSE
end

If u use 0.2 open global.lua at data/
 
i added that to global.lua but i still get this error and it dont work

[11/02/2009 16:42:13] data/creaturescripts/scripts/arenawar.lua:eek:nPrepareDeath

[11/02/2009 16:42:13] data/creaturescripts/scripts/arenawar.lua:21: attempt to call global 'getCreatureMaxMana' (a nil value)
[11/02/2009 16:42:13] stack traceback:
[11/02/2009 16:42:13] data/creaturescripts/scripts/arenawar.lua:21: in function <data/creaturescripts/scripts/arenawar.lua:10>
 
the player dies :/ it gets the msg "You have been defeated by X" and then dies and gets tp to temple instead of the position outside the arena :S
 
Back
Top