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


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)