Make Guild Script

*Created by Taz.*

```
Using "RC_Core.rcm"
Function MakeGuild()
;Make guild with player that makes guild as guild master.
;Scripted by Dan Seguin RC Forum name Taz20241

Player = Actor()
Target = ContextActor()
Pname$ = Name(Player)
GTag% = Split(ActorGlobal(Player, 3), 14, "|")

 If (GTag = 1)
   OutPut(Player, "You are in a guild already.")
  Return
  EndIf

 ChatBox$ = OpenDialog(Player, Target, "Guild")
     DialogOutPut(Player, ChatBox, "Would you like to make a new guild?")
    POption1% = DialogInput(Player, ChatBox, "No,Yes") ;Using no first since script will just continue if yes is used.

    If (POption1 = 1) ;exit not going to make a guild.
     CloseDialog(Player, ChatBox)
     Return
     EndIf

 ;Continue to make guild
DoEvents(100)

;Add cost or item check to make guild.

Repeat ;repeat if player enter the wrong name for guild
 CloseDialog(Player, ChatBox)
 ChatBox$ = OpenDialog(Player, Target, "Guild")

      Doevents(10)

     DialogOutPut(Player, ChatBox, "Please enter a guild name.")

     PInput$ = Input(Player, "Guild name", "", 0)

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

     DialogOutput(Player, ChatBox, + PInput + " is this correct?")
    POption2% = DialogInput(Player, ChatBox, "No,Yes")

     CloseDIalog(Player, ChatBox)

    If (POption2 = 2)
        ;Check if guild name is used already.
        Guildname$ = + PInput + ".txt" ;name for guild to be used.
        NameCheck$ = OpenFile(Guildname)

            If (NameCheck = 0)
            ;Name for guild not used, allow the new guild to be made with player as leader.
            Gname = 1

            Else
             CloseDialog(Player, ChatBox)
            ChatBox$ = OpenDialog(Player, Target, "Guild")
            Dialogoutput(Player, ChatBox, "Guild name used already please pick a new name.")
            DialogInput(Player, ChatBox, "Ok")
            CloseDialog(Player, ChatBox)

            EndIf

         CloseFile(NameCheck)

     EndIf

 Until (Gname = 1)

             ;-----------------------------------------------------------------------------------------
            ;Make file with guild name text file that will store giuld names.
            ;First name in list will be guild leader.
            Guildname$ = + PInput + ".txt" ;name for guild to be used.
            GuildFile$ = WriteFile(Guildname)
            WriteLine(GuildFile, + Pname)

             ChatBox$ = OpenDialog(Player, Target, "Guild Option")
           DialogOUtpUt(Player, ChatBox, "Do you want to display your guild tag, or rep tag?")
           POption% = DialogInput(Player, ChatBox, "Show Guild Tag,Show Rep Tag")
           If (POption = 1) ;show guild tag.
            SetTag(Player, PInput) ;set guild tag for guild leader.

            EndIf
           CloseDialog(Player, ChatBox)
    ;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% = 1
            WriteGuildName$ = PInput

             If (POption = 2) ;dont show rep tag
                Extra3% = 1 ;change to 1 to not show guild tag.
            Else
                 Extra3% = Split(ActorGlobal(Player, 3), 16, "|") ;leave at 0
            EndIf

             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, "|")

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

            ;-----------------------------------------------------------------------------------------

            CloseDialog(Player, ChatBox)
            ChatBox$ = OpenDialog(Player, Target, "Guild")
            DialogOutPut(Player, ChatBox, "Guild " + PInput + " has been created. With " + Pname + " as guild master")
            DialogInput(Player, ChatBox, "Close")
            CloseDialog(Player, ChatBox)

         CloseFile(GuildFile)

        ;----------------------------------------------------------------
       ;Make master guild list, use to search guild names.
       MasterGList$ = "Master Guild List.txt"
       MasterGList1$ = OpenFile(MasterGList)

             If (MasterGList1 = 0) ;make Master guild list.
                MakeMGFile$ = WriteFile(MasterGList)
                WriteLine(MakeMGFile, + PInput)
                CloseFile(MakeMGFile)

            Else ;Master guild guild list has been made add to it.

                Repeat
                 EndFile% = Eof(MasterGList1)
                 ReadGLine$ = ReadLine(MasterGList1)
                 CloseFile(ReadGLine)
                 DoEvents(10)
                Until(EndFile = 1)

                WriteLine(MasterGList1, + PInput)

             EndIf

         CloseFile(MasterGList1)
     ;_______________________________________________
      ;Make alliance and war lists
      GuildAliName$ = "Guild Alliance List.txt"
      GuildAliName1$ = OpenFile(GuildAliName)

            If (GuildAliName1 = 0)
            MakeGAliFile$ = WriteFile(GuildAliName)
             CloseFile(MakeGAliFile)
           EndIf

             GuildWarList$ = "Guild War List.txt"
            GuildWarList1$ = OpenFile(GuildWarList)

            If (GuildWarList1 = 0)
             MakeGWarFile$ = WriteFile(GuildWarList)
             CloseFile(MakeGWarFile)
           EndIf
      ;End make alliance and war lists

      CloseFile(GuildAliName1)
     CloseFile(GuildWarList1)
     ;_______________________________________________

 End Function

```