PVP Startup Script

*Created by Taz.*

```
Using "RC_Core.rcm"
; Morgance Online 0.1
; Date/Time: 12:35:09 AM on 7/30/2012
; By Dan Seguin on TAZCO-PC

Function Main()
Player = Actor()
PZone$ = ActorZone(Player)

;keep running till all players are in zone.

     Pname$ = Split(SuperGlobal(2), 1, "|")  ;Retrive leader and name of master list
    BgName$ = "pvp zone" ;name of pvp zone

     PvpFileName$ = + Pname + "Master PvPBg.Txt"
    PvpFileCheck$ = OpenFile(PvpFileName)

        ReadName1$ = ReadLine(PvpFileCheck)
        ReadName2$ = ReadLine(PvpFileCheck)
        ReadName3$ = ReadLine(PvpFileCheck)
        ReadName4$ = ReadLine(PvpFileCheck)
        ReadName5$ = ReadLine(PvpFileCheck)
     CloseFile(PvpFileCheck)

    AllInZOne% = 0
    Player1Counted% = 0
    Player2Counted% = 0
    Player3Counted% = 0
    Player4Counted% = 0
    Player5Counted% = 0

         Repeat

             FindActor1$ = FindActor(ReadName1)
            Player1Zone$ = ActorZone(FindActor1)
                If (Player1Counted = 0) ;only count player 1 time.
                    If (Player1Zone = BgName)
                        AllInZOne% = AllInZOne + 1
                        Player1Counted% = 1
                    EndIf
                EndIf

            FindActor2$ = FindActor(ReadName2)
            Player2Zone$ = ActorZone(FindActor2)
              If (Player2Counted = 0) ;only count player 1 time.
                If (Player2Zone = BgName)
                    Player2Counted% = 1
                    AllInZOne% = AllInZOne + 1
                EndIf
               EndIf
             FindActor3% = FindActor(ReadName3)
            Player3Zone% = ActorZone(FindActor3)
              If (Player3Counted = 0) ;only count player 1 time.
                If (Player3Zone = BgName)
                    Player3Counted% = 1
                    AllInZOne% = AllInZOne + 1
                EndIf
              EndIf
            FindActor4% = FindActor(ReadName4)
           Player4Zone% = ActorZone(FindActor4)
           If (Player4Counted = 0) ;only count player 1 time.
                If (Player4Zone = BgName)
                    AllInZOne% = AllInZOne + 1
                    Player4Counted% = 1
                EndIf
           EndIf
            FindActor5% = FindActor(ReadName5)
            Player5Zone% = ActorZone(FindActor5)
        If (Player5Counted = 0) ;only count player 1 time.
                If (Player5Zone = BgName)
                    AllInZOne% = AllInZOne + 1
                   Player5Counted% = 1
                EndIf
       EndIf
         ;BubbleOutPut(Player, "Amount in zone is " + AllInZOne)
        Doevents(10)
        Until (AllInZOne >= 5) ;change to5 after testing

 ;Start count down for match
CountDown% = 10
Repeat
;Display count down for all players.

OutPut(FindActor1, "Match will start in " + CountDown + " sec.", 255, 23, 12)
OutPut(FindActor2, "Match will start in " + CountDown + " sec.", 255, 23, 12)
OutPut(FindActor3, "Match will start in " + CountDown + " sec.", 255, 23, 12)
OutPut(FindActor4, "Match will start in " + CountDown + " sec.", 255, 23, 12)
OutPut(FindActor5, "Match will start in " + CountDown + " sec.", 255, 23, 12)

CountDown% = CountDown - 1
DoEvents(1000)
Until (CountDown = 0)

DoorName$ = "Block"
FindDoor$ = FindActor(DoorName, 0)
BgZone$ = "pvp zone"
DoorZone$ = ActorZone(FindDoor)
;will need to add a zone instance check as well
If (DoorZone = BgZone) ;if door is in pvp zone remove it
SetAttribute(FindDoor, "Health", 0)
EndIf

;Tell player match has started
OutPut(FindActor1, "Match Started", 255, 23, 12)
OutPut(FindActor2, "Match Started", 255, 23, 12)
OutPut(FindActor3, "Match Started", 255, 23, 12)
OutPut(FindActor4, "Match Started", 255, 23, 12)
OutPut(FindActor5, "Match Started", 255, 23, 12)

End Function

;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;----------------------------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------------------------
;run pvp startup for hold flag

Function HoldFlag()

Player = Actor()
PZone$ = ActorZone(Player)

;keep running till all players are in zone.

     Pname$ = Split(SuperGlobal(3), 1, "|")  ;Retrive leader and name of master list
    BgName$ = "PvpHoldFlag" ;name of pvp zone

     PvpFileName$ = + Pname + "Master Holdflag PvPBg.Txt"
    PvpFileCheck$ = OpenFile(PvpFileName)

        ReadName1$ = ReadLine(PvpFileCheck)
        ReadName2$ = ReadLine(PvpFileCheck)
        ReadName3$ = ReadLine(PvpFileCheck)
        ReadName4$ = ReadLine(PvpFileCheck)
        ReadName5$ = ReadLine(PvpFileCheck)
     CloseFile(PvpFileCheck)

    AllInZOne% = 0
    Player1Counted% = 0
    Player2Counted% = 0
    Player3Counted% = 0
    Player4Counted% = 0
    Player5Counted% = 0

         Repeat

             FindActor1$ = FindActor(ReadName1)
            Player1Zone$ = ActorZone(FindActor1)
                If (Player1Counted = 0) ;only count player 1 time.
                    If (Player1Zone = BgName)
                        AllInZOne% = AllInZOne + 1
                        Player1Counted% = 1
                    EndIf
                EndIf

            FindActor2$ = FindActor(ReadName2)
            Player2Zone$ = ActorZone(FindActor2)
              If (Player2Counted = 0) ;only count player 1 time.
                If (Player2Zone = BgName)
                    Player2Counted% = 1
                    AllInZOne% = AllInZOne + 1
                EndIf
               EndIf
             FindActor3% = FindActor(ReadName3)
            Player3Zone% = ActorZone(FindActor3)
              If (Player3Counted = 0) ;only count player 1 time.
                If (Player3Zone = BgName)
                    Player3Counted% = 1
                    AllInZOne% = AllInZOne + 1
                EndIf
              EndIf
            FindActor4% = FindActor(ReadName4)
           Player4Zone% = ActorZone(FindActor4)
           If (Player4Counted = 0) ;only count player 1 time.
                If (Player4Zone = BgName)
                    AllInZOne% = AllInZOne + 1
                    Player4Counted% = 1
                EndIf
           EndIf
            FindActor5% = FindActor(ReadName5)
            Player5Zone% = ActorZone(FindActor5)
        If (Player5Counted = 0) ;only count player 1 time.
                If (Player5Zone = BgName)
                    AllInZOne% = AllInZOne + 1
                   Player5Counted% = 1
                EndIf
       EndIf
         ;BubbleOutPut(Player, "Amount in zone is " + AllInZOne)
        Doevents(10)
        Until (AllInZOne >= 5) ;change to5 after testing

 ;Start count down for match
CountDown% = 10
Repeat
;Display count down for all players.

OutPut(FindActor1, "Match will start in " + CountDown + " sec.", 255, 23, 12)
OutPut(FindActor2, "Match will start in " + CountDown + " sec.", 255, 23, 12)
OutPut(FindActor3, "Match will start in " + CountDown + " sec.", 255, 23, 12)
OutPut(FindActor4, "Match will start in " + CountDown + " sec.", 255, 23, 12)
OutPut(FindActor5, "Match will start in " + CountDown + " sec.", 255, 23, 12)

CountDown% = CountDown - 1
DoEvents(1000)
Until (CountDown = 0)

;Tell player match has started
OutPut(FindActor1, "Match Started", 255, 23, 12)
OutPut(FindActor2, "Match Started", 255, 23, 12)
OutPut(FindActor3, "Match Started", 255, 23, 12)
OutPut(FindActor4, "Match Started", 255, 23, 12)
OutPut(FindActor5, "Match Started", 255, 23, 12)

;keep track of time and amount players have for holding the flag
RoundOver% = 0 ;set to one when round is over and repeat should end
AmuountToWin% = 20 ; = in sec
FlagHeldName$ = "Pvp Flag"
                    Pname$ = Split(SuperGlobal(3), 1, "|")  ;Retrive leader and name of master list

                        PvpFileName$ = + Pname + "Master Holdflag PvPBg.Txt"
                        PvpFileCheck$ = OpenFile(PvpFileName)
                        ReadName1$ = ReadLine(PvpFileCheck)
                        ReadName2$ = ReadLine(PvpFileCheck)
                        ReadName3$ = ReadLine(PvpFileCheck)
                        ReadName4$ = ReadLine(PvpFileCheck)
                        ReadName5$ = ReadLine(PvpFileCheck)
                        CloseFile(PvpFileCheck)
Repeat

;NOTE open all players resaults at once.

                        ;First player
                        FindName1$ = FindActor(ReadName1) ;find firt name in list
                        FindName1InGame$ = PlayerInGame(FindName1)
                        If (FindName1InGame = 1) ;player online show results
                            P1HoldPoints% = Attribute(FindName1, "PVPBG Points")
                            ItemHeld% = HasItem(FindName1, FlagHeldName)
                                    If (ItemHeld = 1) ;if flag is held give points
                                        TotalHeldPoints% = P1HoldPoints + 1
                                        SetAttribute(FindName1, "PVPBG Points", TotalHeldPoints)

                                        P1HoldPoints% = Attribute(FindName1, "PVPBG Points") ;get amount to see if player wins
                                        If (P1HoldPoints >= AmuountToWin)
                                         ScreenFlash(FindName1, 255, 255, 255, 255, 10000, 555) ;M_Pvp_battleground won GUE ID 555
                                        WinningPlayer% = 1
                                        RoundOver = 1 ;end script
                                        WinnerName% = Name(FindName1)
                                        EndIf
                                    EndIf
                        EndIf

                         ;second player
                        FindName2$ = FindActor(ReadName2) ;find firt name in list
                        FindName2InGame$ = PlayerInGame(FindName2)
                        If (FindName2InGame = 1) ;player online show results
                            P1HoldPoints% = Attribute(FindName2, "PVPBG Points")
                            ItemHeld% = HasItem(FindName2, FlagHeldName)
                                    If (ItemHeld = 1) ;if flag is held give points
                                        TotalHeldPoints% = P1HoldPoints + 1
                                        SetAttribute(FindName2, "PVPBG Points", TotalHeldPoints)

                                        P1HoldPoints% = Attribute(FindName2, "PVPBG Points") ;get amount to see if player wins
                                        If (P1HoldPoints >= AmuountToWin)
                                         ScreenFlash(FindName2, 255, 255, 255, 255, 10000, 555) ;M_Pvp_battleground won GUE ID 555
                                        WinningPlayer% = 1
                                        RoundOver = 1 ;end script
                                        WinnerName% = Name(FindName2)
                                        EndIf
                                    EndIf
                        EndIf

                        ;Third Player
                        FindName3$ = FindActor(ReadName3) ;find firt name in list
                        FindName3InGame$ = PlayerInGame(FindName3)
                        If (FindName3InGame = 1) ;player online show results
                           P1HoldPoints% = Attribute(FindName3, "PVPBG Points")
                            ItemHeld% = HasItem(FindName3, FlagHeldName)
                                    If (ItemHeld = 1) ;if flag is held give points
                                        TotalHeldPoints% = P1HoldPoints + 1
                                        SetAttribute(FindName3, "PVPBG Points", TotalHeldPoints)

                                        P1HoldPoints% = Attribute(FindName3, "PVPBG Points") ;get amount to see if player wins
                                        If (P1HoldPoints >= AmuountToWin)
                                         ScreenFlash(FindName3, 255, 255, 255, 255, 10000, 555) ;M_Pvp_battleground won GUE ID 555
                                        WinningPlayer% = 1
                                        RoundOver = 1 ;end script
                                        WinnerName% = Name(FindName3)
                                        EndIf
                                    EndIf
                        EndIf

;                        ;Forth Player
                         FindName4$ = FindActor(ReadName4) ;find firt name in list
                         FindName4InGame$ = PlayerInGame(FindName4)
                        If (FindName4InGame = 1) ;player online show results
                          P1HoldPoints% = Attribute(FindName4, "PVPBG Points")
                            ItemHeld% = HasItem(FindName4, FlagHeldName)
                                    If (ItemHeld = 1) ;if flag is held give points
                                        TotalHeldPoints% = P1HoldPoints + 1
                                        SetAttribute(FindName4, "PVPBG Points", TotalHeldPoints)

                                        P1HoldPoints% = Attribute(FindName4, "PVPBG Points") ;get amount to see if player wins
                                        If (P1HoldPoints >= AmuountToWin)
                                         ScreenFlash(FindName4, 255, 255, 255, 255, 10000, 555) ;M_Pvp_battleground won GUE ID 555
                                        WinningPlayer% = 1
                                        RoundOver = 1 ;end script
                                        WinnerName% = Name(FindName4)
                                        EndIf
                                    EndIf
                        EndIf

;                        ;Fifth Player
                        FindName5$ = FindActor(ReadName5) ;find firt name in list
                        FindName5InGame$ = PlayerInGame(FindName5)
                        If (FindName5InGame = 1) ;player online show results
                           P1HoldPoints% = Attribute(FindName5, "PVPBG Points")
                            ItemHeld% = HasItem(FindName5, FlagHeldName)
                                    If (ItemHeld = 1) ;if flag is held give points
                                        TotalHeldPoints% = P1HoldPoints + 1
                                        SetAttribute(FindName5, "PVPBG Points", TotalHeldPoints)

                                        P1HoldPoints% = Attribute(FindName5, "PVPBG Points") ;get amount to see if player wins
                                        If (P1HoldPoints >= AmuountToWin)
                                                ScreenFlash(FindName5, 255, 255, 255, 255, 10000, 555) ;M_Pvp_battleground won GUE ID 555
                                        WinningPlayer% = 1
                                        RoundOver = 1 ;end script
                                        WinnerName% = Name(FindName5)
                                        EndIf
                                    EndIf
                        EndIf

;If no one is holding the flag respawn it.
        If (HasItem(FindName1, FlagHeldName) = 0) And HasItem(FindName2, FlagHeldName) And HasItem(FindName3, FlagHeldName) And HasItem(FindName4, FlagHeldName) And HasItem(FindName5, FlagHeldName)
            ;will need to chage inctance of flag spawn to inctance of players
            ZoneNumSpawn% = 1

                ;need to fix for multibale battle grounds
                    FlagHeld% = SuperGlobal(12)

                        If (FlagHeld >= 5)
                            DontSpawnFlag% = 1
                        EndIf

                    ;flag name
                        NameOfFlag$ = "Pvp Flag"
                        FlagIsSpawned% = FindActor(NameOfFlag, 2)
                        FlagZone$ = ActorZone(FlagIsSpawned)
                        PZone$ = "Pvp Zone" ;1 vs 5 cap flag
                        PHoldPvp$ = "pvpholdflag"

                If (NameOfFlag = FlagZone) ; if flag is in this zone end script
                    DontSpawnFlag% = 1
                EndIf

                If (NameOfFlag = PHoldPvp) ; if flag is in this zone end script
                    DontSpawnFlag% = 1
                EndIf

                    If (DontSpawnFlag = 0)
                           ; Pick random flag spawn
                            FlagSpawn% = Rand(1, 6)
                            PZone$ = "pvpholdflag"
                        If (FlagSpawn = 1)
                           NewFlagSpawn$ = Spawn(FlagID, PZone, 203.353, 77.7768, 18.1667, "Pvp_Flag_Right Click", "", ZoneNumSpawn) ;Spawn pvp flag in 1 of 3 places.
                        ElseIf (FlagSpawn = 2)
                          NewFlagSpawn$ = Spawn(FlagID, PZone, 11.3225, 110.022, 48.7636, "Pvp_Flag_Right Click", "", ZoneNumSpawn) ;Spawn pvp flag in 1 of 3 places.
                        ElseIf(FlagSpawn = 3)
                          NewFlagSpawn$ = Spawn(FlagID, PZone, 508.802, 99.0043, 409.793, "Pvp_Flag_Right Click", "", ZoneNumSpawn) ;Spawn pvp flag in 1 of 3 places.
                        ElseIf(FlagSpawn = 4)
                          NewFlagSpawn$ = Spawn(FlagID, PZone, 79.5606, 89.8855, 459.374, "Pvp_Flag_Right Click", "", ZoneNumSpawn) ;Spawn pvp flag in 1 of 3 places.
                        ElseIf(FlagSpawn = 5)
                          NewFlagSpawn$ = Spawn(FlagID, PZone, - 76.009, 91.3214, 563.521, "Pvp_Flag_Right Click", "", ZoneNumSpawn) ;Spawn pvp flag in 1 of 3 places.
                        ElseIf(FlagSpawn = 6)
                          NewFlagSpawn$ = Spawn(FlagID, PZone, 465.644, 46.9174, 35.4374, "Pvp_Flag_Right Click", "", ZoneNumSpawn) ;Spawn pvp flag in 1 of 3 places.
                        EndIf
                        DontSpawnFlag% = 0
                    EndIf

        EndIf ;End check if all players have no flag.

Doevents(1000)
Until (RoundOver = 1)

If (WinningPlayer = 1) ;there is a winner

            ;flash screen for the losers!
            If Not (Pname = Name(FindName1)) ;if not winner show losser
                ScreenFlash(FindName1, 255, 255, 255, 255, 10000, 653)
            EndIf

             If Not (Pname = Name(FindName2)) ;if not winner show losser
                ScreenFlash(FindName2, 255, 255, 255, 255, 10000, 653)
            EndIf

             If Not (Pname = Name(FindName3)) ;if not winner show losser
                ScreenFlash(FindName3, 255, 255, 255, 255, 10000, 653)
            EndIf

            If Not (Pname = Name(FindName4)) ;if not winner show losser
                ScreenFlash(FindName4, 255, 255, 255, 255, 10000, 653)
            EndIf

             If Not (Pname = Name(FindName5)) ;if not winner show losser
                ScreenFlash(FindName5, 255, 255, 255, 255, 10000, 653)
            EndIf
            DoEvents(8000)

                    ;Get Result Info display flag held time and pvp kills
                         PvpKillCountBg% = Split(ActorGlobal(FindName1, 3), 20, "|") ;player bg kill amount
                         Player1FlagReturns% = Attribute(FindName1, "PVPBG Points")
                         PlayerName1$ = Name(FindName1)
                         PvpKillCountBg2% = Split(ActorGlobal(FindName2, 3), 20, "|") ;player bg kill amount
                         Player2FlagReturns% = Attribute(FindName2, "PVPBG Points")
                         PlayerName2$ = Name(FindName2)
                         PvpKillCountBg3% = Split(ActorGlobal(FindName3, 3), 20, "|") ;player bg kill amount
                         Player3FlagReturns% = Attribute(FindName3, "PVPBG Points")
                         PlayerName3$ = Name(FindName3)
                         PvpKillCountBg4% = Split(ActorGlobal(FindName4, 3), 20, "|") ;player bg kill amount
                         Player4FlagReturns% = Attribute(FindName4, "PVPBG Points")
                         PlayerName4$ = Name(FindName4)
                         PvpKillCountBg5% = Split(ActorGlobal(FindName5, 3), 20, "|") ;player bg kill amount
                         Player5FlagReturns% = Attribute(FindName5, "PVPBG Points")
                         PlayerName5$ = Name(FindName5)

;check if players are ingame to show text to.

                        FindName1InGame$ = PlayerInGame(FindName1)
                        FindName2InGame$ = PlayerInGame(FindName2)
                        FindName3InGame$ = PlayerInGame(FindName3)
                        FindName4InGame$ = PlayerInGame(FindName4)
                        FindName5InGame$ = PlayerInGame(FindName5)

                       ;First player
                        If (FindName1InGame = 1) ;player online show results
                            Chatbox$ = OpenDialog(FindName1, Player, "Pvp Results", 521)
                            ShowP1% = 1
                        EndIf

                         ;second player
                        If (FindName2InGame = 1) ;player online show results
                            Chatbox1$ = OpenDialog(FindName2, Player, "Pvp Results", 521)
                            ShowP2% = 1
                        EndIf

                        ;Third Player
                        If (FindName3InGame = 1) ;player online show results
                            Chatbox2$ = OpenDialog(FindName3, Player, "Pvp Results", 521)
                            ShowP3% = 1
                        EndIf

;                        ;Forth Player
                        If (FindName4InGame = 1) ;player online show results
                            Chatbox3$ = OpenDialog(FindName4, Player, "Pvp Results", 521)
                            ShowP4% = 1
                        EndIf

;                        ;Fifth Player
                        If (FindName5InGame = 1) ;player online show results
                            Chatbox4$ = OpenDialog(FindName5, Player, "Pvp Results", 521)
                            ShowP5% = 1
                        EndIf

                        ;Change name to winner
                        PName$ = WinnerName

                        If (FindName1InGame = 1) ;player online show results
                         ;Display results to all players
                        DialogOutPut(FindName1, ChatBox, "----------" + PName + " WINS----------", 110, 0, 234)
                        DialogOutPut(FindName1, ChatBox, "----------------The Match-------------", 110, 0, 234)
                        DialogOutPut(FindName1, ChatBox, "")
                        DialogOutPut(FindName1, ChatBox, "----Name------Held Time------Kills----", 110, 0, 234)
                        DialogOutPut(FindName1, ChatBox, "---"+ PlayerName1 +"-------"+ Player1FlagReturns + "-------------" + PvpKillCountBg + "-----", 110, 0, 234)
                        DialogOutPut(FindName1, ChatBox, "---"+ PlayerName2 +"-------"+ Player2FlagReturns + "-------------" + PvpKillCountBg2 + "-----", 110, 0, 234)
                        DialogOutPut(FindName1, ChatBox, "---"+ PlayerName3 +"-------"+ Player3FlagReturns + "------------" + PvpKillCountBg3 + "-----", 110, 0, 234)
                        DialogOutPut(FindName1, ChatBox, "---"+ PlayerName4 +"-------"+ Player4FlagReturns + "------------" + PvpKillCountBg4 + "-----", 110, 0, 234)
                        DialogOutPut(FindName1, ChatBox, "---"+ PlayerName5 +"-------"+ Player5FlagReturns + "------------" + PvpKillCountBg5 + "-----", 110, 0, 234)
                DoEvents(100)

                        EndIf

                        If (FindName2InGame = 1) ;player online show results
                         ;Display results to all players
                        DialogOutPut(FindName2, Chatbox1, "----------" + PName + " WINS----------", 110, 0, 234)
                        DialogOutPut(FindName2, Chatbox1, "----------------The Match-------------", 110, 0, 234)
                        DialogOutPut(FindName2, Chatbox1, "")
                        DialogOutPut(FindName2, Chatbox1, "----Name------Held Time------Kills----", 110, 0, 234)
                        DialogOutPut(FindName2, Chatbox1, "---"+ PlayerName1 +"-------"+ Player1FlagReturns + "-------------" + PvpKillCountBg + "-----", 110, 0, 234)
                        DialogOutPut(FindName2, Chatbox1, "---"+ PlayerName2 +"-------"+ Player2FlagReturns + "-------------" + PvpKillCountBg2 + "-----", 110, 0, 234)
                        DialogOutPut(FindName2, Chatbox1, "---"+ PlayerName3 +"-------"+ Player3FlagReturns + "------------" + PvpKillCountBg3 + "-----", 110, 0, 234)
                        DialogOutPut(FindName2, Chatbox1, "---"+ PlayerName4 +"-------"+ Player4FlagReturns + "------------" + PvpKillCountBg4 + "-----", 110, 0, 234)
                        DialogOutPut(FindName2, Chatbox1, "---"+ PlayerName5 +"-------"+ Player5FlagReturns + "------------" + PvpKillCountBg5 + "-----", 110, 0, 234)
                DoEvents(100)

                        EndIf

                        If (FindName3InGame = 1) ;player online show results

                         ;Display results to all players
                        DialogOutPut(FindName3, Chatbox2, "----------" + PName + " WINS----------", 110, 0, 234)
                        DialogOutPut(FindName3, Chatbox2, "----------------The Match-------------", 110, 0, 234)
                        DialogOutPut(FindName3, Chatbox2, "")
                        DialogOutPut(FindName3, Chatbox2, "----Name------Held Time------Kills----", 110, 0, 234)
                        DialogOutPut(FindName3, Chatbox2, "---"+ PlayerName1 +"-------"+ Player1FlagReturns + "-------------" + PvpKillCountBg + "-----", 110, 0, 234)
                        DialogOutPut(FindName3, Chatbox2, "---"+ PlayerName2 +"-------"+ Player2FlagReturns + "-------------" + PvpKillCountBg2 + "-----", 110, 0, 234)
                        DialogOutPut(FindName3, Chatbox2, "---"+ PlayerName3 +"-------"+ Player3FlagReturns + "------------" + PvpKillCountBg3 + "-----", 110, 0, 234)
                        DialogOutPut(FindName3, Chatbox2, "---"+ PlayerName4 +"-------"+ Player4FlagReturns + "------------" + PvpKillCountBg4 + "-----", 110, 0, 234)
                        DialogOutPut(FindName3, Chatbox2, "---"+ PlayerName5 +"-------"+ Player5FlagReturns + "------------" + PvpKillCountBg5 + "-----", 110, 0, 234)
                DoEvents(100)

                        EndIf

                        If (FindName4InGame = 1) ;player online show results
                         ;Display results to all players
                        DialogOutPut(FindName4, Chatbox3, "----------" + PName + " WINS----------", 110, 0, 234)
                        DialogOutPut(FindName4, Chatbox3, "----------------The Match-------------", 110, 0, 234)
                        DialogOutPut(FindName4, Chatbox3, "")
                        DialogOutPut(FindName4, Chatbox3, "----Name------Held Time------Kills----", 110, 0, 234)
                        DialogOutPut(FindName4, Chatbox3, "---"+ PlayerName1 +"-------"+ Player1FlagReturns + "-------------" + PvpKillCountBg + "-----", 110, 0, 234)
                        DialogOutPut(FindName4, Chatbox3, "---"+ PlayerName2 +"-------"+ Player2FlagReturns + "-------------" + PvpKillCountBg2 + "-----", 110, 0, 234)
                        DialogOutPut(FindName4, Chatbox3, "---"+ PlayerName3 +"-------"+ Player3FlagReturns + "------------" + PvpKillCountBg3 + "-----", 110, 0, 234)
                        DialogOutPut(FindName4, Chatbox3, "---"+ PlayerName4 +"-------"+ Player4FlagReturns + "------------" + PvpKillCountBg4 + "-----", 110, 0, 234)
                        DialogOutPut(FindName4, Chatbox3, "---"+ PlayerName5 +"-------"+ Player5FlagReturns + "------------" + PvpKillCountBg5 + "-----", 110, 0, 234)
                DoEvents(100)

                        EndIf

                        If (FindName5InGame = 1) ;player online show results

                         ;Display results to all players
                        DialogOutPut(FindName5, Chatbox4, "----------" + PName + " WINS----------", 110, 0, 234)
                        DialogOutPut(FindName5, Chatbox4, "----------------The Match-------------", 110, 0, 234)
                        DialogOutPut(FindName5, Chatbox4, "")
                        DialogOutPut(FindName5, Chatbox4, "----Name------Held Time------Kills----", 110, 0, 234)
                        DialogOutPut(FindName5, Chatbox4, "---"+ PlayerName1 +"-------"+ Player1FlagReturns + "-------------" + PvpKillCountBg + "-----", 110, 0, 234)
                        DialogOutPut(FindName5, Chatbox4, "---"+ PlayerName2 +"-------"+ Player2FlagReturns + "-------------" + PvpKillCountBg2 + "-----", 110, 0, 234)
                        DialogOutPut(FindName5, Chatbox4, "---"+ PlayerName3 +"-------"+ Player3FlagReturns + "------------" + PvpKillCountBg3 + "-----", 110, 0, 234)
                        DialogOutPut(FindName5, Chatbox4, "---"+ PlayerName4 +"-------"+ Player4FlagReturns + "------------" + PvpKillCountBg4 + "-----", 110, 0, 234)
                        DialogOutPut(FindName5, Chatbox4, "---"+ PlayerName5 +"-------"+ Player5FlagReturns + "------------" + PvpKillCountBg5 + "-----", 110, 0, 234)
                DoEvents(100)

                        EndIf

            If (ShowP1 = 1) ;show exit to player 1 if they are online
                        DialogInput(FindName1, ChatBox, "OK") ;player 1
                        CloseDialog(FindName1, ChatBox)
                        SetMaxAttribute(FindName1, "PVPBG Points", 0) ;set attribute back to zero so flags can be counted again.
                        SetAttribute(FindName1, "PVPBG Points", 0)
                        Warp(FindName1, "Annakay Town", "Start", 0) ;Warp 1st player
            EndIf

            If (ShowP2 = 1) ;show exit to player 2 if they are online

                         DialogInput(FindName2, ChatBox1, "OK") ;player 2
                         CloseDialog(FindName2, ChatBox1)
                        SetMaxAttribute(FindName2, "PVPBG Points", 0) ;set attribute back to zero so flags can be counted again.
                        SetAttribute(FindName2, "PVPBG Points", 0)
                         Warp(FindName2, "Annakay Town", "Start", 0) ;Warp 2nd player
             EndIf

                 If (ShowP3 = 1) ;show exit to player 3 if they are online

                        DialogInput(FindName3, ChatBox2, "OK") ;player 3
                        CloseDialog(FindName3, ChatBox2)
                        SetMaxAttribute(FindName3, "PVPBG Points", 0) ;set attribute back to zero so flags can be counted again.
                        SetAttribute(FindName3, "PVPBG Points", 0)
                        Warp(FindName3, "Annakay Town", "Start", 0) ;Warp 3rd player
                 EndIf

                  If (ShowP4 = 1) ;show exit to player 4 if they are online
                        ;DialogInput(FindName4, ChatBox3, "OK") ;player 4
                        CloseDialog(FindName4, ChatBox3)
                        SetMaxAttribute(FindName4, "PVPBG Points", 0) ;set attribute back to zero so flags can be counted again.
                        SetAttribute(FindName4, "PVPBG Points", 0)
                        Warp(FindName4, "Annakay Town", "Start", 0) ;Warp 4th player
                 EndIf
                 If (ShowP5 = 1) ;show exit to player 5 if they are online
                        ;DialogInput(FindName5, ChatBox4, "OK") ;player 5
                        CloseDialog(FindName5, ChatBox4)
                        SetMaxAttribute(FindName5, "PVPBG Points", 0) ;set attribute back to zero so flags can be counted again.
                        SetAttribute(FindName5, "PVPBG Points", 0)
                        Warp(FindName5, "Annakay Town", "Start", 0) ;Warp 5th player
                 EndIf

         CreateEmitter(Player, "Summon_Mount", 11, 5000) ;make player glow with power

              Pname$ = Split(SuperGlobal(3), 1, "|")  ;Retrive leader and name of master list
              DeleteFile(+ Pname + "Master Holdflag PvPBg.Txt") ;remove pvp bg file
                           ;Make super global delimiter if there is no pvp zones made yet.
                ;Set changes to delimiter

             Pvpname1$ = 0 ;change name to 0
            Pvpname2$ = Split(SuperGlobal(3), 2, "|")
            Pvpname3$ = Split(SuperGlobal(3), 3, "|")
            Pvpname4$ = Split(SuperGlobal(3), 4, "|")
            Pvpname5$ = Split(SuperGlobal(3), 5, "|")
            Pvpname6$ = Split(SuperGlobal(3), 6, "|")
            Pvpname7$ = Split(SuperGlobal(3), 7, "|")
            Pvpname8$ = Split(SuperGlobal(3), 8, "|")
            Pvpname9$ = Split(SuperGlobal(3), 9, "|")
            Pvpname10$ = Split(SuperGlobal(3), 10, "|")

        SetSuperGlobal(3, PvpZoneLeaders) ;set dilimiter

            ;kill flag before removing zone
           FlagName$ = "Pvp Flag"
           SpawnedFlag$ = FindActor(FlagName, 2)
            If (SpawnedFlag = 1)
                SetAttribute(SpawnedFlag, "Health", 0)
            EndIf
            DoEvents(10000)
            RemoveZoneInstance(BgName, 1)

Endif

 End Function

```