Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
LocalPlayerID function problems.. [FIXED]
#1
I added a function and edited packets for players on the same map.. it doesn't work properly but i dont know why. Please take a look and make some comments.

The Clientside function:
Code:
Sub SetLocalPlayerID()
Dim i As Long
Dim C As Long

    For i = 1 To MAX_PLAYERS
        LocalPlayerID(i) = 0
    Next i
    
    C = 1
    
    For i = 1 To MAX_PLAYERS
         If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
               LocalPlayerID(C) = i
               C = C + 1
         End If
     Next i
    
End Sub
Clientside handledata:
Code:
' ::::::::::::::::::::::::::
    ' :: Update local players ::
    ' ::::::::::::::::::::::::::
    If LCase$(Parse(0)) = "updatelocalplayers" Then
        Call SetLocalPlayerID
    End If
The Server edited packet:
Code:
Sub SendLeaveMap(ByVal Index As Long, ByVal oldMap As Long, MapNum)
Dim Packet As String
Dim i As Long

    Packet = "PLAYERDATA" & SEP_CHAR & Index & SEP_CHAR & GetPlayerName(Index) & SEP_CHAR & GetPlayerSprite(Index) & SEP_CHAR & 0 & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & GetPlayerAccess(Index) & SEP_CHAR & GetPlayerPK(Index) & SEP_CHAR & END_CHAR
    Call SendDataToMapBut(Index, oldMap, Packet)
    
    Call SetPlayerMap(Index, MapNum)
                    
        For i = 1 To MAX_PLAYERS
            If IsPlaying(i) And i  Index And GetPlayerMap(i) = oldMap Then
                Packet = Packet & "UpdateLocalPlayers" & END_CHAR
                Call SendDataTo(i, Packet)
            End If
        Next i
        
        Packet = "UpdateLocalPlayers" & END_CHAR
        Call SendDataTo(Index, Packet)
        
        For i = 1 To MAX_PLAYERS
            If IsPlaying(i) And i  Index And GetPlayerMap(i) = MapNum Then
                Packet = Packet & "UpdateLocalPlayers" & END_CHAR
                Call SendDataTo(i, Packet)
            End If
        Next i
    
End Sub
And... example code I use in the gameloop:
Code:
' Blit out players
         For i = 1 To MAX_PLAYERS
            If LocalPlayerID(i) = 0 Then
                Exit For
            End If
            Call BltPlayer(LocalPlayerID(i))
        Next i

I get a range of problems.. Players aren't blted at all, players are blted still when I leave the map.. Please help.
Reply
#2
Code:
Packet = Packet & "UpdateLocalPlayers" & END_CHAR
Should be:
Code:
Packet = "UpdateLocalPlayers" & END_CHAR
Reply
#3
don't you need a SEP_CHAR seperating your packet title and the END_CHAR
Reply
#4
Not really. If you do that you'll have an empty parse(1). END_CHAR is only to say a packet is done, it is not interpreted. Then it will try to split the packet with SEP_CHAR and that will give you two pieces. The packet name and an empty string. In mirage that's done but it's really not needed at all. If you replace all "sep_char & end_char" with "end_char" it probably will make a fill bugs xD Well, sometimes we forget to check a fill things and that may cause a RTE9.
Reply
#5
Dragoons Master Wrote:
Code:
Packet = Packet & "UpdateLocalPlayers" & END_CHAR
Should be:
Code:
Packet = "UpdateLocalPlayers" & END_CHAR
\

Wow I overthought this one. I fixed by seperating the update packets into SendLeaveMap and SendJoinMap.. Thanks for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)