Action PVP Arena lever!

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany



PVP Arena lever.

You can add as much as you want.

It not must be arena, it can be anything, quest etc!

Its simple! Just add line with uid to actions.xml, and edit 'arenas'.

data/actions/scripts/arenalever.lua
Lua:
local arenas = {
	[7667] = {
		fromPos ={
			{x = 2240, y = 1287, z = 8},	--player 1 start pos
			{x = 2240, y = 1289, z = 8}		--player 2 start pos
											--you can add how much you want, there are no limits
		},
		toPos = {
			{x = 2243, y = 1288, z = 9},	--player 1 teleport position
			{x = 2250, y = 1288, 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 more creatures 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
actions.xml
Code:
<action uniqueid="7667" script="arenalever.lua" />
 

Sizaro

Intermediate OT User
Joined
Aug 20, 2007
Messages
5,061
Best answers
2
Reaction score
117
Location
Sweden
xD you released a script because I gave you rep HAHAHA I PWN
 
OP
slawkens

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
Haha noooouuuu xd I didn't saw that. but ty!

Btw. Sorry for high image size.. but i musted save it as .PNG, because my photoshop died, and I used paint ;@
 

averatec

Intermediate OT User
Joined
Jun 1, 2007
Messages
2,222
Best answers
2
Reaction score
145
Location
Poland
Simpler may be using the UID of tiles.
 

Ernii

New Member
Joined
Oct 19, 2008
Messages
169
Best answers
0
Reaction score
1
Could you also make a PvP arena script ?
 
OP
slawkens

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
It was already somewhere released, but here you have:
Code:
local arenas =
{
	{ --Arena 1 - enigma city
		fromPosition = {x = 2241, y = 1285, z = 9},
		toPosition = {x = 2252, y = 1291, z = 9},
		exitPosition = {x = 2239, y = 1288, 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
 

Don Daniello

/root
Staff member
Administrator
Joined
Apr 11, 2008
Messages
3,523
Best answers
15
Reaction score
931
Location
Proland
@slawkens what to add in creaturescripts.xml ?
 

Toast

New Member
Joined
Feb 28, 2008
Messages
150
Best answers
0
Reaction score
0
Thanks Slawkens, Very happy to have you on the TFS team.
Also nice to see nice scripts coming from you. Thanks
 

Toast

New Member
Joined
Feb 28, 2008
Messages
150
Best answers
0
Reaction score
0
Where would I add this and Is there any other Line to add in XML
document?
Thanks



It was already somewhere released, but here you have:
Code:
local arenas =
{
	{ --Arena 1 - enigma city
		fromPosition = {x = 2241, y = 1285, z = 9},
		toPosition = {x = 2252, y = 1291, z = 9},
		exitPosition = {x = 2239, y = 1288, 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
 

Kanakashy

Twifysoft Designer
Joined
Jan 14, 2009
Messages
1,546
Best answers
0
Reaction score
39
Location
Puerto Rico
How i can use for example

I step on one of those floors

Then it automaticly teleports me to a pvp zone

Srry for my english
 

Falkos

New Member
Joined
Nov 15, 2009
Messages
6
Best answers
0
Reaction score
0
Location
Poland ;]
I have a little problem..
I made arenalever.lua in actions/scripts and added to actions.xml:

Code:
        <action uniqueid="7667" script="arenalever.lua" />
Then I made arenas.lua in creaturescripts/scripts and added to creaturescripts.xml :

Code:
        <event type="preparedeath" name="arenas" event="script" value="arenas.lua"/>
I changed directions for my map, made switch on the map (1946) and it doesn't work.

Help pls!

PS. I'm Polish..
 

Zerak456

Gorlex.net NEW!
Joined
Aug 13, 2008
Messages
1,060
Best answers
0
Reaction score
6
Location
Germany
slawkenz. i'm getting this error.

Code:
[16:25:51.361] [Error - Luainterface::loadfile] data/actions/arena.lua:13: unexpected symbol near '}'

and heres mine atm.
Code:
local arenas =
    { --Arena 1 - enigma city
        fromPosition = {x = 1046, y = 1002, z = 8},
        toPosition = {x = 1046, y = 1006, z = 9},
        exitPosition = {x = 1046, y = 999, z = 8}
    },
--[[
    { --Arenatest - enigma city
        fromPosition = {x = 1048, y = 1002, z = 8},
        toPosition = {x = 1049, y = 1006, z = 9},
        exitPosition = {x = 1048, y = 999, z = 8}
    },]]--
}

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
 
OP
slawkens

slawkens

Developer
Premium User
Joined
Aug 27, 2007
Messages
2,873
Best answers
60
Reaction score
389
Location
Germany
slawkenz. i'm getting this error.

Code:
[16:25:51.361] [Error - Luainterface::loadfile] data/actions/arena.lua:13: unexpected symbol near '}'

and heres mine atm.
Code:
local arenas =
    { --Arena 1 - enigma city
        fromPosition = {x = 1046, y = 1002, z = 8},
        toPosition = {x = 1046, y = 1006, z = 9},
        exitPosition = {x = 1046, y = 999, z = 8}
    },
--[[
    { --Arenatest - enigma city
        fromPosition = {x = 1048, y = 1002, z = 8},
        toPosition = {x = 1049, y = 1006, z = 9},
        exitPosition = {x = 1048, y = 999, z = 8}
    },]]--
}

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
You're missing one more "{" right after "local arenas =".

And there are actually 2 scripts:

1) action (posted in first post)
- for using lever + teleporting players

2) creatureevent (posted here)
- for teleporting back when someone is killed.

So, script you posted should go into creaturescripts folder, and in creaturescripts.xml you need to add:
Code:
<event type="prepareDeath" name="PVPArena" script="arena.lua">
and, in login.lua add:
registerCreatureEvent(cid, "PVPArena")
 
Top