FANDOM


Created by Taz.

Using "RC_Core.rcm"

Function Gquit()
Player = Actor()
PName$ = Name(PLayer)
PTag$ = Split(ActorGlobal(Player, 3), 15, "|") ;guild name

OUtpUt(Player, "Guild name is " + PTag)

GTag% = Split(ActorGlobal(Player, 3), 14, "|")


 If (PTag = "")
   OutPut(Player, "You are not in a guild")
   Return
  Else ;player is in guild allow them to leave.
  
     ChatBox = OpenDialog(Player, 0, "Leaving Guild") 
     DialogOutPut(Player, ChatBox, "You are going to leave " + PTag + " guild. Are you sure?")
     POption% = DialogInput(Player, ChatBox, "No,Yes")
     
       If (POption = 1) ;don`t remove player from the guild.
        CloseDialog(Player, ChatBox) 
        Return
       EndIf
       
       
        If (POption = 2) ;Take player out of guild.
        
            GMasterCheack% = 0
        
           NewGname$ = + PTag + ".txt"
           NameCheck$ = OpenFile(NewGname)

           TempFile1$ = + PTag + "temp.txt" ;make temp file.
           TempCheck$ = WriteFile(TempFile1)
                                  
               Repeat
                EndFilewrite% = Eof(NameCheck)
                                        
                ReadGline$ = Readline(NameCheck)
                Doevents(10)
                
                ;Check for guild master
                If (GMasterCheck = 0)
                 GMaster$ = ReadGline
                EndIf            
                 GuildMasterName$ = GMaster
                 GMasterCheck% = GMasterCheck + 1
                 
                   If (GuildMasterName = PName) ;tell player guild master can not remove them self.
                    DialogOutput(Player, ChatBox, "You are guild master and can not leave your own guild.")
                    DialogInput(Player, ChatBox, "Close")
                    CloseDialog(Player, ChatBox)
                    CloseFile(NameCheck)
                    CloseFile(TempCheck)
                    DeleteFile(+ PTag + "temp.txt") ;delete file so it can be rewriten.
                    Return
                   EndIf
                   
               
                          If (ReadGline = PName) 
                               ;name in list is name to kick so don`t add to new list.
                          Else
                              WriteLine(TempCheck, ReadGline)
                          EndIf
                                                                                         
                           CloseFile(ReadGline)
               Until (EndFilewrite = 1)
               
                     CloseFile(NameCheck)
                     CloseFile(TempCheck)
                                               
                       DoEvents(10)
                       NewGname3$ = + PTag + ".txt"
                       DeleteFile(NewGname3) ;delete file so it can be rewriten.
                                      
                                  
                  ;rewrite new guild list - player that was kicked.
                                     
                                  GName$ = + PTag + "temp.txt" ;open temp file.
                                  NameCheck1$ = OpenFile(GName)
                                  
                                    TempFile1$ = + PTag + ".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(+ PTag + "temp.txt") ;delete file so it can be rewriten.
                     CloseDialog(Player, ChatBox)
                                   
                  SetTag(Player, "")
                  
                  
                  
                  OutPUt(Player, "You have left " + PTag + " guild")
              
                  ;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

                  
                    MasterGuild$ = FindActor(GuildMasterName, 1)
                                            
                   IsOnline% = PlayerInGame(MasterGuild)
                                                
                         If (IsOnline = 1) ;guild master is online tell them player left guild.
                           OutPut(MasterGuild, + Pname + " has left your guild")
                            
                            Return
                         EndIf
                  
                                    
        EndIf
  EndIf

End Function