• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Arena Battle Script

KylerXX

Active Member
Joined
Jun 24, 2010
Messages
439
Reaction score
30
I know that are existing more Arena Battle scripts, but my script its easy to configure and its works.

LUA:
function onUse(cid, item, frompos, itemEx, topos) -- script by xafterin
 -- functions--
 local coord = {
 x = {93, 97}, -- {pos X first corner, pos X of second corner of arena}
 y = {122, 124}, ---- {pos Y first corner, pos Y of second corner of arena}
 z = 7 -- Position Z
 }
function checkp()
 for areax = coord.x[1], coord.x[2] do
		for areay = coord.y[1], coord.y[2] do
			local area = {x = areax, y = areay, z = coord.z, stackpos = 253}
			if isPlayer(getThingFromPos(area).uid) then
		return true
		end
		end
	end
	return false
end
-- end functions --
 
local t = { -- configurayion
lvlReq = 1, -- required level
msg = "Go fight!", -- Message on enter to arena
player1 = {{x = 99, y = 122, z = 7, stackpos = 253}, {x = 95, y = 123, z = 7}}, -- {required position of player1 ,  pos to go}
player2 =  {{x = 99, y = 124, z = 7, stackpos = 253}, {x = 95, y = 124, z = 7}}, -- {required position of player2 ,  pos to go}
effects = {12} --efect
}
 local s = { -- dont touch
 p1 = getThingFromPos(t.player1[1]).uid,
 p2 = getThingFromPos(t.player2[1]).uid
}
			if not checkp() then
						if isPlayer(s.p1) and isPlayer(s.p2) then
									if getPlayerLevel(s.p1) >= t.lvlReq and getPlayerLevel(s.p2) >= t.lvlReq then
											doTeleportThing(s.p1, t.player1[2])
											doTeleportThing(s.p2, t.player2[2])
											doSendMagicEffect(t.player1[2], t.effects[1])
											doSendMagicEffect(t.player2[2], t.effects[1])
											doPlayerSendTextMessage(s.p1,18,t.msg)
											doPlayerSendTextMessage(s.p2,18,t.msg)
									else
											doPlayerSendCancel(cid, "Dont enough level, anyone needs required level ("..t.lvlReq..").")
									end		
						else
								doPlayerSendCancel(cid, "Need more players to enter arena.")
						end
			else
					doPlayerSendCancel(cid, "If anyone is in battle cant enter!")
			end
	return true
end

actions.xml
Code:
<action actionid="aid" event="script" value="arenabattle.lua"/>


Comments please:thumbup:
 
Last edited:
LUA:
if item.actionid == actID then
You don't need this.

Very nice script, I made almost the same code some time ago. Very useful.
 
LUA:
if item.actionid == actID then
You don't need this.

Very nice script, I made almost the same code some time ago. Very useful.

Thanks :)
I see why the
LUA:
if item.actionid == actID then
are useless, thanks, I remove :)

more comments hehe (:
 
bump aff..xd new thing:
on kill player the winner player get a reward and go teleport out of arena area:
LUA:
function onKill(cid, target)
 local coord = {
 x = {1000, 1000}, -- {pos X first corner, pos X of second corner of arena}
 y = {1000, 1000}, ---- {pos Y first corner, pos Y of second corner of arena}
 z = 7 -- Position Z
 }
function checkp()
 for areax = coord.x[1], coord.x[2] do
		for areay = coord.y[1], coord.y[2] do
			local area = {x = areax, y = areay, z = coord.z}
			if isPlayer(getThingFromPos(area).uid) then
		return true
		end
		end
	end
	return false
end
local salidapos = {x = x, y = y, z = z, stackpos = 253} --out position
local reward = 2160 -- id of rew
local cant = 100 -- quantity
if isPlayer(target) then
		if checkp() then
			doTeleportThing(cid, salidapos)
			doPlayerAddItem(cid, reward, cant)
		end
	end
return true
end

go creaturescripts.xml
XML:
<event type="kill" name="ArenaBattle" event="script" value="arenabattle.lua"/>

on login.lua under:
Code:
registerCreatureEvent(cid, "GuildMotd")

write:
Code:
registerCreatureEvent(cid, "ArenaBattle")
 
Last edited:
good. now its useful with that onkill creature script. good work.
 
How would i change this script so it works for more than one floor, i have a big war place with alot of stairs not just seventh floor...
 
in this lines:
LUA:
 local coord = {
 x = {93, 97}, -- {pos X first corner, pos X of second corner of arena}
 y = {122, 124}, ---- {pos Y first corner, pos Y of second corner of arena}
 z = 7
change the 7 for this: {7,tofloor}
now this :
LUA:
function checkp()
 for areax = coord.x[1], coord.x[2] do
		for areay = coord.y[1], coord.y[2] do
			local area = {x = areax, y = areay, z = coord.z, stackpos = 253}
			if isPlayer(getThingFromPos(area).uid) then
		return true
		end
		end
	end
	return false
end

change for this:
LUA:
function checkp()
 for areax = coord.x[1], coord.x[2] do
		for areay = coord.y[1], coord.y[2] do
			for areaz = coord.z[1], coord.z[2] do 
			local area = {x = areax, y = areay, z = areaz, stackpos = 253}
			if isPlayer(getThingFromPos(area).uid) then
		return true
		end
		end
	end
	end
	return false
end
 
Back
Top