• 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 [0.3.5pl1] PvP Arena

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,984
Solutions
2
Reaction score
119
Location
Germany
GitHub
Shawak
Credits:
100% by me :thumbup:

Script:

- data/creaturescripts/creaturescripts.xml
Code:
	<event type="statschange" name="Arena" event="script" value="pvp_arena.lua"/>
- data/creaturescripts/scripts/pvp_arena.lua
Lua:
--[[
	PvP Aerna v0.1
	by Shawak
]]--

local corpse_ids = {
	3065, -- famale 
	3058  -- male
}

---------------------------
local arena = {------------
---------------------------
-- Put your pvp areas here:

{main_pos = {x=1101, y=1043, z=7}, frompos = {x=1091, y=1037, z=7}, topos = {x=1111, y=1048, z=7}},


} -------------------------

function onStatsChange(cid, attacker, type, combat, value)
	if combat == COMBAT_HEALING then
		return true
	end

	if getCreatureHealth(cid) > value then
		return true
	end

	local arenaID = 0
	for i = 1, #arena do
		if isInRange(getCreaturePosition(cid), arena[i].frompos, arena[i].topos) then
			arenaID = i
			break
		end
		if i == #arena then
			return true
		end 
	end

	local corpse = doCreateItem((corpse_ids[getPlayerSex(cid)+1]), 1, getPlayerPosition(cid))
	doSetItemSpecialDescription(corpse, "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".\n[PvP Arena Kill]")

	doTeleportThing(cid, arena[arenaID].main_pos)
	doSendMagicEffect(getCreaturePosition(cid), 10)

	doRemoveConditions(cid)
	doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
	doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))

	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item").." in a pvp arena.")
	if isPlayer(attacker) then
		doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You killed "..getCreatureName(cid).." in a pvp arena.")
	end
	return false
end
- data/creaturescripts/scripts/login.lua add
Lua:
	registerCreatureEvent(cid, "Arena")

Regards,
Shawak
 
Hey Shawak! Can't you make the thread a bit nicer with a screenshot involved?:)

Thanks for sharing!
 
I guess this is pretty good, but the code can be minimized for an arena?
 
Error in 0.3.6 PL1
PHP:
[Error - CreatureScript Interface]
data/creaturescripts/scripts/PVP Arena.lua:onStatsChange
Description:
data/creaturescripts/scripts/PVP Arena.lua:42: attempt to call global 'd
oSetItemSpecialDescription' (a nil value)
stack traceback:
        data/creaturescripts/scripts/PVP Arena.lua:42: in function <data
/creaturescripts/scripts/PVP Arena.lua:21>


Error:
PHP:
doTeleportThing(cid, arena[arenaID].main_pos)
Change To:
PHP:
doTeleportThing(cid, arena.main_pos)
 
Last edited:
@Up:
You just have to add "doSetItemSpecialDescription" in your functions.
 
Try this one:
Lua:
function doSetItemSpecialDescription(uid, description)
     return doItemSetAttribute(uid, "specialdescription", description)
end
 
Because you are using TFS0.3.6....
Did you added the function in /lib ?
 
little small problem :)
what is to put in main position?
and from pos to pos
i know it is the pvp arena area but how to point to it with these three positions only
 
can i make so there is many player in Arena like LMS ( Last Man Standing)

--[[
PvP Aerna v0.1
by Shawak
]]--

local corpse_ids = {
3065, -- famale
3058 -- male
}

---------------------------
local arena = {------------
---------------------------
-- Put your pvp areas here:

{main_pos = {x=1101, y=1043, z=7}, frompos = {x=1091, y=1037, z=7}, topos = {x=1111, y=1048, z=7}},

{main_pos = {x=1101, y=1043, z=7}, frompos = {x=1091, y=1037, z=7}, topos = {x=1111, y=1048, z=7}},

{main_pos = {x=1101, y=1043, z=7}, frompos = {x=1091, y=1037, z=7}, topos = {x=1111, y=1048, z=7}},

{main_pos = {x=1101, y=1043, z=7}, frompos = {x=1091, y=1037, z=7}, topos = {x=1111, y=1048, z=7}},

{main_pos = {x=1101, y=1043, z=7}, frompos = {x=1091, y=1037, z=7}, topos = {x=1111, y=1048, z=7}},

} -------------------------

function onStatsChange(cid, attacker, type, combat, value)
if combat == COMBAT_HEALING then
return true
end

if getCreatureHealth(cid) > value then
return true
end

local arenaID = 0
for i = 1, #arena do
if isInRange(getCreaturePosition(cid), arena.frompos, arena.topos) then
arenaID = i
break
end
if i == #arena then
return true
end
end

local corpse = doCreateItem((corpse_ids[getPlayerSex(cid)+1]), 1, getPlayerPosition(cid))
doSetItemSpecialDescription(corpse, "You recognize "..getCreatureName(cid)..". He was killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item")..".\n[PvP Arena Kill]")

doTeleportThing(cid, arena[arenaID].main_pos)
doSendMagicEffect(getCreaturePosition(cid), 10)

doRemoveConditions(cid)
doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))

doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You got killed by "..(isMonster(attacker) and "a "..string.lower(getCreatureName(attacker)) or isCreature(attacker) and getCreatureName(attacker) or "a field item").." in a pvp arena.")
if isPlayer(attacker) then
doPlayerSendTextMessage(attacker, MESSAGE_STATUS_CONSOLE_BLUE, "You killed "..getCreatureName(cid).." in a pvp arena.")
end
return false
end
 
Back
Top