[ITEMDEF i_pvp_stone]
NAME=PVP Stone
ID=i_gravestone_18
TYPE=t_normal

ON=@Create
morep=<src.p>
color=0ad
attr=attr_static

ON=@Click
IF (<More1>==2)
SAY @0ad,,2 1072516,PVP,<EVAL <TIMER>>
return 1
ENDIF

ON=@Dclick
IF (<more2>==2)
SAY @036,,2 501752
return 1
ENDIF
IF (<more1>==2)
src.sysmessageloc 04ac,3000278,The arena
return 1
ENDIF
IF (<more1>==1) && (<src.findid.i_pvp_time>)
src.clear_pvp_tags
src.spelleffect s_dispel,1000
src.flags &= ~statf_incognito
src.flags &= ~statf_criminal
src.flags &= ~statf_invisible
src.findid.i_pvp_time.remove
more1=0
more2=0
timer -1
tag.participante1=
color=0ad
src.go Help Room
SAY @04ac,,2 1062613,<SRC.NAME> gives up!
return 1
ENDIF
IF (<more1>==1)
sDIALOG d_pvp 2
return 1
ENDIF
IF !(<more1>)
sDIALOG d_pvp 1
return 1
ENDIF

ON=@TIMER
FOR 2
	IF (<TAG0.PARTICIPANTE<dLOCAL._FOR>>)
	REF1=<TAG0.PARTICIPANTE<dLOCAL._FOR>>
	REF1.memoryfindtype.memory_harmedby.remove
	REF1.memoryfindtype.memory_iaggressor.remove
	REF1.memoryfindtype.memory_fight.remove
	REF1.memoryfindtype.memory_sawcrime.remove
	REF1.memoryfindtype.memory_aggreived.remove
	REF1.memoryfindtype.memory_war_targ.remove
	REF1.hits=<REF1.maxhits>
	REF1.mana=<REF1.maxmana>
	REF1.stam=<REF1.maxstam>
	REF1.spelleffect s_dispel,1000
	REF1.flags &= ~statf_criminal
	REF1.flags &= ~statf_incognito
	REF1.flags &= ~statf_war
	REF1.flags &= ~statf_invisible
	REF1.fame=<REF1.tag0.pvp.fame>
	REF1.karma=<REF1.tag0.pvp.karma>
	REF1.kills=<REF1.tag0.pvp.kills>
	REF1.deaths=<REF1.tag0.pvp.deaths>
	REF1.clear_pvp_tags
	REF1.go Help Room
	REF1.findid.i_pvp_logout.remove
	REF1.flags &= ~statf_criminal
	REF1.sysmessageloc 0ad,1072515,PVP time
	REF1.findid.i_pvp_time.remove
	ENDIF
try tag.participante<dLOCAL._FOR>
more2=0
color=0ad
more1=0
ENDFOR
timer=-1
return 1

[DIALOG d_pvp]
200,100
src.closealldialogs
PAGE 1
resizepic 20 20 3600 300 130
checkertrans 20 20 300 130
tilepic 160 70 9684
dtext 130 40 39 PVP System
button 40 70 2117 2118 1 0 1
dtext 60 67 1152 With loot
button 40 100 2117 2118 1 0 2
dtext 60 97 1152 Without loot

PAGE 2
resizepic 20 20 3600 270 190
checkertrans 20 20 270 190
tilepic 130 140 9607
dtext 40 40 88 <uid.<tag0.participante1>.name> is waiting an oponent.
dtext 40 60 88 For a PVP <QVAL <more2> ? with looting : without looting>.
dtext 80 90 39 Accept?
button 50 130 2311 2312 1 0 3
button 200 130 243 241 1 0 0

[DIALOG d_pvp BUTTON]
ON=1
IF (<more1>)
src.sysmessage @036,3,1 There is already someone in the arena.
return 1
ENDIF
IF (<distance> > 5)
src.sysmessageloc 036,500295
return 1
ENDIF
IF (<src.GOLD> < 4000)
src.sysmessage @,3,1 You don't have enough gold to pay the fee.
RETURN 1
ENDIF
src.gold -= 4000
src.events +e_pvp
more1 ++
tag.participante1=<src>
serv.newitem=i_pvp_time
src.equip <new>
new.link=<uid>
timer <eval 60*3>
color=036
say @04ac,3,1 <src.name> enters the arena!
src.tag.pvp.karma=<src.karma>
src.tag.pvp.deaths=<src.deaths>
src.tag.pvp.kills=<src.kills>
src.tag.pvp.fame=<src.fame>
src.spelleffect s_dispel,1000
src.flags |= statf_incognito|statf_criminal
src.removefromview
src.moveto <morep>
src.update
src.effect 3,i_fx_smoke,16,16
more2=1

ON=2
IF (<more1>)
src.sysmessage @036,3,1 There is already someone in the arena.
return 1
ENDIF
IF (<distance> > 5)
src.sysmessageloc 036,500295
return 1
ENDIF
IF (<src.GOLD> < 4000)
src.sysmessage @,3,1 You don't have enough gold to pay the fee.
RETURN 1
ENDIF
src.gold -= 4000
src.events +e_pvp
more1 ++
tag.participante1=<src>
serv.newitem=i_pvp_time
src.equip <new>
new.link=<uid>
timer <eval 60*3>
color=036
say @04ac,3,1 <src.name> enters the arena!
src.tag.pvp.karma=<src.karma>
src.tag.pvp.deaths=<src.deaths>
src.tag.pvp.kills=<src.kills>
src.tag.pvp.fame=<src.fame>
src.spelleffect s_dispel,1000
src.flags |= statf_incognito|statf_criminal
src.removefromview
src.moveto <morep>
src.update
src.effect 3,i_fx_smoke,16,16
more2=0

ON=3
IF !(<more1>)
src.sysmessage @036,3,1 There are no oponents to fight with you.
return 1
ENDIF
IF (<more1>==2)
src.sysmessageloc 04ac,3000278,The arena
return 1
ENDIF
IF (<distance> > 5)
src.sysmessageloc 036,500295
return 1
ENDIF
IF (<src.GOLD> < 4000)
src.sysmessage @,3,1 You don't have enough gold to pay the fee.
RETURN 1
ENDIF
src.gold -= 4000
src.events +e_pvp
more1 ++
tag.participante2=<src>
serv.newitem=i_pvp_time
src.equip <new>
new.link=<uid>
timer <eval 60*8>
color=36
say @04ac,3,1 <src.name> enters the arena!
src.tag.pvp.karma=<src.karma>
src.tag.pvp.deaths=<src.deaths>
src.tag.pvp.kills=<src.kills>
src.tag.pvp.fame=<src.fame>
src.spelleffect s_dispel,1000
src.flags |= statf_incognito|statf_criminal
src.removefromview
src.moveto <morep>
src.update
src.effect 3,i_fx_smoke,16,16
SAY @0ad,,2 1072516,PVP,360

///////////////////////////////

[EVENTS e_pvp]
ON=@Click
IF !(<isonline>)
message @07a3 [Offline]
ENDIF

ON=@LogOut
flags |= statf_invisible
serv.newitem=i_pvp_logout
new.link=<findid.i_pvp_time.link>
equip <new>
new.timer=60*3
new.link.say @04ac,3,1 <name> logged out, he has 3 minutes to come back, or he'll lose.

ON=@LogIn
flags &= ~statf_invisible
findid.i_pvp_logout.remove

ON=@SkillStart
IF (<ACTION>==SKILL_HIDING) || (<ACTION>==SKILL_STEALTH)
src.sysmessageloc 036,1005213
action -1
return 1
endif

ON=@SpellCast
IF (<ARGN1>==s_summon_creature>) || (<ARGN1>==s_summon_daemon>) || (<ARGN1>==s_blade_spirits>) || (<ARGN1>==s_summon_elem_air>) || (<ARGN1>==s_summon_elem_earth>) || (<ARGN1>==s_summon_elem_fire>) || (<ARGN1>==s_summon_elem_water>) || (<ARGN1>==s_energy_vortex>) || (<ARGN1>==s_invisibility>)
action=-1
src.sysmessageloc 036,1005213
return 1
endif

ON=@Death
ref1=<attacker.last>
local.actname=<ref1.name>
memoryfindtype.memory_harmedby.remove
memoryfindtype.memory_iaggressor.remove
memoryfindtype.memory_fight.remove
memoryfindtype.memory_sawcrime.remove
memoryfindtype.memory_aggreived.remove
memoryfindtype.memory_war_targ.remove
ref1.memoryfindtype.memory_harmedby.remove
ref1.memoryfindtype.memory_iaggressor.remove
ref1.memoryfindtype.memory_fight.remove
ref1.memoryfindtype.memory_sawcrime.remove
ref1.memoryfindtype.memory_aggreived.remove
ref1.memoryfindtype.memory_war_targ.remove
sysmessage @036 You lose.
ref1.sysmessage @036 You win.
ref2=<FINDID.I_PVP_TIME.LINK>
ref2.SAY @04ac,3,1 <local.actname> wins the PVP!
SERV.b @946,3,1 <NAME> loses a pvp to <local.actname>
IF !(<ref2.MORE2>)
ref2.TIMER
action -1
return 1
ENDIF

ON=@DeathCorpse
REF1=<FINDID.I_PVP_TIME.LINK>
IF (<REF1.MORE2>==1)
	FOR 2
		IF (<REF1.TAG0.PARTICIPANTE<dLOCAL._FOR>> == <UID>)
		try REF1.tag.participante<dLOCAL._FOR>=
		ENDIF
	ENDFOR
REF1.timer 30
SPELLEFFECT s_dispel,1000
go Help Room
flags &= ~statf_incognito
flags &= ~statf_war
flags &= ~statf_invisible
findid.i_pvp_time.remove
fame=<tag0.pvp.fame>
karma=<tag0.pvp.karma>
kills=<tag0.pvp.kills>
deaths=<tag0.pvp.deaths>
clear_pvp_tags
flags &= ~statf_criminal
hits=<maxhits>
mana=<maxmana>
stam=<maxstam>
resurrect
REF1.more2=2
ARGO.timer=30
ARGO.say @946,3,1 You have 30 seconds to loot.
update
ENDIF

ON=@ItemDclick
IF (<ACT.TYPE>==t_figurine) || (<ACT.TYPE>==t_shrink_fix)
RETURN 1
ENDIF

ON=@Dismount
RETURN 1

///////////////////////////

[ITEMDEF i_pvp_time]
NAME=PVP Time
ID=i_memory
TYPE=t_eq_script
LAYER=layer_special

ON=@Create
attr=attr_invis|attr_move_never

////////////////////////////

[FUNCTION clear_pvp_tags]
tag.pvp.karma=
tag.pvp.fame=
tag.pvp.kills=
tag.pvp.deaths=
events -e_pvp

///////////////////////////

[itemdef i_pvp_logout]
NAME=LogOut Timer
ID=i_memory
TYPE=t_eq_script
LAYER=layer_special

ON=@Create
attr=attr_invis|attr_decay

ON=@Timer
link.SAY @0ad,,2 1072515,PVP time
link.timer
remove
return 1

////////////////////PVP Arena Select//////////////////////

[ITEMDEF i_pvp_arena_select]
ID=i_gravestone_7
NAME=PVP - Arenas
TYPE=t_normal

ON=@Create
attr=attr_static

ON=@Dclick
SDIALOG d_pvp_arenas
RETURN 1

[DIALOG d_pvp_arenas]
200,100
src.closealldialogs
PAGE 0
resizepic 20 20 3600 250 300
checkertrans 20 20 250 300
dtext 100 35 1152 PVP - Arenas
FOR 10
button 40 <EVAL 50+(<LOCAL._FOR>*22)> 093A 0939 1 0 <dLOCAL._FOR>
dtext 55 <EVAL 45+(<LOCAL._FOR>*22)> 36 Arena <dLOCAL._FOR> (<EVAL <UID.<TAG0.ARENA<dLOCAL._FOR>>.MORE1>> / 2)
ENDFOR

[DIALOG d_pvp_arenas BUTTON]
ON=1 10
IF (<DISTANCE> <= 4)
SRC.GO ARENA <ARGN> - Espera
SRC.MOVE 100
SRC.MOVE -100
REGION.LIGHT 00
ENDIF

[EOF]