goku1993 Posted May 26, 2011 Author Share Posted May 26, 2011 Hey guys i have created a guild system based of well the source kind of searched for stuff i needed in the actual source and changed many things, anyway almost everything works fine, i can invite people,summon them well you get the idea.The only thing that's not working is leaving the guild, i was wondering do you think this should work fine to delete the name from the file because it's not deleting it.``` For i = 1 To MAX_GUILD_MEMBERS If Guild(guildNum).Member(i) = Trim$(Player(index).Name) Then Guild(guildNum).Member(i) = vbNullString 'save guild Call SaveGuild(guildNum)```if you need my guild rec```Public Type GuildRec Name As String Founder As String Member(1 To MAX_GUILD_MEMBERS) As String MemberCount As LongEnd Type```if you need the save sub(note:saved as txt right now to fix the problem after that i ll change it)```Sub SaveGuild(ByVal index As Long) Dim filename As String Dim F As Long filename = App.Path & "\data\guilds\" & Trim$(Guild(index).Name) & ".txt" F = FreeFile Open filename For Binary As #F Put #F, , Guild(index) Close #FEnd Sub```I know that the techniques i used to create the guild system could be wrong and if you have any pointers please go ahead and point me to the right direction criticism is welcome.Oh almost forgot if you need me to post another sub because there's something in the code above you aren't really understanding go ahead and ask.Thank you for your help. Link to comment Share on other sites More sharing options...
damian666 Posted May 26, 2011 Share Posted May 26, 2011 that should work just fine actually O.odid you try adding debug msg-es to it?to see what it does exactly?Dami Link to comment Share on other sites More sharing options...
goku1993 Posted May 27, 2011 Author Share Posted May 27, 2011 just found out that the guild member's name will get deleted off the list but the other names don't if they quit the guild (guild leader and members have a different section where they leave the guild in the code but both are similar and can't find the error in the member part) anyway here is the leave sub, been trying to find something wrong in there but couldn't maybe someone on here can help:```Public Sub Guild_PlayerLeave(ByVal index As Long)Dim guildNum As Long, i As Long, Name As String guildNum = Player(index).guildNum Name = Player(index).Guild Call LoadGuild(guildNum, Name) If guildNum > 0 Then ' find out how many members we have Guild_CountMembers guildNum ' make sure there's more than 0 people If Guild(guildNum).MemberCount > 0 Then ' check if leader If Guild(guildNum).Founder = Trim$(Player(index).Name) Then ' set next person down as leader For i = 1 To MAX_GUILD_MEMBERS If Not Guild(guildNum).Member(i) = vbNullString And Guild(guildNum).Member(i) <> Player(index).Name Then Guild(guildNum).Founder = Guild(guildNum).Member(i) Guild(guildNum).Member(1) = Guild(guildNum).Member(i) 'GuildMsg guildNum, GetPlayerName(i) & " is now the guild leader.", BrightBlue Call SavePlayer(index) Call SaveGuild(guildNum) Exit For End If Next ' leave guild 'GuildMsg guildNum, GetPlayerName(index) & " has left the guild.", BrightRed ' remove from array For i = 1 To MAX_GUILD_MEMBERS If Guild(guildNum).Member(i) = Trim$(Player(index).Name) Then Guild(guildNum).Member(i) = vbNullString Call SaveGuild(guildNum) Exit For End If Next 'remove from player Player(index).guildNum = 0 Player(index).Guild = vbNullString ' save player Call SavePlayer(index) ' recount guild Guild_CountMembers guildNum ' set update to all SendGuildUpdate guildNum ' send clear to player SendGuildUpdateTo index Else ' not the leader, just leave ' GuildMsg guildNum, GetPlayerName(index) & " has left the guild.", BrightRed ' remove from array For i = 1 To MAX_GUILD_MEMBERS If Guild(guildNum).Member(i) = Trim$(Player(index).Name) Then Guild(guildNum).Member(i) = vbNullString 'save guild Call SaveGuild(guildNum) Exit For End If Next 'remove from player Player(index).guildNum = 0 Player(index).Guild = vbNullString 'save player Call SavePlayer(index) ' recount guild Guild_CountMembers guildNum ' set update to all SendGuildUpdate guildNum ' send clear to player SendGuildUpdateTo index End If Else ' find out how many members we have Guild_CountMembers guildNum ' clear out everyone's guild For i = 1 To MAX_GUILD_MEMBERS index = Guild(guildNum).Member(i) ' player exist? If Not index = vbNullString Then 'remove from player Player(index).guildNum = 0 Player(index).Guild = vbNullString ' send clear to players SendGuildUpdateTo index 'save player and guild Call SavePlayer(index) Call SaveGuild(guildNum) End If Next ' clear out the guild itself ClearGuild guildNum End If End IfEnd Sub```I don't get it why does``` For i = 1 To MAX_GUILD_MEMBERS If Not Guild(guildNum).Member(i) = vbNullString And Guild(guildNum).Member(i) <> Player(index).Name Then Guild(guildNum).Founder = Guild(guildNum).Member(i) Guild(guildNum).Member(1) = Guild(guildNum).Member(i) 'GuildMsg partyNum, GetPlayerName(i) & " is now the party leader.", BrightBlue Call SavePlayer(index) Call SaveGuild(guildNum)```Only save the member(1) in the file and not the founder??? Link to comment Share on other sites More sharing options...
goku1993 Posted May 30, 2011 Author Share Posted May 30, 2011 anyone?? Link to comment Share on other sites More sharing options...
Helladen Posted May 30, 2011 Share Posted May 30, 2011 So you basically copied the party system. I have no idea, make sure your strings are actually strings. Such as in the GuildRec Member and in the PlayerRec make sure Guild is a string.Doing things like that is not smart, you should base them off something not copy them and start editing. That's mad… Link to comment Share on other sites More sharing options...
goku1993 Posted May 30, 2011 Author Share Posted May 30, 2011 Nothing's wrong with the strings and all that already checked, just couldn't really find a better way to create the guild system… Link to comment Share on other sites More sharing options...
Helladen Posted May 30, 2011 Share Posted May 30, 2011 You must create a guild create sub to fix the issue with the founder not being saved. I'm not sure I would have to see every sub you edited to fix the bugs, sorry I couldn't be more helpful. Using the party system for a guild system is not smart. Robin coded it to be temporary data, it is not saved so it's best to just base the code in some areas with it and not copy it directly and expect it to work with a few modifcaitons. Link to comment Share on other sites More sharing options...
goku1993 Posted May 30, 2011 Author Share Posted May 30, 2011 In some parts i changed the code completely though anyway i guess I'll try to recreate something from scratch i think i might be able to do it while searching on the net for better ways. Link to comment Share on other sites More sharing options...
Helladen Posted May 30, 2011 Share Posted May 30, 2011 You shouldn't allow the founder to leave, erase the whole founder leave part and add a message exit at the very top. Have it where they promote someone else before they can leave.Also when the guild is created you probably missed the 2nd person, make sure you set all the data correctly. Link to comment Share on other sites More sharing options...
goku1993 Posted May 30, 2011 Author Share Posted May 30, 2011 Nope didn't miss the second person everything is working fine with this guild system except the leave part for everyone… 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