Mirage Source

Free ORPG making software.
It is currently Tue Aug 09, 2022 7:06 pm

All times are UTC




Post new topic Reply to topic  [ 47 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Updated Party/Group
PostPosted: Thu Aug 21, 2008 2:37 am 
Offline
Pro
User avatar

Joined: Wed Jun 07, 2006 8:04 pm
Posts: 464
Location: MI
Google Talk: asrrin29@gmail.com
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.

_________________
Image
Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 4:33 am 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
I think I'll have a go at it. Maybe if I can get something basic enough client side we can get another one of those community based tutorials going with it.

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 11:50 am 
Offline
Pro
User avatar

Joined: Wed Jun 07, 2006 8:04 pm
Posts: 464
Location: MI
Google Talk: asrrin29@gmail.com
I'd like to see the party stats displayed graphically, either in picScreen or in a seperate picBox, but as long as I can get it working, I think it will be a great addition to any source out thier. can't really have an MMORPG if you can only group with one other person, lol.

_________________
Image
Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 4:00 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
Yeah, I'm gonna take a graphical approach for displaying hp and mp. Though I'll be doing it on a picBox rather than blting it to the game screen.

I started working on it a little bit last night. My first attempt only read the Leader's Name, level, and class. It was like 3:00 a.m. though, so I didn't fiddle with it for too long.

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 8:16 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
Okay, so I've been playing with this a little more today. Right now, I'm just trying to get everything displaying on plain old labels. Here is what I've done so far code-wise:

Sub HandleData - Client Side
Code:
    ' :::::::::::::::::
    ' :: Party Stats ::
    ' :::::::::::::::::
    If (LCase(Parse(0)) = "partystats") Then
        X = Val(Parse(1)) ' Total Group Members
        frmMirage.lblLeaderName.Caption = Trim$(Parse(2)) & " " & Val(Parse(4)) ' Leader Name & Level
        frmMirage.lblLeaderClass.Caption = Trim$(Parse(3)) ' Leader Class
        frmMirage.lblLeaderHP = Val(Parse(6)) & "/" & Val(Parse(5)) ' Leader HP
        frmMirage.lblLeaderMP.Caption = Val(Parse(8)) & "/" & Val(Parse(7)) ' Leader MP
       
        n = 9 ' Next Parse In Line
        For i = 1 To X ' MAX_GROUP_NUMBER
            frmMirage.lblGroupName(i - 1).Caption = Trim$(Parse(n)) & " " & Val(Parse(n + 2)) ' Member i Name & Level
            frmMirage.lblGroupClass(i - 1).Caption = Trim$(Parse(n + 1)) ' Member i Class
            frmMirage.lblGroupHP(i - 1).Caption = Val(Parse(n + 4)) & "/" & Val(Parse(n + 3)) ' Member i HP
            frmMirage.lblGroupMP(i - 1).Caption = Val(Parse(n + 6)) & "/" & Val(Parse(n + 5)) ' Member i MP
            n = n + 1
        Next i
    End If
    Exit Sub


modGeneral - Server Side
Code:
Sub SendPartyStats(ByVal GroupID As Long)
Dim Packet As String, party As Long, I As Long, GroupNum As Long

party = FindPlayer(Group(GroupID).GroupLeader)
' Subtracted 1 becuase the GroupLeader is handled seperately
GroupNum = (Group(Player(party).GroupID).GroupNum - 1)

Packet = GetPlayerName(party) & SEP_CHAR & Class(GetPlayerClass(party)).Name & SEP_CHAR & GetPlayerLevel(party) & SEP_CHAR & GetPlayerMaxHP(party) & SEP_CHAR & GetPlayerHP(party) & SEP_CHAR & GetPlayerMaxMP(party) & SEP_CHAR & GetPlayerMP(party) & SEP_CHAR
For I = 1 To GroupNum
    party = FindPlayer(Group(GroupID).GroupMember(I))
    Packet = Packet & GetPlayerName(party) & SEP_CHAR & Class(GetPlayerClass(party)).Name & SEP_CHAR & GetPlayerLevel(party) & SEP_CHAR & GetPlayerMaxHP(party) & SEP_CHAR & GetPlayerHP(party) & SEP_CHAR & GetPlayerMaxMP(party) & SEP_CHAR & GetPlayerMP(party) & SEP_CHAR
Next
Packet = "PARTYSTATS" & SEP_CHAR & GroupNum & SEP_CHAR & Packet & SEP_CHAR & END_CHAR
Call SendDataToParty(GroupID, Packet)

End Sub


It works just fine when I have only 2 people in a party. This is what it looks like when I have 3 people in a party:
Image

As you can see, the third party member's stats are all out of order, and the name doesn't show up at all. I can't tell if the For statement client side is just spitting out random stuff, or if those numbers that do show up are actually representing the third party member.

By the way Asrrin, you're missing some SEP_CHARs in SubSendPartyStats. Look between GetPlayerHP & GetPlayerMaxHP. Missing it for the Leader and Group Members.

Does anyone see where this code is flawed? Because I don't :?

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 9:10 pm 
Offline
Pro
User avatar

Joined: Sun Aug 05, 2007 2:26 pm
Posts: 547
try having 4 or 2 people in the party. Is it always messing up on the third, or on the last, or everything after 2?

_________________
GIAKEN wrote:
I think what I see is this happening:

Labmonkey gets mod, everybody loves him, people find out his code sucks, he gets demoted, then banned, then he makes an engine called Chaos Engine.


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 9:55 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
Seems like it's everything after 2 party members.

Image

My FPS drops to 10 when I open 4 clients. Getting difficult to test :oops:

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 10:16 pm 
Offline
Persistant Poster
User avatar

Joined: Thu Mar 29, 2007 10:30 pm
Posts: 1510
Location: Virginia, USA
Google Talk: hpmccloud@gmail.com
I'm thinking you're sending the packets wrong or handling them wrong. As you notice after the second one it skips the name and goes to the next parse data like it's skipping a number in a loop.

_________________
Nean wrote:
Yes harold. Give it to me.

Image
Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 10:27 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
I know. But I think it's worse than just skipping a parse. In the second pic, my level is where my class should be, and my name displays my class and hp.

I'm about to commence thinking again though. Just got back from a job interview.

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 11:21 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
Add :
Code:
Debug.Print Data


Under
Code:
If (LCase(Parse(0)) = "partystats") Then


just so you can see what the actual packet data is.

And instead of
Code:
n = n + 1

Shouldn't it be
Code:
n = n + 7


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 11:41 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
I'm adding different values to n to retrieve the right parse, then all I have to do is add 1 after it loops through the For statement.

GroupNum always equals 1 though. One step closing to solving this I thinks

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 11:43 pm 
Offline
Pro
User avatar

Joined: Wed Jun 07, 2006 8:04 pm
Posts: 464
Location: MI
Google Talk: asrrin29@gmail.com
yeah, it's the n+7 that's doing it I'm fairly certain. change that and see what happens.

Also, I'd like to see some sort of HP/MP bar...I think I will look around for a progress bar control that is customizable, that would be nice.

_________________
Image
Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 11:53 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
Sonire wrote:
I'm adding different values to n to retrieve the right parse, then all I have to do is add 1 after it loops through the For statement.

GroupNum always equals 1 though. One step closing to solving this I thinks


You're not actually setting the n to those different values though.

You have 7 parses in a loop so n needs to be n = n + 7.


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 21, 2008 11:57 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
When I change the N + # I get pretty much the exact same results. Jumbled data, and the leader, and first party member working fine.

Asrrin, bars will be easy just as soon as I get the right data sent. :D

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Fri Aug 22, 2008 12:31 am 
Just use shapes. As you can set the images to them and when you change the width, it doesn't stretch them and what not to the width, if it's shorter than the image loaded, it cuts it off.

That's what we all do. >.>


Top
  
 
 Post subject: Re: Updated Party/Group
PostPosted: Fri Aug 22, 2008 3:40 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
I figured out the problem:

In :
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


Change:
Code:
' 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


to:
Code:
' 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
                Player(n).PartyPlayer = index
                Exit Sub
            Else
                Call PlayerMsg(index, "You are already in a party!", Pink)
                Exit Sub
            End If
        End If


The problem was on the server, it kept calling CreateGroup and makeing the groupcount = 0.

You will still need to change N= N + 1 to N= N+7.


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Fri Aug 22, 2008 5:12 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
Image

Getting much closer. It displays the one of the party players twice though. Does the same thing if I have 3 people.

I don't really understand how this makes a difference really though:
Code:
Player(n).PartyPlayer = Player(index).Char(Player(index).CharNum).Name
                Player(n).PartyPlayer = index


Why do we need both of those lines?

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Fri Aug 22, 2008 5:26 pm 
Offline
Pro
User avatar

Joined: Tue Nov 13, 2007 2:42 pm
Posts: 509
Sonire wrote:
Code:
Player(n).PartyPlayer = Player(index).Char(Player(index).CharNum).Name
                Player(n).PartyPlayer = index


Why do we need both of those lines?


Opps, you just need:
Code:
Player(n).PartyPlayer = index


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Wed Aug 27, 2008 8:18 pm 
Offline
Newbie

Joined: Mon Aug 11, 2008 9:45 pm
Posts: 3
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
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

to denote we are 1 group less

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.


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 28, 2008 2:18 pm 
Offline
Pro
User avatar

Joined: Wed Jun 07, 2006 8:04 pm
Posts: 464
Location: MI
Google Talk: asrrin29@gmail.com
it is good practice to start arrays at 0 regardless of what is going on outside of them. you can do it that way if you want, but I think I'll keep it started at 0 unless it is causing errors elsewhere in the code.

_________________
Image
Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 28, 2008 2:23 pm 
Asrrin29 wrote:
it is good practice to start arrays at 0 regardless of what is going on outside of them. you can do it that way if you want, but I think I'll keep it started at 0 unless it is causing errors elsewhere in the code.


His changes just stops the group leader from being assigned a group ID, even though either way, it will always be 0 for the group leader. Lol.


Top
  
 
 Post subject: Re: Updated Party/Group
PostPosted: Thu Aug 28, 2008 4:15 pm 
Offline
Newbie

Joined: Mon Aug 11, 2008 9:45 pm
Posts: 3
Yeah, I just wanted to start at 1. 1 or 0 doesn't make a difference as long as you keep the structure throughout. Looking through the code, I see some bugs still. So here's the new Leavegroup sub:
Code:
Sub LeaveGroup(ByVal index As Long, ByVal N As Long)
Dim TempLeader As Long, i As Long, TempGroupID As Long
Dim j As Long
Dim k As Long


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) = ""
            j = FindPlayer(Group(Player(index).GroupID).GroupLeader)
            Player(j).PartyStarter = YES
            Player(j).PartyPlayer = j
            Call PlayerMsg(j, "You are now the party leader.", Pink)
            Exit For
        End If
    Next
Else
    j = FindPlayer(Group(Player(index).GroupID).GroupLeader)
    For i = 1 To MAX_GROUP_NUMBER
        If Group(Player(index).GroupID).GroupMember(i) = GetPlayerName(index) Then
            Group(Player(index).GroupID).GroupMember(i) = ""
        End If
    Next
End If

For i = 1 To MAX_GROUP_NUMBER - 1
    If Group(Player(index).GroupID).GroupMember(i) = "" Then
        Group(Player(index).GroupID).GroupMember(i) = Group(Player(index).GroupID).GroupMember(i + 1)
        Group(Player(index).GroupID).GroupMember(i + 1) = ""
    End If
    If Group(Player(index).GroupID).GroupMember(i) <> "" Then
        k = FindPlayer(Group(Player(index).GroupID).GroupMember(i))
        Player(k).PartyPlayer = j
    End If
Next

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


The original code left the members in their original spot in the members array when someone leave the group or DC from the server. That's also fine if you rewrite the code in the sendpartystats to use max_group_number instead of groupnum and just skip over any empty slot in the member array. However, since that sub is called very frequently, it is more efficient just to shift all members in the LeaveGroup Sub. The LeaveGroup sub now also reassign "PartyPlayer" for every group member. If you don't do this, members keep the ID of the leader if he/she DC and you'll error out later when you try to make calls based on that party ID.

On the client side, make sure you clear out your labels when you receive partystats from the server. If you don't, you'll be seeing what looks to be duplicates :).


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Sun Sep 14, 2008 6:58 pm 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
I've tried using this code...And so far I've only put in the Server side part of it, and it is giving me an error when I try compiling it. I'm using MS4 if that matters.

I'm getting the error that says "Method or data member not found", and it's highlighting
Code:
Player(index).PartyPlayer = index


The ".PartyPlayer =" part of the modTypes code above is what it's highlighting...What am I doing wrong?


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Sun Sep 14, 2008 7:33 pm 
Offline
Persistant Poster
User avatar

Joined: Tue May 30, 2006 2:07 am
Posts: 836
Location: Nashville, Tennessee, USA
Google Talk: rs.ruggles@gmail.com
Server side coding on this tutorial is not fully functional yet. It's also largely written for compatibility with Mirage Source versions 3.0.3 and 3.0.7.

_________________
I'm on Facebook! Google Plus My Youtube Channel My Steam Profile

Image


Top
 Profile  
 
 Post subject: Re: Updated Party/Group
PostPosted: Sun Sep 14, 2008 7:34 pm 
Offline
Regular
User avatar

Joined: Tue Jun 17, 2008 12:39 pm
Posts: 55
Oh, alright. Darn, I was hoping I could use this. =/ Oh well, I'll wait.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 47 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group