RealmCrafter Wiki
Advertisement

Created by Tazco.

Using "RC_Core.rcm"
; By Naddaz on TAZCO

Function Main()
;Makes a petition and sends player input to a text file.
;Makes a petition list that will name evey player that has maked a petition.
;Will only add players name once to the list. 
;Gm`s the right gm rank will be able to check read and delete petitions. Only ranks can only read.
Player = Actor()
Target = ContextActor()
PName$ = Name(Player)

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

DialogOutPut(Player, ChatBox, "Would you like to make a petition that a gm could look at later?.", 230, 145, 23)
PetOption% = DialogInPut(Player, ChatBox, "Yes,No")

    If (PetOption = 1) ;Start the petition making
        CloseDialog(Player, ChatBox)
        ChatBox$ = OpenDialog(Player, Target, "Petition")


                
                    PetFile$ = OpenFile(+ PName + "s petition.txt")
                    If (PetFile = 0) ;player has a petiton opened already
                    ;do nothing since this file will be made later.
                    Else
                        CloseDialog(Player, ChatBox)
                        ChatBox$ = OpenDialog(Player, Target, "Petition")
                        DialogOutPut(Player, ChatBox, "You already have a open petition, please wait for an answer before making a new one.", 230, 145, 23)
                        DialogInput(Player, ChatBox, "Close")
                        CloseDialog(Player, ChatBox)
                        CloseFile(PetFile)
                        Return
                    Endif
                    CloseFile(PetFile)
        
         
         DialogOutPut(Player, ChatBox, "Type your petition and a gm will get back to you shortly.", 230, 145, 23)
        PetEnter$ = Input(Player, "Enter text for petition.", "", 4)
        CloseDialog(Player, ChatBox)
        ChatBox$ = OpenDialog(Player, Target, "Petition")
        DialogOutPut(Player, ChatBox, "You have entered this for your petition " + PetEnter, 230, 134, 23)
 
         
             
                 PetList$ = OpenFile("Petition List.txt")
  
          
                 If (PetList = 0) ;If there is no petition list make one.
                    PetitonList$ = WriteFile("Petition List.txt")
                    CloseFile(PetList) ;close opened petition file
                    CloseFile(PetitonList)
                    PetList$ = OpenFile("Petition List.txt")
                Endif
                
                ;Check if player name is already in the list, if so then don`t add it.
                EndRepeat% = 10
                
                ;NOTE:have repeat commented since it seems to work with out it, also
                ;if you manuly updated the text file it could through the count off since it counts empty spaces.
             Repeat
                
                  EndRepeat = Eof(PetList)
                  NameinFile$ = ReadLine(PetList)

                    If (NameinFile = Name(Player)) ;players name is in the list end repeat and close file.
                        NameMatch% = 5                     
                        Eof(PetList)
                        CloseFile(NameinFile)
                    Endif

                    Doevents(1)

                    
               Until (EndRepeat = 0)    
                

                
                
                   If (NameMatch = 5) ;player has name in the list don`t added it again
                        ;Close file since player is in list already.
                        CloseFile(PetList)
                    Else ;players name is not in the list, add it to the list.              
                        SeekFile(PetList, FileSize("Petition List.txt")) 
                        WriteLine(PetList, Name(Player)) 
                        CloseFile(PetList) ;Close Opened file above
                    Endif
    
                     PetFile$ = OpenFile(+ PName + "s petition.txt")
                   
                If (PetFile = 0) ;Make a new file if there is not one already.
                    PetFile$ = OpenFile(+ PName + "s petition.txt")
                    PPetFile$ = WriteFile(+ PName + "s petition.txt")
                    DoEvents(500) ;wait 1 sec then close files
                    CloseFile(PetFile) ;close opened petition file
                    CloseFile(PPetFile) ;close new petition file    
 
                 Endif
        
                    
                CloseFile(PetFile) ;close opened petition file
       
               POption$ = DialogInput(Player, ChatBox, "Done")
       
        
             If (POption = 1) ;Write to file and end.
                
                PetFile$ = OpenFile(+ PName + "s petition.txt")
                SeekFile(PetFile, FileSize(+ PName + "s petition.txt")) 
                WriteLine(PetFile, PetEnter) ;Write player input to a file.
                DoEvents(500)
                CloseFile(PetFile) ;close opened petition file
                CloseDialog(Player, ChatBox)
                Return        
            Endif
            
             
         
         
         DoEvents(1400)
        CloseDialog(Player, ChatBox)
    
     ElseIf (PetOption = 2) ;Close petition maker
        DoEvents(500)
        CloseDialog(Player, ChatBox)
        Return   
    EndIf
     
 End Function
Advertisement