Ruins of Hell Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> ```> Guild_Name As String * 20> ```You tell VB its a 20 character string (text) so I would imagine the extra spaces you see are 20 - guildname.Exactly, the original tutorial does not account for limited size names and instead just prints the name. Since it's * 20, it is padded with spaces (to make it 20 characters long). To counter this, you can use the Trim$ function. You'll note this is the case in many functions already in Eclipse (like GetPlayerName). So here's a quick little fix you can add.Server-side:Find:```Buffer.WriteString "[" & GuildData(GuildSlot).Guild_Name & "]"```and replace it with:```Buffer.WriteString "[" & Trim$(GuildData(GuildSlot).Guild_Name) & "]"``` Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 This is what I have currently. I have only two problems I think.```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 #FEnd Function```1st I don't know what the guild names are. So I don't know what to have to check``` If Trim$(LCase$(s)) = Trim$(LCase$(Name)) Then```I am also not quite sure where to put the call functions. Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 Whenever someone makes a guild, you need to call that sub, if it returns True a guild with that name already exists, so send error message and cancel making the guild. If it returns true, the guild name is free. In that case you still need to add a sub to add the new guild name to the list, and then create the guild. I think that's all that needs to be done. Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> Whenever someone makes a guild, you need to call that sub, if it returns True a guild with that name already exists, so send error message and cancel making the guild. If it returns true, the guild name is free. In that case you still need to add a sub to add the new guild name to the list, and then create the guild. I think that's all that needs to be done.So this part of the code is correct?```If Trim$(LCase$(s)) = Trim$(LCase$(Name)) Then``` Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 that part of the code just compares lower case S string to lower case Name string (aka, compares namelist to new name) Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> that part of the code just compares lower case S string to lower case Name string (aka, compares namelist to new name)Ok so this function is now correct?This means I now need toPlace the locations to call itIf value is true end subIf value is false write to file and continue on guild making? Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 Yep Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> YepMy check in Public Sub MakeGuild. Ok looked at the wrong code. I think Founder_Index is wrong, but I am not sure what I need to replace it with to send a message back to the player.``` If FindGuild = True Then PlayerMsg Founder_Index, "That Guild name already exists!", BrightRed Exit Sub End If```It is just below``` GuildFileId = Find_Guild_Save GuildSlot = FindOpenGuildSlot```How does it look? Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 It would be the first thing I'd check when starting the process of guild creation, I wouldn't do stuff like finding GuildSlots or GuildFileID's first.(But Im not too familiar with the actual guild code)also, you're forgetting to save the guild name to the file when the name isn't taken yet. Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> It would be the first thing I'd check when starting the process of guild creation, I wouldn't do stuff like finding GuildSlots or GuildFileID's first.> > (But Im not too familiar with the actual guild code)That makes sense actually, moved the coding to the first thing. How about the rest of it? AlsoCould I just make it``` If FindGuild = True Then PlayerMsg Founder_Index, "That Guild name already exists!", BrightRed Exit Sub Else (write to list) End If```The problem i think with that is that If the player is already in a guild it will write to make a new guild, and then see he is in a guild and end it. Not quite sure what to do about the writing part of it. Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 You dont have to do the write to list at the Else statement. You can just do that in the final step of guild creation, when you're sure everything else is in order. For the writing part, just check the examples already in the source code for charnames. There should be a sub for it you can almost copy. Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> You dont have to do the write to list at the Else statement. You can just do that in the final step of guild creation, when you're sure everything else is in order. For the writing part, just check the examples already in the source code for charnames. There should be a sub for it you can almost copy.Ok i moved the code down below``` If Name = "" Then PlayerMsg Founder_Index, "Your guild needs a name!", BrightRed Exit Sub End If```Which is the final check it seems. I figured this way it will check to make sure they actually entered a name first.Using this sub```Sub SavePlayer(ByVal Index As Long) Dim filename As String Dim F As Long filename = App.Path & "\data\accounts\" & Trim$(Player(Index).Login) & ".bin" F = FreeFile Open filename For Binary As #F Put #F, , Player(Index) Close #FEnd Sub```Changed it to```Sub SaveGuild(ByVal Index As Long) Dim filename As String Dim F As Long filename = App.Path & "\data\guilds\Guildslist.txt" F = FreeFile Open filename For Binary As #F Put #F, , Player(Index) Close #FEnd Sub```Not sure on this part though.``` Put #F, , Player(Index)```Instead of player(Index) do I put GuildData(GuildSlot).Guild_Name = Name Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 I think you're copying the wrong sub, you got the sub that saves player account data to their own data file instead of the sub that saves all char names in 1 big text file.Actually, it's not a seperate sub, it's a little piece of code that is ran just before sub SavePlayer(). So you got pretty damn close : P.``` ' Append name to file F = FreeFile Open App.Path & "\data\accounts\charlist.txt" For Append As #F Print #F, Name Close #F``` Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> I think you're copying the wrong sub, you got the sub that saves player account data to their own data file instead of the sub that saves all char names in 1 big text file.> > Actually, it's not a seperate sub, it's a little piece of code that is ran just before sub SavePlayer(). So you got pretty damn close : P.> > ```> ' Append name to file> F = FreeFile> Open App.Path & "\data\accounts\charlist.txt" For Append As #F> Print #F, Name> Close #F> ```Bah you are right. It is the .bin file alsoCompile error Highlights Find Guild and says " Argument not optional.``` 'Check to see if guild name exists. If not Write to file If FindGuild = True Then PlayerMsg Founder_Index, "That Guild name already exists!", BrightRed Exit Sub End If``` Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 Check out your FindGuild sub and see if you can spot the mistake yourself. Let's just say you forgot to do one small thing, you'll have to check out the FindGuild sub to find out what it is, but the mistake is not actually in the FindGuild sub but instead in the part that errored. (obviously) Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> Check out your FindGuild sub and see if you can spot the mistake yourself. Let's just say you forgot to do one small thing, you'll have to check out the FindGuild sub to find out what it is, but the mistake is not actually in the FindGuild sub but instead in the part that errored. (obviously)Looking in to it now. Also new save```Sub SaveGuild(ByVal Index As Long) 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 Call SavePlayer(Index)End Sub```Still not sure what to replace saveplayer(index) with. Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 I'm not sure why you need that there? Why is it important to save the player after you've added the guild name to the guildlist? Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> I'm not sure why you need that there? Why is it important to save the player after you've added the guild name to the guildlist?I need to replace the player part, and have it save the file. I guess is what I am getting at.Also still looking for the error, am I reading it wrong? Should my if be " If false"? Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 ```Sub SaveGuild(ByVal Index As Long) 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 'Call SavePlayer(Index)End Sub```This sub looks great and should be 100% functional, I really dont understand why you'd want to call SavePlayer there. As a hint for the error, check the byvals. Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> ```> Sub SaveGuild(ByVal Index As Long)> 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> 'Call SavePlayer(Index)> End Sub> ```I don't want to save the player. I need the file to save. I don't want someone to make a guild called guildx and then the server restart. The server restarts and comes back up. The file won't be saved meaning guildx name would be available even though guildx would exist. Unless that is not how EO works?is the problem "name"? should it be index? Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 I dont think you quite understand all the code.PS: For clarities sake, I changed Byval Index into Byval Guildname, this is because Index usually refers to the player's number, and in this case you want to use SaveGuild("GuildName"), so guildname is a more logical name. It doesnt change anything, just makes more sense.Oh, and yes, name should be index, but now that index = guildname it should be guildname```Sub SaveGuild(ByVal Guildname As Long) Dim F As Long Dim n As Long F = FreeFile Open App.Path & "\data\guilds\Guildlist.txt" For Append As #F 'this opens the file Print #F, GuildName 'this adds the guild name to the file Close #F 'this closes and saves the file (100% done) 'Call SavePlayer(Index) this is pointlessEnd Sub```For your error,```Function FindGuild(ByVal Name As String) As Boolean```Stare at that line until you see why what's below doesnt work``` If FindGuild = True Then``` Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> I dont think you quite understand all the code.> > PS: For clarities sake, I changed Byval Index into Byval Guildname, this is because Index usually refers to the player's number, and in this case you want to use SaveGuild("GuildName"), so guildname is a more logical name. It doesnt change anything, just makes more sense.> > Oh, and yes, name should be index, but now that index = guildname it should be guildname> > ```> Sub SaveGuild(ByVal Guildname As Long)> Dim F As Long> Dim n As Long> F = FreeFile> Open App.Path & "\data\guilds\Guildlist.txt" For Append As #F 'this opens the file> > Print #F, GuildName 'this adds the guild name to the file> Close #F 'this closes and saves the file (100% done)> 'Call SavePlayer(Index) this is pointless> End Sub> ```> For your error,> > ```> Function FindGuild(ByVal Name As String) As Boolean> ```Stare at that line until you see why what's below doesnt work> ```> If FindGuild = True Then> ```You are correct, I did not understand the code fully. It does exactly what I wanted without adding anything.Is it because it is byval name as **String?** Should it be```Function FindGuild(ByVal Name As Boolean)```I don't really understand why it is name as string) as boolean.So here is my guess. The findguild is saving it as a stringThe if statement is looking for a boolean. So i need to convert string into boolean?I still have no idea what the bolded part is doingFunction FindGuild(ByVal Name As String) **As Boolean**Changed it to``` If FindGuild(True) Then```Works then compile error on```Call SaveGuild```Argument not optional.Looking into it now. Changed and compile worked. testing now ``` Call SaveGuild(Guildname)``` Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 To be honest you're just messing it up more.Sub SaveGuild(ByVal Guildname As Long)That means you need to call that sub by usingCall findguild(GUILDNAME)If you dont add the guild name the findguild sub wont know what its looking for. Link to comment Share on other sites More sharing options...
Snoozey Posted April 24, 2012 Share Posted April 24, 2012 @Joost:> To be honest you're just messing it up more.> Sub SaveGuild(ByVal Guildname As Long)> > That means you need to call that sub by using> Call findguild(GUILDNAME)> > If you dont add the guild name the findguild sub wont know what its looking for.Hm, The dat files are not being made, and it is not writing into the file.here is what I have.If I change true to guildname it always is in use, even if the file is empty.``` 'Check to see if guild name exists. If not Write to file If FindGuild(True) Then PlayerMsg Founder_Index, "That Guild name already exists!", BrightRed Exit Sub End If 'Write to text file to save guild name. Call SaveGuild(Guildname)``````Sub SaveGuild(ByVal Guildname As Long) 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 #FEnd 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 #FEnd Function``` Link to comment Share on other sites More sharing options...
Joost Posted April 24, 2012 Share Posted April 24, 2012 Did you add a file named Guildlist.txt in the guilds folder? Not sure if the code actually sets up the text if none if found. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now