Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Where to put this code


Zopto
 Share

Recommended Posts

```
Sub SaveGuildName(ByVal name As String)
    Dim F As Long
    Dim n As Long
        F = FreeFile
        Open App.Path & "\data\guilds\Guildlist.txt" For Append As #F
        Print #F, name; ""

        Close #F
End Sub
```
```
Function FindGuild(ByVal name As String) As Boolean
    Dim F As Long
    Dim s As String
    F = FreeFile
    Open App.Path & "\data\guilds\Guildlist.txt" For Input As #F

    Do While Not EOF(F)
        Input #F, s

        If Trim$(LCase$(s)) = Trim$(LCase$(name)) Then
            FindGuild = True
            Close #F
            Exit Function
        End If

    Loop

    Close #F
End Function
```
```
    'Check to see if guild name exists.
    If FindGuild(name) Then
        PlayerMsg Founder_Index, "That Guild name already exists!", BrightRed
        Exit Sub
    End If
```
```
    'Write to text file to save guild name.
    Call SaveGuildName(name)
```
Makes guild list if guild list is not there. This is in initserver
```
        ' Check if the master Guildlist file exists for checking duplicate names, and if it doesnt make it
    If Not FileExist("data\guilds\Guildlist.txt") Then
        F = FreeFile
        Open App.Path & "\data\guilds\Guildlist.txt" For Output As #F
        Close #F
    End If
```Before I forget I would like to thank you. It must of been frustrating trying to help me, but I feel as though I learned quite a bit.

Now I am working on it deleting out of the text file when the guild disbands.  I have a feeling the deleting will be very hard…

Stuck on the deleting part. No errors thrown, however nothing is deleted.
```
Sub DeleteGuild(ByVal name As String)
    Dim f1 As Long
    Dim f2 As Long
    Dim s As String
    Call FileCopy(App.Path & "\data\guilds\Guildlist.txt", App.Path & "\data\guilds\Guildtemp.txt")
    ' Destroy name from Guild List
    f1 = FreeFile
    Open App.Path & "\data\guilds\Guildtemp.txt" For Input As #f1
    f2 = FreeFile
    Open App.Path & "\data\guilds\Guildlist.txt" For Output As #f2

    Do While Not EOF(f1)
        Input #f1, s

        If Trim$(LCase$(s)) <> Trim$(LCase$(name)) Then
            Print #f2, s
        End If

    Loop

    Close #f1
    Close #f2
    Call Kill(App.Path & "\data\guilds\Guildtemp.txt")
End Sub
```

[/quote
where to i  put this code can any one make me a tutorial how to i use it… tnx?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...