RealmCrafter Wiki
Register
Advertisement

Created by Taz.

Using "RC_Core.rcm"
; Test
 ; Date/Time: 10:17:53 PM on 3/6/2011
; By Naddaz on TAZCO

;Now search will only search 1 at a time, sucks but less problems this way.
;NOTE this script must be called  "Guildinfo" or you would need to change the threadexecutes.
;Updated March 22 2011 Added rage war and alliance
;Updated june 2 2011 Fixed an issue with add player.

Function Main()
;Guild info to show guild members and add members.
;Scripted by Dan Seguin RC Forum name Taz20241

Player = Actor()
Target = ContextActor()
Pname$ = Name(Player)



 
 NewDialog = 0
 Repeat ;NOTE this repeat to keep the dialog open is stoping the guild name list from showing multiple names.
 ;-----------------------------------------------------------------------------------
;if guild master give more options.
GuildTag$ = Split(ActorGlobal(Player, 3), 15, "|")
GTag% = Split(ActorGlobal(Player, 3), 14, "|")


;IF (GuildTag = 0)
;    GuildTag$ = Tag(Player)
;Endif
 
 OutPut(Player, "guild tag is " + GuildTag)
 
 
  If (GTag = 0)
   ;player is not in a guild tell them and end script.
        ChatBox = OpenDialog(Player, Target, "Guild Info")
        DialogOutPut(Player, ChatBox, "You are not in a guild, you must be in one, or make one to use this feature.")
        DialogInput(Player, Chatbox, "Close")
        CloseDialog(Player, ChatBox)
     
        Return
     EndIf
   
 ;-----------------------------------------------------------------------------------
    NewGname$ = + GuildTag + ".txt"
    NameCheck$ = OpenFile(NewGname)
    ;Check if player is guild master
    Mastername$ = ReadLine(NameCheck)
    Mastername1$ = Mastername
    
         CloseFile(NameCheck) ;close file
       ; CloseFile(Mastername) ;close file
   CloseDialog(Player, ChatBox)    
    
     ChatBox = OpenDialog(Player, Target, "Guild Info")
    DialogOutput(Player, ChatBox, "Pick a option")
    
      If (Mastername1 = Pname)
          ;Player is guild master give new options.
        POption% = DialogInput(Player, ChatBox, "Guild Info,Search Members,Guild Options,Help,Close,Add Member,Disband Guild,Set MOTD") 
        GuildMaster% = 1 ;will be used to show more options in search
     Else
           ;Player is non Guild master give normal options.
        POption% = DialogInput(Player, ChatBox, "Guild Info,Search Members,Guild Options,Help,Close") 
     EndIf
 
  
 
 If (POption = 1) ;Guild Info
   CloseDialog(Player, ChatBox)
  ChatBox = OpenDialog(Player, Target, "Guild Info")     
  DialogOutPut(Player, ChatBox, "Your guild master is " + Mastername1) 
  DialogOutPut(Player, ChatBox, "Your guild name is "  + GuildTag)

 MOTDFile$ = + GuildTag + " MOTD.txt" 
 OFile$ = OpenFile(MOTDFile)
     
     If (OFile = 0) ; there is no MOTD 
        DialogInput(Player, ChatBox, "Close")     
        CloseDialog(Player, ChatBox) 
        CloseFile(OFile)
   
     Else ;there is a MOTD show it.
      ReadMOTD$ = ReadLine(OFile)
      DialogOutPut(Player, ChatBox, "")
      DialogOutPut(Player, ChatBox, "Message of the day is", 255, 200, 176) 
      DialogOutPut(Player, ChatBox, + ReadMOTD)
      DialogInput(Player, ChatBox, "Close")
      CloseDialog(Player, ChatBox)
      CloseFile(OFile)
      CloseFile(ReadMOTD)
    EndIf
     
 ElseIf (POption = 2) ;Search Members
     
          NewGname$ = + GuildTag + ".txt"
         NameCheck$ = OpenFile(NewGname)

         CoutNames% = 0 ;will be used to count names in guild, using to change to next 9 amount.
        
        Repeat 
          CloseDialog(Player, Chatbox)
         ChatBox = OpenDialog(Player, 0, "Guild name search")
         
             DoEvents(10)
        
            Readname$ = ReadLine(NameCheck) 
           Checkname$ = Readname
           DialogOutPut(Player, Chatbox, + Checkname)
    
            CloseFile(Readname)
           CoutNames% = CoutNames + 1
              EndFile% = Eof(NameCheck)
                 
        
             ;If (CoutNames <> 9) ;give input and reset dialog out put.
 If (GuildMaster = 1) ;show more options for guild master
           
    ;If (CoutNames >= 2) ;count names amount
                  
                  If Not (Checkname = "")
                   Poption% = DialogInput(Player, ChatBox, "Close,Input Name,Next")
                  Else
                   DialogOutPut(Player, ChatBox, "End of guild name list.")
                   DialogInput(Player, ChatBox, "Close")
                   StopRe% = 1      
                  EndIf
              
                     If (Poption = 1) ;close search
                     CloseDialog(Player, Chatbox)
                     
                     StopRe% = 1                  
                    EndIf
                   ;------------------------------------------
                   ;Add options for guild master.
                   
                   Reusename$ = Checkname
                  If (Poption = 2) ;input name
                Repeat 
           
                 
                                   If (NewDialog = 1) ;set to 1 by picking try again
                                       CloseDialog(Player, ChatBox)
                                       ChatBox = OpenDialog(Player, 0, "Guild name search")
                                       DialogOutPut(Player, Chatbox, "Last name searched is " + Reusename)
                                       DialogOutput(Player, Chatbox, "Enter name of member to see more options.")
                                       DialogOutPut(Player, ChatBox, "Type exit to end input") 
                                       PInput$ = Input(Player, "Player Name", "", 0)
                                       NewDialog% = 0
                                       
                                   Else ;will be call on first time check.
                                     DialogOutput(Player, Chatbox, "Enter name of member to see more options.")
                                     DialogOutPut(Player, ChatBox, "Type exit to end input") 
                                     PInput$ = Input(Player, "Player Name", "", 0)
                                   EndIf
                                    
                       ;Check if players name is in the guild. 
                       CloseFile(NameCheck)
                       DoEvents(10)
                       
                          EndInput$ = "exit"
                       
                          If (PInput = EndInput)
                           CloseDialog(Player, ChatBox)
                           Return
                          EndIf
                       
                       
                        NewGname$ = + GuildTag + ".txt"
                        NameCheck$ = OpenFile(NewGname)
                        
                   ;check if player name entered is in list.   
                   Repeat    
                         DoEvents(10)
                
                        Readname$ = ReadLine(NameCheck) 
                        Checkname$ = Readname
                        CloseFile(Readname)
                        
                        EndFile% = Eof(NameCheck)
                        If (Checkname = PInput)
                          EndFile% = 1
                        EndIf
                        
                   Until (EndFile = 1)      
                        
                           If (Checkname = PInput) ;check name inputed
                            
                             ;Player found add more options for guild master.
                             
                             MastOption% = DialogInput(Player, ChatBox, "Kick,Close")
                             
                                 If (MastOption = 2) ;Close
                                    CloseDialog(Player, ChatBox)
                                    Return
                                 EndIf
                              
                             
                              If (MastOption = 1) ;master option kick player 
                                
                                DialogOutPut(Player, Chatbox, "Are you sure you want to remove " + PInput + " from guild?")
                                KickOption% = DialogInPut(Player, ChatBox, "No,Yes")
                                
                                    If (KickOption = 1) ;close master declined kicking of player.
                                      CloseDialog(Player, ChatBox)
                                      ChatBox = OpenDialog(Player, Target, "")
                                      DialogOutPut(Player, ChatBox, "You are going to keep " + PInput + " in the guild")
                                      DialogInput(Player, ChatBox, "Close")
                                      CloseDialog(Player, ChatBox)
                                      CloseFile(NameCheck)
                                      Return
                                    EndIf
                                
                                  ;Continue removing player.
                                  ;Rewrite guild text file.
                                  
                                 CloseFile(NameCheck)
 
                                    NewGname$ = + GuildTag + ".txt"
                                   NameCheck$ = OpenFile(NewGname)

                                    TempFile1$ = + GuildTag + "temp.txt" ;make temp file.
                                    TempCheck$ = WriteFile(TempFile1)
                                  
                                        Repeat
                                          EndFilewrite% = Eof(NameCheck)
                                        
                                            ReadGline1$ = Readline(NameCheck)
                                            ReadGline$ = ReadGline1
                                            CloseFile(ReadGline1)
                                             Doevents(10)
                                             
                                                If (PInput = PName)
                                                    CloseDialog(Player, ChatBox)
                                                    ChatBox = OpenDialog(Player, Target, "")
                                                    DialogOutPut(Player, ChatBox, "You can not kick yourself from the guild")
                                                    DialogINput(Player, ChatBox, "Close")
                                                    CloseDialog(Player, ChatBox)
                                                    CloseFile(NameCheck)
                                                    CloseFile(TempCheck)
                                                    DeleteFile(+ GuildTag + "temp.txt") ;delete file so it can be rewriten.
                                                   Return
                                                 EndIf
                                             
                                             If (ReadGline = PInput) 
                                              ;name in list is name to kick so don`t add to new list.
                                             Else
                                               If Not (ReadGline = "")
                                                 WriteLine(TempCheck, ReadGline)
                                               EndIf
                                             EndIf
                                                                                         
                                         CloseFile(ReadGline)
                                        Until (EndFilewrite = 1)
                                               CloseFile(NameCheck)
                                               CloseFile(TempCheck)
                                               
                                            DoEvents(10)
                                          NewGname3$ = + GuildTag + ".txt"
                                          DeleteFile(NewGname3) ;delete file so it can be rewriten.
                                      
;___________________________________________________________________________________                                  
;rewrite new guild list - player that was kicked.
                                     
                                   GName$ = + GuildTag + "temp.txt" ;open temp file.
                                  NameCheck1$ = OpenFile(GName)
                                  
                                    TempFile1$ = + GuildTag + ".txt" ;make guild file.
                                    TempCheck1$ = WriteFile(TempFile1)
                                     
                                            
                                        Repeat
                                        
                                         EndFilewrite1% = Eof(NameCheck1)
                                        
                                                                          
                                            ReadGline1$ = Readline(NameCheck1)
                                             Doevents(10)
                                             
                                              WriteLine(TempCheck1, ReadGline1)
                                          
                                              CloseFile(ReadGline1)                             
                                        Until (EndFilewrite1 = 1)
                                        
                                           CloseFile(NameCheck1)
                                           CloseFile(TempCheck1)
                                           
                                        DeleteFile(+ GuildTag + "temp.txt") ;delete file so it can be rewriten.
                                        CloseDialog(Player, ChatBox)
                                       
                                         ChatBox = OpenDialog(Player, 0, "")
                                         DialogOutPut(Player, ChatBox, "You have removed " + PInput + " from your guild")
                                         DialogInput(Player, ChatBox, "Close")
                                         CloseDialog(Player, ChatBox) 
                                
                                
                                            KickedPlayer$ = FindActor(PInput, 1)
                                            
                                            IsOnline% = PlayerInGame(KickedPlayer)
                                                
                                                If (IsOnline = 1) ;player online tell them they were kicked from the guild.
                                                  ChatBox = OpenDialog(KickedPlayer, 0, "")
                                                  DialogOutPut(KickedPlayer, Chatbox, "You have been kicked from " + GuildTag + " guild")
                                                  SetTag(KickedPlayer, "") ;take tag from player
                                                  DialogInput(KickedPlayer, ChatBox, "Close")
                                                  CloseDialog(KickedPlayer, ChatBox)
                                                  
                                                  Return
                                                EndIf
                                                
                                          SetTag(KickedPlayer, "") ;take tag from player
                               ; Closedialog(Player, ChatBox)
                                                  

                             EndIf 
                           ; EndFile = 0
                           

                              EndIf ;end master option kick player
                        If (EndFile = 1)
                             ;Player not found  
                             CloseDialog(Player, ChatBox)
                             ChatBox = OpenDialog(Player, 0)
                             DialogOutput(Player, Chatbox, "Player not in guild, would you like to re-enter the name?")
                             Poption2% = DialogInput(Player, Chatbox, "Close,Try again")
                             
                               If (Poption2 = 1) ;close dialog player does not want to try again.
                                CloseDialog(Player, ChatBox)
                                StopRe1% = 1
                                CloseFile(Readname)
                                CloseFile(NameCheck)
                                Return
                               EndIf

                                    If (Poption2 = 2) ;set so try again will reopen dialog
                                       NewDialog% = 1
                               
                                    EndIf
                                
                         EndIf       
                            
                       Until (StopRe1% = 1)
                       
                       
      ;Endif  ;end count name amount
                      
               ;------------------------------------------
                  CoutNames% = 0
                  CloseDialog(Player, Chatbox)
                  ChatBox = OpenDialog(Player, Target, "Guild Info") 
                  
    
 
                   
  EndIf  ;end guild master options  
           
            If (GuildMaster = 0)
               ;non guild master options.

                Poption% = DialogInput(Player, ChatBox, "Close,Next")
                   If (Poption = 1) ;close search
                     CloseDialog(Player, Chatbox)
                     StopRe% = 1  
                     Return
                   EndIf

        
                   CoutNames% = 0
                  CloseDialog(Player, Chatbox)
                  ChatBox = OpenDialog(Player, Target, "Guild Info")              
               EndIf          
            EndIf
            
       ;  DialogInput(Player, ChatBox, "Close")
   
       
 
        Until (StopRe = 1)
        
          Doevents(10)

          CoutNames% = 0
          CloseFile(Readname)
          CloseFile(NameCheck)
        
           CloseDialog(Player, ChatBox)

   
         
 ElseIf (POption = 3) ; Search master guild list
 
                   CloseDialog(Player, ChatBox)
                  ChatBox = OpenDialog(Player, Target, "Guild Check")
                    ;give more guild options for player
                        DialogOutPut(Player, ChatBox, "Choose an option")
                        GuildOption% = DialogInput(Player, ChatBox, "Look at guilds at war,Look at guild alliances,Search guilds,Remove alliance or war with guild,Change to Rep/Guild tag,Close")
                            
                               If (GuildOption = 6) ;close
                                CloseDialog(Player, ChatBox)
                                Return                               
                               EndIf                            
                                    
                                
                                If (GuildOption = 5) ;change guild tag to rep tag or vice versa
                                    CloseDialog(Player, ChatBox)
                                    ChatBox = OpenDialog(Player, Target, "Guild Tag Option")
                                    CurrTag% = Tag(Player)
                                    PName$ = Name(Player)
                                     ; If (CurrTag = GuildTag) ;player has guild tag on.
                                       TagOption% = Split(ActorGlobal(Player, 3), 16, "|")  
                                       
                                        If (TagOption = 1)
                                            DialogOutPut(Player, ChatBox, "You have your guild tag, being displayed. Would you like to show your rep tag instead?")
                                            POption% = DialogInput(Player, ChatBox, "Yes,No")
                                                
                                                If (POption = 2) ;close
                                                CloseDialog(Player, ChatBox)
                                                Return
                                                EndIf
                                                
                                            If (POption = 1)
                                             CloseDialog(Player, ChatBox)
                                                SetTag(Player, "")
                                                DoEvents(1000)
                                                
                                                 fname$ = "PlayerReptag." + PName ;open player rep file and restore tag
                                                 
                                                      FHandle$ = OpenFile(fname) 
                                                          If (FHandle = 0) 
                                                            Return 
                                                          EndIf 
                                                         
                                                               If (EoF(FHandle)) 
                                                                CloseFile(FHandle) 
                                                                Return 
                                                               EndIf 
                                                               
                                                                PTag$ = ReadString(FHandle) 
                                                              If (Ptag = "") 
                                                                 CloseFile(FHandle) 
                                                                 Return 
                                                              EndIf
                                                              MyTag$ = ReadString(FHandle) 
                                                              
                                                                 CloseFile(FHandle)                                               
                                                
                                                SetTag(Player, MyTag) ;set rep tag
                                                OutPut(Player, "Rep tag " + MyTag + " has been restored.")
                                              
                                     ;set teag options
                                            HealthStat% = Split(ActorGlobal(Player, 3), 1, "|")
                                            ManaStat% = Split(ActorGlobal(Player, 3), 2, "|")
                                            StrStat% = Split(ActorGlobal(Player, 3), 3, "|")
                                            TouStat% = Split(ActorGlobal(Player, 3), 4, "|")
                                            DefStat% = Split(ActorGlobal(Player, 3), 5, "|")
                                            AgiStat% = Split(ActorGlobal(Player, 3), 6, "|")
                                            WizStat% = Split(ActorGlobal(Player, 3), 7, "|")
                                            StatsCurr% = Split(ActorGlobal(Player, 3), 8, "|")
                                            StBak% = Split(ActorGlobal(Player, 3), 9, "|")
                                            RepCurr% = Split(ActorGlobal(Player, 3), 10, "|")     ;player rep
                                            Gamble% = Split(ActorGlobal(Player, 3), 11, "|")      ;used in gambling
                                            ClassStored% = Split(ActorGlobal(Player, 3), 12, "|") ;stores melee, ranging and magic
                                            InOutCombat% = Split(ActorGlobal(Player, 3), 13, "|")  ;use in tracker in and out of combat
                                            ;extra delimters for things that mybe needed later.
                                            Extra1% = Split(ActorGlobal(Player, 3), 14, "|")
                                            Extra2$ = GuildTag
                                            Extra3% = 0 
                                            Extra4% = Split(ActorGlobal(Player, 3), 17, "|")
                                            Extra5% = Split(ActorGlobal(Player, 3), 18, "|")
                                            Extra6% = Split(ActorGlobal(Player, 3), 19, "|")
                                            Extra7% = Split(ActorGlobal(Player, 3), 20, "|")
                                            Extra8% = Split(ActorGlobal(Player, 3), 21, "|")
                                                
                                                
                                                    OtherThingsToStore$ = HealthStat + "|" + ManaStat + "|" + StrStat + "|" + TouStat + "|" +  DefStat + "|" + AgiStat + "|" + WizStat + "|" + StatsCurr + "|" + StBak + "|" + RepCurr + "|" + Gamble + "|" + ClassStored + "|" + InOutCombat + "|" + Extra1 + "|" + Extra2 + "|" + Extra3 + "|" + Extra4 + "|" + Extra5 + "|" + Extra6 + "|" + Extra7 + "|" + Extra8

                                                    SetActorGlobal(Player, 3, OtherThingsToStore) ;set dilimiter to actor global 2 
                                                Return
                                            EndIf
                                            
                                        
                                        Else ;set guild tag
                                        CloseDialog(Player, ChatBox)
                                        ChatBox = OpenDialog(Player, Target, "Guild Tag Option")
                                        DialogOutPut(Player, Chatbox, "You have your rep tag, being displayed. Would you like to show your guild tag?")
                                              POption% = DialogInput(Player, ChatBox, "Yes,No")
                                                
                                                If (POption = 2) ;close
                                                    CloseDialog(Player, ChatBox)
                                                    Return
                                                EndIf
                                       
                                       
                                            If (POption = 1) ;Change player tag to guild tag.
                                              CloseDialog(Player, ChatBox)
                                                SetTag(Player, "")
                                                DoEvents(1000)
                                                SetTag(Player, GuildTag)
                                                OutPut(Player, "guild tag " + GuildTag + " has been restored.")
                                                
                                           ;set teag options
                                            HealthStat% = Split(ActorGlobal(Player, 3), 1, "|")
                                            ManaStat% = Split(ActorGlobal(Player, 3), 2, "|")
                                            StrStat% = Split(ActorGlobal(Player, 3), 3, "|")
                                            TouStat% = Split(ActorGlobal(Player, 3), 4, "|")
                                            DefStat% = Split(ActorGlobal(Player, 3), 5, "|")
                                            AgiStat% = Split(ActorGlobal(Player, 3), 6, "|")
                                            WizStat% = Split(ActorGlobal(Player, 3), 7, "|")
                                            StatsCurr% = Split(ActorGlobal(Player, 3), 8, "|")
                                            StBak% = Split(ActorGlobal(Player, 3), 9, "|")
                                            RepCurr% = Split(ActorGlobal(Player, 3), 10, "|")     ;player rep
                                            Gamble% = Split(ActorGlobal(Player, 3), 11, "|")      ;used in gambling
                                            ClassStored% = Split(ActorGlobal(Player, 3), 12, "|") ;stores melee, ranging and magic
                                            InOutCombat% = Split(ActorGlobal(Player, 3), 13, "|")  ;use in tracker in and out of combat
                                            ;extra delimters for things that mybe needed later.
                                            Extra1% = Split(ActorGlobal(Player, 3), 14, "|")
                                            Extra2$ = GuildTag
                                            Extra3% = 1
                                            Extra4% = Split(ActorGlobal(Player, 3), 17, "|")
                                            Extra5% = Split(ActorGlobal(Player, 3), 18, "|")
                                            Extra6% = Split(ActorGlobal(Player, 3), 19, "|")
                                            Extra7% = Split(ActorGlobal(Player, 3), 20, "|")
                                            Extra8% = Split(ActorGlobal(Player, 3), 21, "|")
                                            
                                                OtherThingsToStore$ = HealthStat + "|" + ManaStat + "|" + StrStat + "|" + TouStat + "|" +  DefStat + "|" + AgiStat + "|" + WizStat + "|" + StatsCurr + "|" + StBak + "|" + RepCurr + "|" + Gamble + "|" + ClassStored + "|" + InOutCombat + "|" + Extra1 + "|" + Extra2 + "|" + Extra3 + "|" + Extra4 + "|" + Extra5 + "|" + Extra6 + "|" + Extra7 + "|" + Extra8

                                                SetActorGlobal(Player, 3, OtherThingsToStore) ;set dilimiter to actor global 2 
                                               
                                                CloseDialog(Player, ChatBox)

                                                Return
                                                
                                            EndIf                                         
                                       
                                        EndIf                                                          
        
                                 EndIf
                  ;-----------------------------------------------------------------
                  ;Remove alliance or war with guild.
                  ;Will use a thread execute instand of adding more to this part of the script
                  ;executeing to function RemoveWarAlli
                  
                   If (GuildOption = 4)
                     CloseDialog(Player, ChatBox)
                     ThreadExecute("GuildInfo", "RemoveWarAlli", Player, Target, 0)  
                     Return 
                   EndIf
                  ;end remove guild alliance or war.
                ;-----------------------------------------------------------------   
                         
                                    
                            If (GuildOption = 1) ;Look at guilds at war
                              GuildWarList$ = "Guild War List.txt"
                              GuildWarRead$ = OpenFile(GuildWarList)
                              
                                CloseDialog(Player, ChatBox)
                                ChatBox = OpenDialog(Player, Target, "Guild Check")
                              
                                 Repeat
                                      ReadWarFile1$ = ReadLine(GuildWarRead)
                                      ReadWarFile$ = ReadWarFile1
                                        
                                        CloseFile(ReadWarFile1)
                                        
                                        If (ReadWarFile = "")
                                          CloseDialog(Player, ChatBox)
                                          ChatBox = OpenDialog(Player, Target, "Guild Check")
                                          DialogOutPut(Player, ChatBox, "There is not any guilds at war right now.")
                                          DialogInput(Player, ChatBox, "Close")
                                          CloseDialog(Player, ChatBox)
                                          CloseFile(GuildWarRead)
                                          EndFile10% = 1
                                         Return
                                        EndIf
                             
                                   EndFile10% = Eof(GuildWarRead)
                                   
                                     DialogOutPut(Player, ChatBox, + ReadWarFile, 200, 45, 100)
                                     GOption% = DialogInput(Player, ChatBox, "Next,Close")
                                     
                                        If (GOption = 2) ;close
                                         CloseDialog(Player, ChatBox)
                                         CloseFile(GuildWarRead)
                                         Return
                                        EndIf
                                        
                                   CloseDialog(Player, ChatBox)
                                   ChatBox = OpenDialog(Player, Target, "Guild Check")
                                   
                                 Until (EndFile10 = 1)
                                   CloseFile(GuildWarRead)
                                   DialogOutPut(Player, ChatBox, "There is no more guilds at war to display.")
                                   DialogInput(Player, ChatBox, "Close")
                                 
                                 CloseDialog(Player, ChatBox)
                                 Return
                                 
                            EndIf ;End Look at guilds at war
                            
                            
                       
                              If (GuildOption = 2) ;Look at guild alliances
                               GuildAliName$ = "Guild Alliance List.txt"
                               GuildAliRead$ = OpenFile(GuildAliName)
                              
                                CloseDialog(Player, ChatBox)
                                ChatBox = OpenDialog(Player, Target, "Guild Check")
                              
                                 Repeat
                                      ReadWarFile1$ = ReadLine(GuildAliRead)
                                      ReadWarFile$ = ReadWarFile1
                                        
                                        CloseFile(ReadWarFile1)
                                        
                                        If (ReadWarFile = "")
                                          CloseDialog(Player, ChatBox)
                                          ChatBox = OpenDialog(Player, Target, "Guild Check")
                                          DialogOutPut(Player, ChatBox, "There is no guilds that have any alliances.")
                                          DialogInput(Player, ChatBox, "Close")
                                          CloseDialog(Player, ChatBox)
                                          CloseFile(GuildAliRead)
                                          EndFile10% = 1
                                         Return
                                        EndIf
                             
                                   EndFile10% = Eof(GuildAliRead)
                                   
                                     DialogOutPut(Player, ChatBox, + ReadWarFile, 200, 45, 100)
                                     GOption% = DialogInput(player, ChatBox, "Next,Close")
                                     
                                        If (GOption = 2) ;close
                                         CloseDialog(Player, ChatBox)
                                         CloseFile(GuildAliRead)
                                         Return
                                        EndIf
                                        
                                   CloseDialog(Player, ChatBox)
                                   ChatBox = OpenDialog(Player, Target, "Guild Check")
                                   
                                 Until (EndFile10 = 1)
                                   CloseFile(GuildAliRead)
                                   DialogOutPut(Player, ChatBox, "There is no more guild alliances to display.")
                                   DialogInput(Player, ChatBox, "Close")
                                 
                                   CloseDialog(Player, ChatBox)
                                 Return
                                 
                             
                              EndIf ;end Look at guild alliances

;contiune with searching guild names.

       MasterGList$ = "Master Guild List.txt"
       MasterGList1$ = OpenFile(MasterGList)  
 
 ;There should not have to be a if file check since player would not be able to access this if there was no guilds.

        CloseDialog(Player, ChatBox)
        ChatBox = OpenDialog(Player, 0, "Search Guild")
        GuildCount% = 0
        
         
         Repeat
          GuildCount% = GuildCount + 1
         EndFile% = Eof(MasterGList1)
         ReadGname1$ = ReadLine(MasterGList1)
         ReadGname$ = ReadGname1
       
          CloseFile(ReadGname1)
      
               CloseDialog(Player, ChatBox)
              ChatBox = OpenDialog(Player, 0, "Search Guild")
     
                 DialogOutPut(Player, ChatBox, + ReadGname)
         
                If Not (ReadGname = "")
                  POption% = DialogInput(Player, ChatBox, "Close,Next,Input Guild Name")
               Else
                   DialogOutPut(Player, ChatBox, "End of guild list")
                   DialogInput(Player, ChatBox, "Close")
                   CloseDialog(Player, ChatBox)
                   CloseFile(MasterGList1)
                  Return
               EndIf     
                  

                  
                  If (POption = 1) ;Close
                   CloseDialog(Player, ChatBox)
                   EndFile% = 1
                   CloseFile(MasterGList1)
                   Return 
                  EndIf
                  
                    If (POption = 2) ;next                    
                        CloseDialog(Player, ChatBox)
                        ChatBox = OpenDialog(Player, 0, "Search Guild")
                    EndIf
                  
                  
                  
                  If (POption = 3) ;Input Guild Name
                                
                  
                   DialogOutPut(Player, ChatBox, "Last guild name checked " + ReadGname)
                   DialogOutPut(Player, ChatBox, "Enter guild name, for more options.")
                    PInput$ = Input(Player, "Guild Name", "", 0)
                    
                        MasterGList3$ = "Master Guild List.txt"
                        MasterGList2$ = OpenFile(MasterGList3) 
                  
                   
                            Repeat
                             DoEvents(10)
                             ReadGuild$ = ReadLine(MasterGList2)
                             CheckGuildName$ = ReadGuild
                        
                             CloseFile(ReadGuild)     


                               If (EndFile = 1)
                                   OutPut(Player, "Name not Found")
                                   CloseDialog(Player, ChatBox)
                                   CloseFile(MasterGList2)
                                   CloseFile(MasterGList1)
                                   Return
                                EndIf

                          
                              If (PInput = CheckGuildName) ;guild name found
                               EndFile1% = 1                                                         
                              EndIf 
                                                                
                             EndFile% = Eof(MasterGList2) ;at end of file end repeat.
                              
                            Until (EndFile1 = 1)
                  
                            CloseFile(MasterGList2)
                            CloseFile(MasterGList1)
                                   
                        CloseDialog(Player, ChatBox)
                        ChatBox = OpenDialog(Player, Target, "Guild Check")   
                        DialogOutPut(Player, ChatBox, + CheckGuildName + " Guild found what would you like to do?")     
                        GuildOption% = DialogInput(Player, ChatBox, "Rage war on guild,Make Aliance with guild,Close")            
;___________________________________________________________________________________
 ;___________________________________________________________________________________
 ;___________________________________________________________________________________
 ;_______________________Rage war on guild___________________________________________
 ;___________________________________________________________________________________
                     
                             If (GuildOption = 3) ;close 
                             CloseDialog(Player, ChatBox)
                             Return
                            EndIf
                  
                   If (GuildOption = 1) ;rage war on inputed guild
                  
                       If (PInput = GuildTag) 
                    ;if input name is same as guild tag tell player they cant rage war on there own guild.
                        OutPut(Player, "You can not rage war against your own guild!!", 255, 135, 45)
                        CloseDialog(Player, ChatBox)
                       Return
                       EndIf                                            
                           
;______________________________________________________________
       ;Check if guild has an alliance with input guild before raging war.                     
                           
                     GuildAliName$ = "Guild Alliance List.txt"  ;guild leader that starts ali guild tag
                     GuildAliNameCheck$ = OpenFile(GuildAliName)
                      
                          ;Check if guild is at war already or not. If not then continue script and set war.
                            CheckHasAli$ = + GuildTag + " is allied with " + PInput
                            
                               Repeat
                               
                                DoEvents(10)
                                 ReadAliLine1$ = ReadLine(GuildAliNameCheck)
                                 ReadAliLine$ = ReadAliLine1
                                  CloseFile(ReadAliLine1)
                                                                 
                                   If (ReadAliLine = CheckHasAli)
                                    OutPut(Player, "You can not make an alliance with a guild that you are at war with.")
                                    Endfile3% = 1
                                    CloseFile(GuildAliNameCheck)
                                    CloseDialog(Player, ChatBox)
                                    Return
                                   EndIf
                                 
                                Endfile3% = Eof(GuildAliNameCheck)
                               
                               Until (Endfile3 = 1)
                               
                         CloseFile(GuildAliNameCheck)
                         
                      GuildAliName$ = "Guild Alliance List.txt"
                      GuildAliNameCheck$ = OpenFile(GuildAliName)
                         
                         ;Check name reversed if guild is already an ali.
                         
                        Checkotherway$ = + PInput + " is allied with " + GuildTag
                        
                             Repeat
                                DoEvents(10)
                                 ReadAliLine1$ = ReadLine(GuildAliNameCheck)
                                 ReadAliLine$ = ReadWarLine1
                                  CloseFile(ReadAliLine1)
                                 
                                  
                                   If (ReadAliLine = Checkotherway)
                                    OutPut(Player, "You can not make an alliance with a guild that you are at war with.")
                                    Endfile3% = 1
                                    CloseFile(GuildAliNameCheck)
                                    CloseDialog(Player, ChatBox)
                                    Return
                                   EndIf
                                 
                                Endfile3% = Eof(GuildAliNameCheck)
                                
                              Until (Endfile3 = 1)
                        
                          CloseFile(GuildAliNameCheck)
                      
                           
                           ;End check if guild is in alliance.
;_______________________________________________________________________                      
                           
           ;need to close and reopen file so it starts at first line again.    
                     GuildWarList$ = "Guild War List.txt" 
                     GuildWarList1$ = OpenFile(GuildWarList)
                        
                         ;Check if guild is at war already or not. If not then continue script and set war.
                            CheckAtWar$ = + PInput + " at war with " + GuildTag
                            
                        
                               Repeat
                               
                                DoEvents(10)
                                 ReadWarLine2$ = ReadLine(GuildWarList1)
                                 ReadWarLine$ = ReadWarLine2
                                  CloseFile(ReadWarLine)
                                                                 
                                   If (ReadWarLine = CheckAtWar)
                                    OutPut(Player, "You are already at war with that guild.")
                                    Endfile3% = 1
                                    CloseFile(GuildWarList1)
                                    CloseDialog(Player, ChatBox)
                                    Return
                                   EndIf
                                 
                                Endfile3% = Eof(GuildWarList1)
                               
                               Until (Endfile3 = 1)
                               
                         CloseFile(GuildWarList1)
                         
                     GuildWarList$ = "Guild War List.txt" 
                     GuildWarList1$ = OpenFile(GuildWarList)
                         
                         ;Check name reversed if guild is already at war.
                         
                        Checkotherway$ = + GuildTag + " at war with " + PInput
                        
                             Repeat
                                DoEvents(10)
                                 ReadWarLine13$ = ReadLine(GuildWarList1)
                                 ReadWarLine$ = ReadWarLine13
                                  CloseFile(ReadWarLine)
                                  
                                  OutPut(Player, "Name checked 2 " + ReadWarLine)
                                  
                                   If (ReadWarLine = Checkotherway)
                                    OutPut(Player, "You are already at war with that guild.")
                                    Endfile3% = 1
                                    CloseFile(GuildWarList1)
                                    CloseDialog(Player, ChatBox)
                                    Return
                                   EndIf
                                 
                                Endfile3% = Eof(GuildWarList1)
                                
                              Until (Endfile3 = 1)
                        
                          CloseFile(GuildWarList1)
                          
                             GuildWarList$ = "Guild War List.txt" 
                             GuildWarList1$ = OpenFile(GuildWarList)
                             
                        If (GuildWarList1 = 0) ;make master guild war list
                        
                          MakeGWarFile$ = WriteFile(GuildWarList)
                          WriteLine(MakeGWarFile, + PInput + " at war with " + GuildTag)
                          CloseFile(MakeGWarFile)
                         
                         
                        Else ;guild war list made add to it.
                          
                         ;Add rage guild to next line.
                         
                              Repeat
                                  DoEvents(10)
                                  NextLineRead$ = ReadLine(GuildWarList1)
                                 
                                  Endfile2% = Eof(GuildWarList1)
                                  
                                    If (Endfile2 = 1) ;write next line
                                       WriteLine(GuildWarList1, + PInput + " at war with " + GuildTag)
                                       CloseFile(MakeGWarFile)
                                    EndIf
                                  
                              Until (Endfile2 = 1)
                        EndIf
                         CloseFile(GuildWarList1) ;close file that was opened above.
                         
                        ;Tell guild leader they have raged war on said guild.
                        
                          CloseDialog(Player, ChatBox)
                          ChatBox = OpenDialog(Player, Target, "Guild War")
                          DialogOutPut(Player, ChatBox, "You have raged war on " + PInput + " guild.") 
                          DialogInput(Player, ChatBox, "Close")
                          CloseDialog(Player, ChatBox)
                          
                          
                          ;Tell players in guild that started the war who they are at war with.
                          
                                                
                                Guildname$ = + GuildTag + ".txt"  ;guild leader that starts war guild tag
                                GuildNameCheck$ = OpenFile(Guildname) ;guild leader that starts war guild tag
                         
                                  Repeat
                                    DoEvents(10)
                                      MainGuildRead1$ = ReadLine(GuildNameCheck)
                                     
                                       MainGuildRead$ = MainGuildRead1
                                                                              
                                        CloseFile(MainGuildRead1) ;close read line so no memory leaks happen
                                        
                                           WarnPlayer$ = FindActor(MainGuildRead, 1)
          
                                             IsOnline% = PlayerInGame(WarnPlayer)
                                                
                                                If (IsOnline = 1) ;player online tell them they were kicked from the guild.
                                                   OutPut(WarnPlayer, "Your guild is now at war with " +  PInput)                  
                                                EndIf
                                  
                                        
                                  
                                    EndFile1% = Eof(GuildNameCheck)
                          
                                   Until (EndFile1 = 1) 
                                     CloseFile(GuildNameCheck)
                         
                                  
                                  
                                ;tell all players in guild to rage war on who they are at war with. 
                                    ToWarGuildname$ = + PInput + ".txt" ;at war guild name
                                    ToWarGuildNameCheck$ = OpenFile(ToWarGuildname) ;at war guild name
                                    
                                            Repeat
                                              DoEvents(10)
                                                AtWarGuild1$ = ReadLine(ToWarGuildNameCheck)
                                                AtWarGuild$ = AtWarGuild1
                                                
                                                 CloseFile(AtWarGuild1) ;close read line so no memory leaks happen
                          
                                                  WarnPlayer$ = FindActor(AtWarGuild, 1)
                                             
                                                 IsOnline% = PlayerInGame(WarnPlayer)
                                                
                                                If (IsOnline = 1) ;player online tell them they were kicked from the guild.
                                                   OutPut(WarnPlayer, "Your guild is now at war with " +  GuildTag)               
                                                EndIf
                          
                                                EndFile1% = Eof(ToWarGuildNameCheck)
                                                
                                            Until (EndFile1 = 1) 
                                            
                                            CloseFile(ToWarGuildNameCheck)
                                        return ;need return or server will crash
                   EndIf ;end rage war option


;________________________________________________________________________________
 ;________________________________________________________________________________
 
                     If (GuildOption = 2) ;Make alliance with guild
                      CloseDialog(Player, ChatBox)
                      
                    If (PInput = GuildTag) 
                    ;if input name is same as guild tag tell player they cant make an alliance with there own guild.
                        OutPut(Player, "You can not make an alliance with your own guild!!", 255, 135, 45)
                        CloseDialog(Player, ChatBox)
                       Return
                    EndIf 
                      
               
                      GuildAliName$ = "Guild Alliance List.txt"  ;guild leader that starts ali guild tag
                     GuildAliNameCheck$ = OpenFile(GuildAliName)
                      
                          ;Check if guild is at war already or not. If not then continue script and set war.
                            CheckHasAli$ = + GuildTag + " is allied with " + PInput
                            
                               Repeat
                               
                                DoEvents(10)
                                 ReadAliLine1$ = ReadLine(GuildAliNameCheck)
                                 ReadAliLine$ = ReadAliLine1
                                  CloseFile(ReadAliLine1)
                                                                 
                                   If (ReadAliLine = CheckHasAli)
                                    OutPut(Player, "You have an aliance with that guild aready.")
                                    Endfile3% = 1
                                    CloseFile(GuildAliNameCheck)
                                    CloseDialog(Player, ChatBox)
                                    Return
                                   EndIf
                                 
                                Endfile3% = Eof(GuildAliNameCheck)
                               
                               Until (Endfile3 = 1)
                               
                         CloseFile(GuildAliNameCheck)
                         
                      GuildAliName$ = "Guild Alliance List.txt"
                      GuildAliNameCheck$ = OpenFile(GuildAliName)
                         
                         ;Check name reversed if guild is already an ali.
                         
                        Checkotherway$ = + PInput + " is allied with " + GuildTag
                        
                             Repeat
                                DoEvents(10)
                                 ReadAliLine1$ = ReadLine(GuildAliNameCheck)
                                 ReadAliLine$ = ReadWarLine1
                                  CloseFile(ReadAliLine1)
                                 
                                  
                                   If (ReadAliLine = Checkotherway)
                                    OutPut(Player, "You have an aliance with that guild aready.")
                                    Endfile3% = 1
                                    CloseFile(GuildAliNameCheck)
                                    CloseDialog(Player, ChatBox)
                                    Return
                                   EndIf
                                 
                                Endfile3% = Eof(GuildAliNameCheck)
                                
                              Until (Endfile3 = 1)
                        
                          CloseFile(GuildAliNameCheck)
                          
                          
;________________________________________________________________________________________                      
                 ;Check if guild is at war before making alliance.     
               
                ;need to close and reopen file so it starts at first line again.    
                     GuildWarList$ = "Guild War List.txt" 
                     GuildWarList1$ = OpenFile(GuildWarList)
                        
                         ;Check if guild is at war already or not. If not then continue script and set war.
                            CheckAtWar$ = + PInput + " at war with " + GuildTag
                            
                        
                               Repeat
                               
                                DoEvents(10)
                                 ReadWarLine14$ = ReadLine(GuildWarList1)
                                 ReadWarLine$ = ReadWarLine14
                                  CloseFile(ReadWarLine)
                                                                 
                                   If (ReadWarLine = CheckAtWar)
                                    OutPut(Player, "You can not make an alliance with a guild that you are at war with.")
                                    Endfile3% = 1
                                    CloseFile(GuildWarList1)
                                    CloseDialog(Player, ChatBox)
                                   Return
                                   EndIf
                                 
                                Endfile3% = Eof(GuildWarList1)
                               
                               Until (Endfile3 = 1)
                               
                         CloseFile(GuildWarList1)
                         
                     GuildWarList$ = "Guild War List.txt" 
                     GuildWarList1$ = OpenFile(GuildWarList)
                         
                         ;Check name reversed if guild is already at war.
                         
                        Checkotherway$ = + GuildTag + " at war with " + PInput
                        
                             Repeat
                                DoEvents(10)
                                 ReadWarLine15$ = ReadLine(GuildWarList1)
                                 ReadWarLine$ = ReadWarLine15
                                  CloseFile(ReadWarLine)
                                  
                                  
                                   If (ReadWarLine = Checkotherway)
                                    OutPut(Player, "You can not make an alliance with a guild that you are at war with.")
                                    Endfile3% = 1
                                    CloseFile(GuildWarList1)
                                    CloseDialog(Player, ChatBox)
                                    Return
                                   EndIf
                                 
                                Endfile3% = Eof(GuildWarList1)
                                
                              Until (Endfile3 = 1)
                        
                          CloseFile(GuildWarList1)
           
 
                                 ;End at war check.
 ;________________________________________________________________________________________                                           
 ;________________________________________________________________________________________                
;________________________________________________________________________________________             
  
                      GuildAliName$ = "Guild Alliance List.txt"  ;guild leader that starts war guild tag
                     GuildAliNameCheck$ = OpenFile(GuildAliName)
                     
                            If (GuildAliNameCheck = 0) ;make new aliance file.
                                MakeGAliFile$ = WriteFile(GuildAliName)
                                WriteLine(MakeGAliFile, + GuildTag + " is allied with " + PInput)
                                CloseFile(MakeGAliFile)
                         
                            Else ;write to next line on ali file.
                                
                                 Repeat
                                    DoEvents(10)
                                     ReadNextLine1$ = ReadLine(GuildAliNameCheck)
                                     ReadNextLine$ = ReadNextLine1
                                     CloseFile(ReadNextLine1)
                                  
                                     EndFile2% = Eof(GuildAliNameCheck)
                                    
                                       If (EndFile2 = 1) ;write to next line.
                                         WriteLine(GuildAliNameCheck, + GuildTag + " is allied with " + PInput)
                                      
                                       EndIf
                                    
                                 Until (EndFile2 = 1)       

                                
                            EndIf
                                CloseFile(GuildAliNameCheck)
                               
                                 ChatBox = OpenDialog(Player, Target, "Guild Alliance")
                                 DialogOutPut(Player, ChatBox, "Your guild is now in an aliance with " + PInput)
                                 DialogInput(Player, ChatBox, "Close")
                                 CloseDialog(Player, ChatBox)
                               
                 ;Tell all players in guild that they are allied with inputed guild.
                          
                                                
                                Guildname$ = + GuildTag + ".txt"  ;guild leader that starts alliance tag
                                GuildNameCheck$ = OpenFile(Guildname) ;guild leader that starts alliance tag
                         
                                  Repeat
                                    DoEvents(10)
                                      MainGuildRead1$ = ReadLine(GuildNameCheck)
                                     
                                       MainGuildRead$ = MainGuildRead1
                                                                              
                                        CloseFile(MainGuildRead1) ;close read line so no memory leaks happen
                                        
                                           WarnPlayer$ = FindActor(MainGuildRead, 1)
          
                                             IsOnline% = PlayerInGame(WarnPlayer)
                                                
                                                If (IsOnline = 1) ;player online tell them they are alliaed with inputed guild.
                                                   OutPut(WarnPlayer, "Your guild is allied with " + PInput + " Guild")                  
                                                EndIf
                                  
                                        
                                  
                                    EndFile1% = Eof(GuildNameCheck)
                          
                                   Until (EndFile1 = 1) 
                                     CloseFile(GuildNameCheck)

                                  
                                ;tell all players in guild they are allied with guild. 
                                    ToAliGuildname11$ = + PInput + ".txt" ;at allied with guild
                                    ToAliGuildNameCheck$ = OpenFile(ToAliGuildname11) ;at allied with guild
                                    
                                
                                           Repeat
                                              DoEvents(10)
                                                AtWarGuild11$ = ReadLine(ToAliGuildNameCheck)
                                                AtWarGuild$ = AtWarGuild11
                              
                                                 CloseFile(AtWarGuild11) ;close read line so no memory leaks happen
                          
                                                  WarnPlayer1$ = FindActor(AtWarGuild, 1)
          
                                                  IsOnline% = PlayerInGame(WarnPlayer1)
                                                                                                
                                                If (IsOnline = 1) ;player online tell them they were kicked from the guild.
                                                   OutPut(WarnPlayer, "Your guild is allied with " +  GuildTag + " Guild")               
                                                EndIf                        
                                                
                                                EndFile1% = Eof(ToAliGuildNameCheck)                                      
                                          
                                            Until (EndFile1 = 1) 
                                         
                                           CloseFile(ToAliGuildNameCheck)                                       
                                        Return
                                    
                    EndIf ;end make aliance with guild       
                        
                  EndIf ;end input guild name                               
             
          DoEvents(10)
        Until (Endfile = 1)
        
   
 ElseIf (POption = 4) ;Help give info 
    
  CloseDialog(Player, ChatBox)
 ChatBox = OpenDialog(Player, Target, "Help")
 DialogOUtPut(Player, ChatBox, "Use Gquit to leave a guild, Makeguild to make a new guild and Guildinfo to get other guild options. Note Guild master will get more options with guildinfo")
 DialogInput(Player, ChatBox, "Close")
 CloseDialog(Player, ChatBox)

ElseIf (Poption = 5)  ;close 

     CloseDialog(Player, ChatBox)
     EndRep% = 1
ElseIf (POption = 6) ;Add Member

    Conrep% = 0
       DialogOutPut(Player, Chatbox, "Enter name of player to add to guild.")

      PInput$ = Input(Player, "Player Name", "", 0)
      
         If (PInput = PName)
            CloseDialog(Player, ChatBox)
            ChatBox = OpenDialog(Player, Target, "")
            DialogOutPut(Player, ChatBox, "You can not add your self to your own guild.")
            DialogInPut(Player, ChatBox, "Close")
            CloseDialog(Player, ChatBox)
            Conrep% = 1       
        EndIf 
       CloseDialog(Player, ChatBox)
        
 ;do repeat to search for actor.
 
  If (Conrep >= 0)

    Repeat
      
         ActorFound$ = FindActor(PInput, 1) ;find actor, to invite to guild.
        Doevents(10)
        
              If (ActorFound = 0) ;end loop if player not found
               OutPut(Player, "Actor not found")               
               PlayerFound = 1
              Conrep% = 1 
             EndIf 
             
    If (Conrep = 0) 
         IsOnline% = PlayerInGame(ActorFound) ;check if player is online before continuing.
   
         If (IsOnline = 1) ;check if player is online
          
                 If (ActorFound >= 1)
                 PlayerFound = 1  
                 ;OutPut(Player, "Found")
                EndIf  
      
         Else ;tell guild leader that player is not online.
             OutPut(Player, "Player is offline, please try again later.")       
             PlayerFound = 1  
             Return 
        EndIf
                     
   EndIf
    
      Until (PlayerFound = 1) 
     
        ;Continue to add and check if player is in guild.    
       Jointag$ = Tag(ActorFound) ;check actor tag.
       ChatBox = OpenDialog(Player, 0, "")
            
 
       If (Jointag = GuildTag)
        DialogOutPut(Player, ChatBox, + PInput + " is already in your guild.")
        DialogInput(Player, ChatBox, "Close")
        CloseDialog(Player, ChatBox)
        Conrep% = 1
        
       EndIf
    If (Conrep% = 0) ;only do this if the continue should not be set from a close dialog input
         If Not (Jointag = "") ;check if player is in a guild already if not then contnue with adding them.
          DialogOutPut(Player, ChatBox, + PInput + " is in a guild already.")
          DialogInput(Player, ChatBox, "Close")
          CloseDialog(Player, ChatBox)
           
          EndIf
          
     ChatBox1 = OpenDialog(ActorFound, 0, "Guild Invite")
    DialogOutPut(ActorFound, ChatBox1, "Join " + GuildTag + " guild?")
    CloseDialog(Player, ChatBox)
    AddOption% = DialogInput(ActorFound, ChatBox1, "No,Yes") ;open dialog to ask player if they want to join guild.
       
         If (AddOption = 1)
        
             ChatBox = OpenDialog(Player, Target, "Guild Invite") ;open new window to tell player that they have declined your guild invite.
            CloseDialog(ActorFound, ChatBox1)
            DialogOutPut(Player, ChatBox, + PInput + " has declined your guild invite.", 255, 0, 0) ;tell guild leader that there invite was declined.
            DialogInput(Player, ChatBox, "Close")
            CloseDialog(Player, ChatBox)
           
             
         EndIf
   EndIf    
       
  If (AddOption = 2)
        ;continue with adding player to guild.
        CloseDialog(ActorFound, ChatBox1)
        OutPut(ActorFound, "You have joined " + GuildTag + " Guild.") ;tell player what guild they have joined.

        SetTag(ActorFound, GuildTag) ;set player to guild tag
        
         ChatBox = OpenDialog(Player, 0, + PInput + " Accepted")
        DialogOutPut(Player, ChatBox, + PInput + " has accepted your guild invite.", 255, 0, 45) ;tell guild leader that there invite was accepted.

       
         ;-------------------------------------------------------
        ;Add player to guild list.
            
             NewGname$ = + GuildTag + ".txt" 
            NameCheck$ = OpenFile(NewGname)
        
          Repeat
             DoEvents(100)
            Readname$ = ReadLine(NameCheck) 
            
              EndFile% = Eof(NameCheck)
                        
                If (EndFile = 1) ; if end file then player is not in your guild and add them.

                 StopRe% = 1
                EndIf


           ; OutPut(Player, "Counting names")
         
          Until (StopRe = 1)
          WriteLine(NameCheck, PInput)
          CloseFile(Readname)
          CloseFile(NameCheck)
       
        ;close dialog from above.     
       DialogInput(Player, ChatBox, "Close")
       CloseDialog(Player, ChatBox)  
            
         ;-------------------------------------------------------
  EndIf
  EndIf      
 ElseIf (POption = 7) ;Disband Guild
  
  GuildTag$ = Split(ActorGlobal(Player, 3), 15, "|")
 
  CloseDialog(Player, ChatBox)
 ChatBox = OpenDialog(Player, 0, "Disband Guild")
 DialogOutPut(Player, ChatBox, "You are about to disband your guild, are you sure you want to do this?")
 DGuildOption% = DialogInput(Player, ChatBox, "No,Yes")
 
     If (DGuildOption = 1) ;player don`t want to disband
       CloseDialog(Player, ChatBox)
       ChatBox = OpenDialog(Player, 0, "Disband Guild")
       DialogOutPut(Player, ChatBox, "You have decided not to disband your guild.")
       DialogInput(Player, ChatBox, "Close")
       CloseDialog(Player, ChatBox)
    EndIf
     
  If (DGuildOption = 2)
     DisbandG% = 0
    ;continune to disband guild
     Repeat
        CloseDialog(Player, ChatBox)
       ChatBox = OpenDialog(Player, 0, "Disband Guild")
       DialogOutPut(Player, ChatBox, "Please type DISBAND to continue. Note disband must be typed in capitals.")
       DialogOUtPUt(Player, ChatBox, "You can type exit to end this disband.")
       EndDis$ = "exit"
       DisGuild$ = "DISBAND" 
         PInput$ = Input(Player, "", "", 0)
         
              If (PInput = EndDis) ;End disband.
              CloseDialog(Player, ChatBox)
              ChatBox = OpenDialog(Player, 0, "Disband Guild")
              DialogOutPut(player, ChatBox, "You have chosen not to disband this guild.", 255, 45, 56)
              DialogInput(Player, ChatBox, "Close")
              CloseDialog(Player, ChatBox)
              DisbandG% = 1
              
              EndIf
         
            If (PInput = DisGuild)    
             NewGname$ = + GuildTag + ".txt" 
             NameCheck$ = OpenFile(NewGname)
            ;Disband guild for guild master, delete guild file and remove the tag from all members.
              CloseDialog(Player, ChatBox)
                 Repeat
                   ;Go through guild list and remove tag, as well tell them them the guild was disband.
                  DisGuilddone% = Eof(NameCheck)
                  GetName$ = ReadLine(NameCheck)
                   
                   FindName$ = FindActor(GetName) ;find guild name to take tag
                   SetTag(FindName, "") ;take tag away from name in the list.
                   OutPut(FindName, + GuildTag + " guild has been disband.") ;tell every player that the guild has been disband.
                   
                   CloseFile(GetName)
                 DoEvents(15)
                 Until(DisGuilddone = 1)  
              
                  CloseFile(NameCheck) ;close guild file so it can be deleted.
                 DelGFile$ = + GuildTag + ".txt"
                 DeleteFile(DelGFile)
                 
            DisbandG% = 1
             ConDisband% = 1
           EndIf 
           
        DoEvents(50)
     Until(DisbandG = 1)
       
        If (ConDisband = 1) ;Run this since guild should be disband
         ;________________________________________________________
           ;Take guild name from master guild list.
             
             MasterGList$ = "Master Guild List.txt"
            MasterGList1$ = OpenFile(MasterGList) 
                
                MasterTemp$ = "Temp master guild.txt"
                WriteTemp$ = WriteFile(MasterTemp)   
              Repeat
                DoEvents(10)
                
                ReadGName1$ = ReadLine(MasterGList1)
                ReadGName$ = ReadGName1
                
                CloseFile(ReadGName1)
                
               If Not (ReadGName = GuildTag)
                WriteLine(WriteTemp, ReadGName)
               EndIf 
     
                 EndFile% = Eof(MasterGList1)
     
               Until (EndFile = 1)
              
               CloseFile(WriteTemp) ;close temp file.
              CloseFile(MasterGList1) ;close master list file.
              DeleteFile(MasterGList) ;deete master list file so it can be remade.
              
               
                 MasterTemp$ = "Temp master guild.txt"
                MasterGList1$ = OpenFile(MasterTemp) 
 
                     MasterGList$ = "Master Guild List.txt"
                    WriteMaster$ = WriteFile(MasterGList) 
                    
                   Repeat
                    DoEvents(10)
                    
                        ReadGName1$ = ReadLine(MasterGList1)
                        ReadGName$ = ReadGName1
                        CloseFile(ReadGName1)
                        
                            WriteLine(WriteMaster, ReadGName)
                    
              
                     EndFile1% = Eof(MasterGList1)
                   Until (EndFile1 = 1) 
                   
                   CloseFile(WriteMaster)
                   CloseFile(MasterGList1)
                   DeleteFile(MasterTemp)
                   
                                 
                  ;Set changes to delimiter
    
             HealthStat% = Split(ActorGlobal(Player, 3), 1, "|")
            ManaStat% = Split(ActorGlobal(Player, 3), 2, "|")
            StrStat% = Split(ActorGlobal(Player, 3), 3, "|")
            TouStat% = Split(ActorGlobal(Player, 3), 4, "|")
            DefStat% = Split(ActorGlobal(Player, 3), 5, "|")
            AgiStat% = Split(ActorGlobal(Player, 3), 6, "|")
            WizStat% = Split(ActorGlobal(Player, 3), 7, "|")
            StatsCurr% = Split(ActorGlobal(Player, 3), 8, "|") 
            StBak% = Split(ActorGlobal(Player, 3), 9, "|")   
            RepCurr% = Split(ActorGlobal(Player, 3), 10, "|")     ;player rep
            Gamble% = Split(ActorGlobal(Player, 3), 11, "|")      ;used in gambling
            ClassStored% = Split(ActorGlobal(Player, 3), 12, "|") ;stores melee, ranging and magic
            InOutCombat% = Split(ActorGlobal(Player, 3), 13, "|")  ;use in tracker in and out of combat
            ;extra delimters for things that mybe needed later.
            Writeguild% = 0
            WriteGuildName$ = ""
            Extra3% = Split(ActorGlobal(Player, 3), 16, "|")
            Extra4% = Split(ActorGlobal(Player, 3), 17, "|")
            Extra5% = Split(ActorGlobal(Player, 3), 18, "|")
            Extra6% = Split(ActorGlobal(Player, 3), 19, "|")
            Extra7% = Split(ActorGlobal(Player, 3), 20, "|")
            Extra8% = Split(ActorGlobal(Player, 3), 21, "|")
            
     
     OtherThingsToStore$ = HealthStat + "|" + ManaStat + "|" + StrStat + "|" + TouStat + "|" +  DefStat + "|" + AgiStat + "|" + WizStat + "|" + StatsCurr + "|" + StBak + "|" + RepCurr + "|" + Gamble + "|" + ClassStored + "|" + InOutCombat + "|" + Writeguild + "|" + WriteGuildName + "|" + Extra3 + "|" + Extra4 + "|" + Extra5 + "|" + Extra6 + "|" + Extra7 + "|" + Extra8

        SetActorGlobal(Player, 3, OtherThingsToStore) ;set dilimiter to actor global 3
                   
                   
                   
                   
               Return ;end so repeat will not work, other wize after disband it tells you to make guild before using /guildinfo     
              ;end remove name from master guild list.
        EndIf ;end ConDisband% = 1 check above
;________________________________________________________ 
                     
  EndIf
 ElseIf (POption = 8) ;set MOTD
  
 ;Guild Master set MOTD
    CloseDialog(PLayer, ChatBox)
    ChatBox = OpenDialog(Player, Target, "Set MOTD")
    DialogOutPut(Player, ChatBox, "Would you like to set the guild Message of the day?")
    MOTDOption% = DialogInPut(Player, ChatBox, "No,Yes")
    
     If (MOTDOption = 1) ;Close and dont set MOTD
      CloseDialog(Player, ChatBox)
      ChatBox = OpenDialog(Player, Target, "MOTD")
      DialogOutPut(Player, ChatBOx, "You have decided not to set/Change the MOTD")
      DialogInput(Player, ChatBox, "Close")
      CloseDialog(Player, ChatBox)
        
     EndIf
  
   ;Continue with setting MOTD
 If (MOTDOption = 2)
    Repeat 
       CloseDialog(Player, ChatBox)
      ChatBox = OpenDialog(Player, 0, "Set MOTD")
      DialogOutPut(Player, ChatBox, "Enter message to use for MOTD, will be shown in guild info option.")
    
         MOTDInput$ = Input(Player, "MOTD", "", 0)
            
          CloseDialog(Player, ChatBox)
         ChatBox = OpenDialog(Player, 0, "Set MOTD")
         
           DialogOutPut(Player, ChatBox, + MOTDInput, 230, 145, 23)
          DialogOutPut(Player, ChatBox, "")
          DialogOutPut(Player, ChatBox, "Is this ok?")
          
           MOTDCheck% = DialogInput(Player, ChatBox, "No,Yes")
          
             If (MOTDCheck = 1) ;allow rewrite of MOTD
           
             EndIf
           
            If (MOTDCheck = 2)
             MOTDOK% = 1
           EndIf
          
      Until (MOTDOK = 1)
        CloseDialog(Player, ChatBox)
        MOTDFile$ = + GuildTag + " MOTD.txt" 
        OFile$ = OpenFile(MOTDFile)

          If (OFile = 0) ;MOTD file does not exist make an new one.
            WriteMOTDFILE$ = WriteFile(MOTDFile)
            WriteLine(WriteMOTDFILE, MOTDInput)
        
               CloseFile(OFile)
              CloseFile(WriteMOTDFILE)
           Else ;file made already, delete old file and replace it.
            CloseFile(OFile)
            DeleteFile(+ GuildTag + " MOTD.txt") ;delete file so it can be remade.
            WriteMOTDFILE$ = WriteFile(MOTDFile) ;rewrite motd file
            WriteLine(WriteMOTDFILE, MOTDInput)
        
             CloseFile(WriteMOTDFILE)

           EndIf
 EndIf           
EndIf ;end main options

Until (EndRep = 1) ;this repeat to keep the dialog open is stoping the guild name list from showing multiple names.


End Function









Function RemoveWarAlli()
;Called from this script at line 399
Player = Actor()
Target = ContextActor()
GuildTag$ = Split(ActorGlobal(Player, 3), 15, "|")


ChatBox$ = OpenDialog(Player, Target, "")

DialogOutPut(Player, ChatBox, "What would you like to do?")
GOption% = DialogInput(Player, ChatBox, "Remove war with guild,Remove Alliance with guild")


;remove guild at war portion.
  If (GOption = 1) ;Remove guild at war
    CloseDialog(Player, ChatBox)
    ChatBox$ = OpenDialog(Player, Target, "")
     DialogOutPut(Player, ChatBox, "Please enter the guild name to stop war with.")
     DialogOutPut(player, ChatBox, "NOTE: type 'exit' to end")
     
        EndOption$ = "exit"
       PInput$ = Input(Player, "Guild Name", "", 0)
      
          If (PInput = EndOption)
            CloseDialog(Player, ChatBox)
            ThreadExecute("GuildInfo", "Main", Player, Target, 0) 
           Return          
         Endif
          
          ;------------------------------------------------------------------
            ;check guild list to see if guild entered is even a guild
                MasterGList$ = "Master Guild List.txt"
                CheckMGuildList$ = OpenFile(MasterGList)
               
                         Repeat
                           DoEvents(10)
                           
                                ReadGName1$ = ReadLine(CheckMGuildList)
                                ReadGName$ = ReadGName1
                                CloseFile(ReadGName1)
                           
                                  If (ReadGName = PInput) ;guild name found end repeat and continue
                                    EndFile = 1
                                  Endif
                                  
                                  
                                If (EndFile1 = 1) ; end file becouse guild name not found in list.
                                  CloseDialog(Player, ChatBox)
                                  ChatBox$ = OpenDialog(Player, Target, "")
                                  DialogOutPut(Player, ChatBox, + PInput + " is not a guild.")
                                  DialogInput(Player, ChatBox, "Close")
                                  CloseDialog(Player, ChatBox)
                                  CloseFile(CheckMGuildList)
                                  ThreadExecute("GuildInfo", "Main", Player, Target, 0) 
                                 Return
                                Endif  
                                
                          EndFile1% = Eof(CheckMGuildList) ;leave this check after above endfile1
                          
                        Until (EndFile = 1)
                      CloseFile(CheckMGuildList)
                  ;End guild name check
   ;------------------------------------------------------------------
        
       GuildWarList$ = "Guild War List.txt"
      GWarFile$ = OpenFile(GuildWarList)
      NameToCheck$ = + PInput + " at war with " + GuildTag
    
        ;Check if guild is at war before removing
       
        Repeat
         DoEvents(10)
         GReadFile1$ = ReadLine(GWarFile)
         GReadFile$ = GReadFile1
          CloseFile(GReadFile1)
          
             If (GReadFile = NameToCheck) ;if matches above found guild at war.
              EndFile1% = 1
              CloseDialog(Player, Chatbox)
            
             Endif
            
              
           If (EndFile12 = 1) ;guild at war not found.
            CloseDialog(Player, ChatBox)
            ChatBox$ = OpenDialog(Player, Target, "")
            DialogOutPut(Player, ChatBox, "Your guild is not at war with " + PInput + " guild.", 240, 178, 200)
            DialogInput(Player, ChatBox, "Close")
            CloseDialog(Player, ChatBox)
            CloseFile(GWarFile)
            EndFile1% = 1
            ThreadExecute("GuildInfo", "Main", Player, Target, 0) 
           Return
          Endif
           
           EndFile12% = Eof(GWarFile) ;leave under above check
       
        Until (EndFile1 = 1)
       CloseFile(GWarFile)
       
          ChatBox$ = OpenDialog(Player, Target, "")
         DialogOutPut(Player, Chatbox, "Are you sure you want to stop the war with " + PInput + "?")
         GOptions1% = DialogInput(Player, ChatBox, "Yes,No")
                
                 If (GOptions1 = 2) ;cancel stop war.
                   CloseDialog(Player, ChatBox)
                   ThreadExecute("GuildInfo", "Main", Player, Target, 0) 
                   Return
                 Endif
            
             
                CloseDialog(Player, ChatBox)
             If (GOptions1 = 1) ;stop war with inputed guild.
             
                   GuildWarList$ = "Guild War List.txt"
                  GWarFile$ = OpenFile(GuildWarList)
                
                     GWarTemp$ = "WarTemp.Txt"
                     WriteTemp$ = WriteFile(GWarTemp)
                     
                ;Rewrite war file - war thats stoped.
                ;writing temp file
                
                    Repeat
                     DoEvents(10)
                      ReadWarLine1$ = ReadLine(GWarFile)
                      ReadWarLine$ = ReadWarLine1
                      CloseFile(ReadWarLine1)
                
                        If (ReadWarLine = NameToCheck)
                         ;don`t write line with guild at war.
                        Else
                          WriteLine(WriteTemp, ReadWarLine)
                        Endif
                
                
                      EndFile% = Eof(GWarFile)
                    Until (Endfile = 1)
                    
                        CloseFile(GWarFile)
                        CloseFile(WriteTemp)
                        DeleteFile(GuildWarList)
                        
                      GWarTemp$ = "WarTemp.Txt"
                      GWarTemp1$ = OpenFile(GWarTemp)
                      
                        GuildWarList1$ = "Guild War List.txt"
                        GuildWarList$ = WriteFile(GuildWarList1)
             
                             Repeat
                             DoEvents(10)
                               ReadGWarName$ = ReadLine(GWarTemp1)
                               ReadGWarName1$ = ReadGWarName
                               CloseFile(ReadGWarName)
                               
                                 WriteLine(GuildWarList, ReadGWarName1)
                               
                            
                             EndFile% = Eof(GWarTemp1)
                            Until (EndFile = 1)
                            
                             CloseFile(GWarTemp1)
                             CloseFile(GuildWarList)
                             DeleteFile(GWarTemp)
 
 ;--------------------------------------------------------------------------------------                            
                  ;tell all players in both guilds that they are no longer at war
                          
                                                
                                Guildname$ = + GuildTag + ".txt"  ;guild leader that starts war guild tag
                                GuildNameCheck$ = OpenFile(Guildname) ;guild leader that starts war guild tag
                         
                                  Repeat
                                    DoEvents(10)
                                      MainGuildRead1$ = ReadLine(GuildNameCheck)
                                     
                                       MainGuildRead$ = MainGuildRead1
                                                                              
                                        CloseFile(MainGuildRead1) ;close read line so no memory leaks happen
                                        
                                           WarnPlayer$ = FindActor(MainGuildRead, 1)
          
                                             IsOnline% = PlayerInGame(WarnPlayer)
                                                
                                                If (IsOnline = 1) ;player online tell them they were kicked from the guild.
                                                   OutPut(WarnPlayer, "Your guild is no longer at war with " +  PInput)                  
                                                Endif
                                                                                          
                                    EndFile1% = Eof(GuildNameCheck)
                          
                                   Until (EndFile1 = 1) 
                                     CloseFile(GuildNameCheck)
                         
                                  
                                  
                                ;tell all players in guild to rage war on who they are at war with. 
                                    ToWarGuildname$ = + PInput + ".txt" ;at war guild name
                                    ToWarGuildNameCheck$ = OpenFile(ToWarGuildname) ;at war guild name
                                    
                                            Repeat
                                              DoEvents(10)
                                                AtWarGuild1$ = ReadLine(ToWarGuildNameCheck)
                                                AtWarGuild$ = AtWarGuild1
                                                
                                                 CloseFile(AtWarGuild1) ;close read line so no memory leaks happen
                          
                                                  WarnPlayer$ = FindActor(AtWarGuild, 1)
                                             
                                                 IsOnline% = PlayerInGame(WarnPlayer)
                                                
                                                If (IsOnline = 1) ;player online tell them they were kicked from the guild.
                                                   OutPut(WarnPlayer, "Your guild is no longer at war with " +  GuildTag)               
                                                Endif
                          
                                                EndFile1% = Eof(ToWarGuildNameCheck)
                                                
                                            Until (EndFile1 = 1) 
                                            
                                            CloseFile(ToWarGuildNameCheck)
                                        return ;need return or server will crash
           
                  ;end telling all guild members they are not at war.           
;--------------------------------------------------------------------------------------                             
                               
              Endif ;end stop war option
   
   Endif ;end remove guild at war.
  
   
   ;Alliance portion
   If (GOption = 2) ; Remove Guild alliance   
         CloseDialog(Player, ChatBox)
    ChatBox$ = OpenDialog(Player, Target, "")
     DialogOutPut(Player, ChatBox, "Please enter the guild name to stop alliance with.")
     DialogOutPut(player, ChatBox, "NOTE: type 'exit' to end")
     
        EndOption$ = "exit"
       PInput$ = Input(Player, "Guild Name", "", 0)
      
          If (PInput = EndOption)
            CloseDialog(Player, ChatBox)
            ThreadExecute("GuildInfo", "Main", Player, Target, 0) 
           Return          
         Endif
          
          ;------------------------------------------------------------------
            ;check guild list to see if guild entered is even a guild
                MasterGList$ = "Master Guild List.txt"
                CheckMGuildList$ = OpenFile(MasterGList)
               
                         Repeat
                           DoEvents(10)
                           
                                ReadGName1$ = ReadLine(CheckMGuildList)
                                ReadGName$ = ReadGName1
                                CloseFile(ReadGName1)
                           
                                  If (ReadGName = PInput) ;guild name found end repeat and continue
                                    EndFile = 1
                                  Endif
                                  
                                  
                                If (EndFile1 = 1) ; end file becouse guild name not found in list.
                                  CloseDialog(Player, ChatBox)
                                  ChatBox$ = OpenDialog(Player, Target, "")
                                  DialogOutPut(Player, ChatBox, + PInput + " is not a guild.")
                                  DialogInput(Player, ChatBox, "Close")
                                  CloseDialog(Player, ChatBox)
                                  CloseFile(CheckMGuildList)
                                  ThreadExecute("GuildInfo", "Main", Player, Target, 0) 
                                 Return
                                Endif  
                                
                          EndFile1% = Eof(CheckMGuildList) ;leave this check after above endfile1
                          
                        Until (EndFile = 1)
                      CloseFile(CheckMGuildList)
                  ;End guild name check
   ;------------------------------------------------------------------
        
       GuildWarList$ = "Guild Alliance List.txt"
      GWarFile$ = OpenFile(GuildWarList)
      NameToCheck$ = + GuildTag + " is allied with " + PInput
    
        ;Check if guild is at war before removing
       
        Repeat
         DoEvents(10)
         GReadFile1$ = ReadLine(GWarFile)
         GReadFile$ = GReadFile1
          CloseFile(GReadFile1)
          
             If (GReadFile = NameToCheck) ;if matches above found guild at war.
              EndFile1% = 1
              CloseDialog(Player, Chatbox)
            
             Endif
            
              
           If (EndFile12 = 1) ;guild at war not found.
            CloseDialog(Player, ChatBox)
            ChatBox$ = OpenDialog(Player, Target, "")
            DialogOutPut(Player, ChatBox, "Your guild is not allied with " + PInput + " guild.", 240, 178, 200)
            DialogInput(Player, ChatBox, "Close")
            CloseDialog(Player, ChatBox)
            CloseFile(GWarFile)
            EndFile1% = 1
            ThreadExecute("GuildInfo", "Main", Player, Target, 0) 
           Return
          Endif
           
           EndFile12% = Eof(GWarFile) ;leave under above check
       
        Until (EndFile1 = 1)
       CloseFile(GWarFile)
       
          ChatBox$ = OpenDialog(Player, Target, "")
         DialogOutPut(Player, Chatbox, "Are you sure you want to stop the alliance with " + PInput + "?")
         GOptions1% = DialogInput(Player, ChatBox, "Yes,No")
                
                 If (GOptions1 = 2) ;cancel stop war.
                   CloseDialog(Player, ChatBox)
                   ThreadExecute("GuildInfo", "Main", Player, Target, 0) 
                   Return
                 Endif
            
             
                CloseDialog(Player, ChatBox)
             If (GOptions1 = 1) ;stop war with inputed guild.
             
                   GuildWarList$ = "Guild Alliance List.txt"
                  GWarFile$ = OpenFile(GuildWarList)
                
                     GWarTemp$ = "AlliTemp.Txt"
                     WriteTemp$ = WriteFile(GWarTemp)
                     
                ;Rewrite war file - war thats stoped.
                ;writing temp file
                
                    Repeat
                     DoEvents(10)
                      ReadWarLine1$ = ReadLine(GWarFile)
                      ReadWarLine$ = ReadWarLine1
                      CloseFile(ReadWarLine1)
                
                        If (ReadWarLine = NameToCheck)
                         ;don`t write line with guild at war.
                        Else
                          WriteLine(WriteTemp, ReadWarLine)
                        Endif
                
                
                      EndFile% = Eof(GWarFile)
                    Until (Endfile = 1)
                    
                        CloseFile(GWarFile)
                        CloseFile(WriteTemp)
                        DeleteFile(GuildWarList)
                        
                      GWarTemp$ = "AlliTemp.Txt"
                      GWarTemp1$ = OpenFile(GWarTemp)
                      
                        GuildWarList1$ = "Guild Alliance List.txt"
                        GuildWarList$ = WriteFile(GuildWarList1)
             
                             Repeat
                             DoEvents(10)
                               ReadGWarName$ = ReadLine(GWarTemp1)
                               ReadGWarName1$ = ReadGWarName
                               CloseFile(ReadGWarName)
                               
                                 WriteLine(GuildWarList, ReadGWarName1)
                               
                            
                             EndFile% = Eof(GWarTemp1)
                            Until (EndFile = 1)
                            
                             CloseFile(GWarTemp1)
                             CloseFile(GuildWarList)
                             DeleteFile(GWarTemp)
 
 ;--------------------------------------------------------------------------------------                            
                  ;tell all players in both guilds that they are no longer at war
                          
                                                
                                Guildname$ = + GuildTag + ".txt"  ;guild leader that starts war guild tag
                                GuildNameCheck$ = OpenFile(Guildname) ;guild leader that starts war guild tag
                         
                                  Repeat
                                    DoEvents(10)
                                      MainGuildRead1$ = ReadLine(GuildNameCheck)
                                     
                                       MainGuildRead$ = MainGuildRead1
                                                                              
                                        CloseFile(MainGuildRead1) ;close read line so no memory leaks happen
                                        
                                           WarnPlayer$ = FindActor(MainGuildRead, 1)
          
                                             IsOnline% = PlayerInGame(WarnPlayer)
                                                
                                                If (IsOnline = 1) ;player online tell them they were kicked from the guild.
                                                   OutPut(WarnPlayer, "Your guild is no longer allied with " +  PInput)                  
                                                Endif
                                                                                          
                                    EndFile1% = Eof(GuildNameCheck)
                          
                                   Until (EndFile1 = 1) 
                                     CloseFile(GuildNameCheck)                                        
                                  
                                ;tell all players in guild to rage war on who they are at war with. 
                                    ToWarGuildname$ = + PInput + ".txt" ;at war guild name
                                    ToWarGuildNameCheck$ = OpenFile(ToWarGuildname) ;at war guild name
                                    
                                            Repeat
                                              DoEvents(10)
                                                AtWarGuild1$ = ReadLine(ToWarGuildNameCheck)
                                                AtWarGuild$ = AtWarGuild1
                                                
                                                 CloseFile(AtWarGuild1) ;close read line so no memory leaks happen
                          
                                                  WarnPlayer$ = FindActor(AtWarGuild, 1)
                                             
                                                 IsOnline% = PlayerInGame(WarnPlayer)
                                                
                                                If (IsOnline = 1) ;player online tell them they were kicked from the guild.
                                                   OutPut(WarnPlayer, "Your guild is no longer allied with " +  GuildTag)               
                                                Endif
                          
                                                EndFile1% = Eof(ToWarGuildNameCheck)
                                                
                                            Until (EndFile1 = 1) 
                                            
                                            CloseFile(ToWarGuildNameCheck)
                                           
                                        return ;need return or server will crash
           
                  ;end telling all guild members they are not at war.           
;--------------------------------------------------------------------------------------                             
                               
              Endif ;end stop war option
   
    Endif ;end remove guild alliance


End Function
Advertisement