Ok, so here's the deal. I have an almost complete party code that includes all the server side stuff. the only thing that needs to be added is some code client side that displays the stats of your fellow party members, such as current and max MP, HP, and SP, as well as name, level, and class. If anyone can finish this part of the code then everyone can use this in their source. I only ask that whoever codes the client side to please post it here and make it available to everyone. Other then that, feel free to use!
Server side in modTypes:
Code:
Public Const MAX_GROUP_NUMBER = 5
Type GroupRec
GroupID As Long
GroupLeader As String
GroupNum As Long
GroupMember(0 To MAX_GROUP_NUMBER) As String
End Type
Type AccountRec
GroupID As Long
End Type
Public Group() As GroupRec
Public CurrentGroupAmount As Long
In modHandleData:
Code:
' ::::::::::::::::::
' :: Party packet ::
' ::::::::::::::::::
If LCase(Parse(0)) = "party" Then
n = FindPlayer(Parse(1))
' Prevent partying with self
If n = index Then
Exit Sub
End If
' Check for a previous party and if so drop it
If Player(index).InParty = YES Then
If Player(index).PartyStarter = YES Then
Call PlayerMsg(index, "Party request has been sent to " & GetPlayerName(n) & ".", Pink)
Call PlayerMsg(n, GetPlayerName(index) & " wants you to join their party. Type /join to join, or /leave to decline.", Pink)
Player(n).PartyPlayer = Player(index).CHAR(Player(index).CharNum).Name
Else
Call PlayerMsg(index, "You are already in a party!", Pink)
Exit Sub
End If
End If
If n > 0 Then
' Check if its an admin
If GetPlayerAccess(index) > ADMIN_MONITER Then
Call PlayerMsg(index, "You can't join a party, you are an admin!", BrightBlue)
Exit Sub
End If
If GetPlayerAccess(n) > ADMIN_MONITER Then
Call PlayerMsg(index, "Admins cannot join parties!", BrightBlue)
Exit Sub
End If
' Make sure they are in right level range
'If GetPlayerLevel(index) + 5 < GetPlayerLevel(n) Or GetPlayerLevel(index) - 5 > GetPlayerLevel(n) Then
' Call PlayerMsg(index, "There is more then a 5 level gap between you two, party failed.", Pink)
' Exit Sub
'End If
' Check to see if player is already in a party
If Player(n).InParty = NO Then
Call PlayerMsg(index, "Party request has been sent to " & GetPlayerName(n) & ".", Pink)
Call PlayerMsg(n, GetPlayerName(index) & " wants you to join their party. Type /join to join, or /leave to decline.", Pink)
Player(index).PartyStarter = YES
Player(index).InParty = YES
Player(index).GroupID = CreateGroup(index)
Player(n).PartyPlayer = index
Else
Call PlayerMsg(index, "Player is already in a party!", Pink)
End If
Else
Call PlayerMsg(index, "Player is not online.", White)
End If
Exit Sub
End If
' :::::::::::::::::::::::
' :: Join party packet ::
' :::::::::::::::::::::::
If LCase(Parse(0)) = "joinparty" Then
n = Player(index).PartyPlayer
If n > 0 Then
' Check to make sure they aren't the starter
If Player(index).PartyStarter = NO Then
' Check to make sure that each of there party players match
If Player(index).PartyPlayer = n Then
' Check to make sure the party isn't full
If Group(Player(n).GroupID).GroupNum < MAX_GROUP_NUMBER Then
Call PlayerMsg(index, "You have joined " & GetPlayerName(n) & "'s party!", Pink)
Call PlayerMsg(n, GetPlayerName(index) & " has joined your party!", Pink)
Call JoinGroup(index, n)
Player(index).InParty = YES
Else
Call PlayerMsg(index, "Party is full!", Pink)
Call PlayerMsg(n, "Party is full!", Pink)
End If
Else
Call PlayerMsg(index, "Party failed.", Pink)
End If
Else
Call PlayerMsg(index, "You have not been invited to join a party!", Pink)
End If
Else
Call PlayerMsg(index, "You have not been invited into a party!", Pink)
End If
Exit Sub
End If
' ::::::::::::::::::::::::
' :: Leave party packet ::
' ::::::::::::::::::::::::
If LCase(Parse(0)) = "leaveparty" Then
n = Player(index).PartyPlayer
If n > 0 Then
If Player(index).InParty = YES Then
Call LeaveGroup(index, n)
Else
Call PlayerMsg(index, "Declined party request.", Pink)
Call PlayerMsg(n, GetPlayerName(index) & " declined your request.", Pink)
Player(index).PartyPlayer = 0
Player(index).PartyStarter = NO
Player(index).InParty = NO
Player(n).PartyPlayer = 0
Player(n).PartyStarter = NO
Player(n).InParty = NO
Player(n).GroupID = 0
Group(Player(n).GroupID).GroupID = 0
End If
Else
Call PlayerMsg(index, "You are not in a party!", Pink)
End If
Exit Sub
End If
In modGeneral:
Code:
Function CreateGroup(ByVal index As Long)
Dim GotGroup As Boolean
Dim i As Long
GotGroup = False
If CurrentGroupAmount < 1 Then
CurrentGroupAmount = 1
ReDim Preserve Group(1 To CurrentGroupAmount) As GroupRec
End If
For i = 1 To CurrentGroupAmount
If Group(i).GroupID = 0 Then
Player(index).GroupID = i
Group(i).GroupID = Player(index).GroupID
GotGroup = True
End If
Next
If GotGroup = False Then
CurrentGroupAmount = CurrentGroupAmount + 1
ReDim Preserve Group(1 To CurrentGroupAmount) As GroupRec
Player(index).GroupID = CurrentGroupAmount
Group(CurrentGroupAmount).GroupID = Player(index).GroupID
End If
Group(Player(index).GroupID).GroupNum = 0
Group(Player(index).GroupID).GroupNum = Group(Player(index).GroupID).GroupNum + 1
Group(Player(index).GroupID).GroupLeader = GetPlayerName(index)
CreateGroup = Player(index).GroupID
Player(index).PartyPlayer = index
End Function
Sub JoinGroup(ByVal index As Long, ByVal PartyPlayer As Long)
Dim i As Long
Player(index).GroupID = Player(PartyPlayer).GroupID
Group(Player(index).GroupID).GroupNum = Group(Player(index).GroupID).GroupNum + 1
For i = 0 To MAX_GROUP_NUMBER
If Group(Player(index).GroupID).GroupMember(i) = "" Then
Group(Player(index).GroupID).GroupMember(i) = GetPlayerName(index)
Exit Sub
End If
Next
End Sub
Sub LeaveGroup(ByVal index As Long, ByVal n As Long)
Dim TempLeader As Long, i As Long, TempGroupID As Long
For i = 0 To MAX_GROUP_NUMBER
If Group(Player(index).GroupID).GroupMember(i) = GetPlayerName(index) Then
Group(Player(index).GroupID).GroupMember(i) = ""
End If
Next
If Player(index).PartyStarter = YES Then
For i = 0 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)
End If
Next
End If
Group(Player(index).GroupID).GroupNum = Group(Player(index).GroupID).GroupNum - 1
TempGroupID = Group(Player(index).GroupID).GroupNum
Player(index).PartyPlayer = 0
Player(index).PartyStarter = NO
Player(index).InParty = NO
Player(index).GroupID = 0
Call PlayerMsg(index, "You have left the party.", Pink)
Call PlayerMsg(n, GetPlayerName(index) & " has left the party.", Pink)
If TempGroupID < 2 Then
Player(n).PartyPlayer = 0
Player(n).PartyStarter = NO
Player(n).InParty = NO
Call ClearGroup(Player(n).GroupID)
Player(n).GroupID = 0
Call PlayerMsg(n, "Your group has been disbanded.", Pink)
End If
End Sub
Sub ClearGroup(ByVal GroupID As Long)
Dim i As Long
Group(GroupID).GroupID = 0
Group(GroupID).GroupLeader = ""
Group(GroupID).GroupNum = 0
For i = 1 To MAX_GROUP_NUMBER
Group(GroupID).GroupMember(i) = ""
Next
End Sub
Sub SendPartyStats(ByVal GroupID As Long)
Dim packet As String, party As Long, i As Long
party = FindPlayer(Group(GroupID).GroupLeader)
packet = GetPlayerName(party) & SEP_CHAR & GetPlayerClass(party) & SEP_CHAR & GetPlayerLevel(party) & SEP_CHAR & GetPlayerMaxHP(party) & GetPlayerHP(party) & SEP_CHAR & GetPlayerMaxMP(party) & SEP_CHAR & GetPlayerMP(party) & SEP_CHAR
For i = 0 To MAX_GROUP_NUMBER
party = FindPlayer(Group(GroupID).GroupMember(i))
packet = packet & GetPlayerName(party) & SEP_CHAR & GetPlayerClass(party) & SEP_CHAR & GetPlayerLevel(party) & SEP_CHAR & GetPlayerMaxHP(party) & GetPlayerHP(party) & SEP_CHAR & GetPlayerMaxMP(party) & SEP_CHAR & GetPlayerMP(party) & SEP_CHAR
Next
packet = "PARTYSTATS" & SEP_CHAR & packet & SEP_CHAR & END_CHAR
Call SendDataToParty(GroupID, packet)
End Sub
Sub SendDataToParty(ByVal GroupID As Long, ByVal packet As String)
Dim i As Long, index As Long
For i = 0 To MAX_GROUP_NUMBER
index = FindPlayer(Group(GroupID).GroupMember(i))
Call SendDataTo(index, packet)
Next
index = FindPlayer(Group(GroupID).GroupLeader)
Call SendDataTo(index, packet)
End Sub
use
Code:
Call SendPartyStats(GroupID)
to send the party data to all the members in the party. this can either be put in the main loop, or it can be put in everytime damage is done or a spell is cast, up to you.