;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[@PKBattle]
{
#SAY
You want to enter the PK Battle?\
1, You must enter between {FCOLOR/10}20:10 and 20:30{FCOLOR/12}\
_____Maximum Entrants - {FCOLOR/10}50{FCOLOR/12}.\
2, It costs {FCOLOR/10}50{FCOLOR/12} Integral to join,\
_____winner takes all!\
3, You lose if you are killed, log or lag out.\
_____You cannot re-enter.\
4, You have to be level {FCOLOR/10}40{FCOLOR/12} to enter,\
_____you cannot use teleports or teleport spells.\
5, You will not incur PK Points, and you cannot lose any items\
6, You cannot use Roses, Respawn Scrolls, Rent Pets\
_____or wear a RevivalRing\
7, The NPC will check back after 10 Minutes,\
_____and then every 5 Minutes to see how many are left.\\
<[ Enter PK Battle ]/@gopkgzx>\
<[ Exit ]/@exit>\\
<[ GM Menu ]/@gmpkgg>\\\

[@gopkgzx]
#IF
!checklevel 40
#SAY
You need to be level 40\
<[ Exit ]/@exit>\\\
#ACT
break

#IF
checkitemw RedRose 1
or checkitem RedRose 1
or checkitemw CannibalFlower 1
or checkitem CannibalFlower 1
or checkitemw GreenRose 1
or checkitem GreenRose 1
or checkitemw Carnation 1
or checkitem Carnation 1
or checkitemw Bouquet 1
or checkitem Bouquet 1
or checkitemw LifeStar 1
or checkitem LifeStar 1
or checkitemw BloodTalisman 1
or checkitem BloodTalisman 1
or checkitemw AssasinRevival 1
or checkitem AssasinRevival 1
#SAY
You cannot take ANY Roses into this event!\
<[ Exit ]/@exit>
#ACT
break

#IF
checkitemw RevivalRing 1
or checkitem RevivalRing 1
#SAY
You cannot take a RevivalRing into this event!\
<[ Exit ]/@exit>
#ACT
break

#IF
checkitem RespawnScroll 1
#SAY
You cannot take a RespawnScroll into this event!\
<[ Exit ]/@exit>
#ACT
break

#IF
!checkmonRecall
#SAY
You cannot take pets into this map!  Try again!\
<[ Exit ]/@exit>
#ACT
Killslave
break

#IF
hour 20 20
min  09 30
#ACT
goto @atimeok
#ELSESAY
Event runs from 20:10-20:30\
<[ Exit ]/@exit>

[@atimeok]
#IF
checkhum PK1 50
#SAY
There is already 50 Players in this map\\
<[ Exit ]/@exit>
#ELSEACT
GOTO @PlayersOK

[@PlayersOK]
#ACT
   FormatStr "FLD_CHARACTER='%s'" %USERNAME
   ReadValueSql  "TBL_INTEGRAL"  %A9  "FLD_CHARACTER,FLD_INTEGRAL"  [@IntPKBattle]

[@IntPKBattle()]
#IF
#ACT
   mov    A0      %ARG(1)
   mov    D2      %ARG(2)
   mov    D3      50
#IF
   Esmall D3 %D2
#ACT
   FormatStr "FLD_CHARACTER='%s'" %USERNAME
   mov   A8     %A9
   dec   D2     %D3
   mov   D4     %D2
   FormatStr "FLD_INTEGRAL='%s'" %D4
   UPDATEVALUESQL "TBL_INTEGRAL" %A8 %A9
   mov     A7  ""
   AddStr  A7 %USERNAME
   AddStr  A7 ","
   AddStr  A7 %D3
   AddStr  A7 ",PKBattle,"
   AddStr  A7 %D0
   Savelog "QuestDiary\IntegralSystem\IntegralLog.txt" %A7
   Goto @PKBattleStart
#ELSESAY
You do not have enough Integral Points\
Your current Integral is {FCOLOR/10}<$OUTPUT(D2)>{FCOLOR/12}\
<[ Back ]/@IntegralMainMenu>\


[@PKBattleStart]
#IF
#ACT
loadvalue N1 "QuestDiary\IntegralSystem\PKBattle\PKBattleInfo.txt" Info Total
SetEventMap  "PK1"
Map PK1
INC N1 50
SAVEVALUE "QuestDiary\IntegralSystem\PKBattle\PKBattleInfo.txt" Info Total %N1
lineMsg [Grobal] "(*)PK Battle Event to start at 20:30!"
goto @jinruok_1
#ELSESAY
You have insufficient Integral\
<[ Exit ]/@exit>

[@jinruok_1]
#IF
equal z12 0
#ACT
mov z12 1
goto @jinruok_2_time

[@jinruok_2_time]
#IF
hour 20 20
min  25 31
#ACT
goto @jinruok_2_10
break

#IF
hour 20 20
min  20 24
#ACT
goto @jinruok_2_15
break

#IF
hour 20 20
min  15 19
#ACT
goto @jinruok_2_20
break

#IF
hour 20 20
min  10 14
#ACT
goto @jinruok_2_25
break

[@jinruok_2_25]
#ACT
lineMsg [Grobal] "(*)You have 25 Minutes left before PK Battle commences - 20:30"
Delaygoto [Grobal] 1260 @jinruok_3_1

[@jinruok_2_20]
#ACT
lineMsg [Grobal] "(*)You have 20 Minutes left before PK Battle commences - 20:30"
Delaygoto [Grobal] 960 @jinruok_3_1

[@jinruok_2_15]
#ACT
lineMsg [Grobal] "(*)You have 15 Minutes left before PK Battle commences - 20:30"
Delaygoto [Grobal] 660 @jinruok_3_1

[@jinruok_2_10]
#ACT
lineMsg [Grobal] "(*)You have 10 Minutes left before PK Battle commences - 20:30"
Delaygoto [Grobal] 360 @jinruok_3_1

[@jinruok_3_1]
#ACT
lineMsg [Grobal] "(*)PK Battle Commences in 2 Minutes"
Eventmsg Grobal "...................................................PK Battle Commences in 2 Minutes" 187
Delaygoto [Grobal] 60 @jinruok_3_2

[@jinruok_3_2]
#ACT
lineMsg [Grobal] "(*)PK Battle Commences in 1 Minute!!!"
Eventmsg Grobal "...................................................PK Battle Commences in 1 Minute!!!" 187
Delaygoto [Grobal] 60 @jinruok_3ok

[@jinruok_3ok]
#ACT
ResetMapAttr "PK1"
SetEventMap  "PK1"
lineMsg [Grobal] "(*)PK Battle Has Started!  You won't go red and you can't drop!!!"
Eventmsg Grobal "...................................................PK Battle Has Started!  You won't go red and you can't drop!!!" 187
Delaygoto [Grobal] 600 @renshujiana

;--------------------------
[@renshujiana]
#IF
checkhum PK1 10
#ACT
lineMsg [Grobal] "(*)Keep going Fighters!  Good Luck to you all!"
Eventmsg Grobal "...................................................Keep going Fighters!  Good Luck to you all!" 187
Delaygoto [Grobal] 300 @renshujiana
break
#ELSEACT
SetEventMap  "PK2"
ChangeMapAttr  "PK2" "SAFE"
mapting PK1 PK2 14 14
lineMsg [Grobal] "(*)Battle Enters second Phase, You have 1 Minute to rest before battle restarts!"
Eventmsg Grobal "...................................................Battle Enters second Phase, You have 1 Minute to rest before battle restarts!" 187
Delaygoto [Grobal] 60 @renshujianb

[@renshujianb]
#ACT
ResetMapAttr "PK2"
SetEventMap  "PK2"
lineMsg [Grobal] "(*)Fighters fight!!!!!!!  Can the Last survivor visit the NPC to collect their prize!"
Eventmsg Grobal "...................................................Fighters fight!!!!!!!  Can the Last survivor visit the NPC to collect their prize!" 187

[@gmpkgg]
#IF
IsAdmin
#SAY
<[ Stop Competition ]/@gmpkgg_cs>\
<[ Main Menu ]/@PKBattle>
#ELSESAY
<[ Main Menu ]/@PKBattle>

[@gmpkgg_cs]
#IF
IsAdmin
#ACT
mov z12 0
#SAY
Competition Stopped!\
#ELSESAY
Sorry, you are not a GM!\

}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;