27-08-2008, 08:18 PM
Hello,
I've made some minor changes to hopefully fix up the code a bit. First, since we are keeping the leader separate from the members of the group, change
to
Now in the Joingroup, leavegroup, Sendgroupstats and Senddatatoparty sub, change all the for loops from
To
Now in the Leavegroup sub, add an Exit for to the for loop. We only want to assign 1 new group leader when the group leader leave the group so we need to exit after we promote 1 member to leader.
In the Cleargroup sub, add the following line after you clear the group
to denote we are 1 group less
Finally, in the CloseSocket Sub find
Below that line, add
This call the leavegroup sub to take a player out of the party when they disconnect from the server.
I think that should be everything. For the client, what Sonire made works fine. My apologies for not mentioning which module the sub are in but I'm working off of 3.07 and I've modified the code a lot so my modules might be different than yours. Just do a search of the project for whatever you can't find. The party system seems to work fine (though it's still rather useless at this point until more features are added). I may have forgotten something typing all this up so if you can't get it working, post back and I'll double check my code.
I've made some minor changes to hopefully fix up the code a bit. First, since we are keeping the leader separate from the members of the group, change
Code:
Type GroupRec
GroupID As Long
GroupLeader As String
GroupNum As Long
GroupMember(0 To MAX_GROUP_NUMBER) As String
End Type
to
Code:
Type GroupRec
GroupID As Long
GroupLeader As String
GroupNum As Long
GroupMember(1 To MAX_GROUP_NUMBER) As String
End Type
Now in the Joingroup, leavegroup, Sendgroupstats and Senddatatoparty sub, change all the for loops from
Code:
For I = 0 To MAX_GROUP_NUMBER
To
Code:
For I = 1 To MAX_GROUP_NUMBER
Now in the Leavegroup sub, add an Exit for to the for loop. We only want to assign 1 new group leader when the group leader leave the group so we need to exit after we promote 1 member to leader.
Code:
If Player(index).PartyStarter = YES Then
For I = 1 To MAX_GROUP_NUMBER
If Group(Player(index).GroupID).GroupMember(I) "" Then
Group(Player(index).GroupID).GroupLeader = Group(Player(index).GroupID).GroupMember(I)
Group(Player(index).GroupID).GroupMember(I) = ""
n = FindPlayer(Group(Player(index).GroupID).GroupLeader)
Player(n).PartyStarter = YES
Call PlayerMsg(n, "You are now the party leader.", Pink)
Exit For
End If
Next
End If
In the Cleargroup sub, add the following line after you clear the group
Code:
CurrentGroupAmount = CurrentGroupAmount - 1
Finally, in the CloseSocket Sub find
Code:
If Index > 0 Then
Below that line, add
Code:
If Player(index).InParty = YES Then
Call LeaveGroup(index, Player(index).PartyPlayer)
End If
This call the leavegroup sub to take a player out of the party when they disconnect from the server.
I think that should be everything. For the client, what Sonire made works fine. My apologies for not mentioning which module the sub are in but I'm working off of 3.07 and I've modified the code a lot so my modules might be different than yours. Just do a search of the project for whatever you can't find. The party system seems to work fine (though it's still rather useless at this point until more features are added). I may have forgotten something typing all this up so if you can't get it working, post back and I'll double check my code.