CreatureEvent [0.3.5pl1] PvP Arena

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
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
 

frankfarmer

who'r ninja now
Joined
Aug 5, 2008
Messages
1,472
Best answers
0
Reaction score
30
Location
swe?
Hey Shawak! Can't you make the thread a bit nicer with a screenshot involved?:)

Thanks for sharing!
 
OP
Shawak

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
A screenshot won't show what happens ;p
 

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Best answers
2
Reaction score
109
I guess this is pretty good, but the code can be minimized for an arena?
 

HeberPcL

[PowerOT.com.br]
Joined
Aug 21, 2007
Messages
1,280
Best answers
0
Reaction score
38
Location
Brazil
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:
OP
Shawak

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
@Up:
You just have to add "doSetItemSpecialDescription" in your functions.
 

HeberPcL

[PowerOT.com.br]
Joined
Aug 21, 2007
Messages
1,280
Best answers
0
Reaction score
38
Location
Brazil
Shawak,
can send me function doSetItemSpecialDescription ?
 
OP
Shawak

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
Try this one:
Lua:
function doSetItemSpecialDescription(uid, description)
     return doItemSetAttribute(uid, "specialdescription", description)
end
 
OP
Shawak

Shawak

Intermediate OT User
Joined
Sep 11, 2008
Messages
1,976
Best answers
2
Reaction score
101
Location
Germany
Because you are using TFS0.3.6....
Did you added the function in /lib ?
 

Doggynub

LUA / C++
Joined
Sep 28, 2008
Messages
2,541
Best answers
0
Reaction score
181
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
 

Hevar

Click clack bam bam!
Joined
May 29, 2009
Messages
558
Best answers
0
Reaction score
17
Location
Sweden
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
 
Top