02-04-2009, 12:44 PM
I've done this in MR and showed a few others a better way to do PlayerData. If you ever change what gets sent in the playerdata packet, you have change it in like 4 places. With this you would only change it in 1 place.
I added it to modPlayer
An example
I added it to modPlayer
Code:
Public Function PlayerData(ByVal Index As Long) As String
PlayerData = SPlayerData & SEP_CHAR & Index & SEP_CHAR & GetPlayerName(Index) & SEP_CHAR & GetPlayerSprite(Index) & SEP_CHAR & GetPlayerMap(Index) & SEP_CHAR & GetPlayerX(Index) & SEP_CHAR & GetPlayerY(Index) & SEP_CHAR & GetPlayerDir(Index) & SEP_CHAR & GetPlayerAccess(Index) & SEP_CHAR & GetPlayerPK(Index) & END_CHAR
End Function
An example
Code:
Public Sub SendJoinMap(ByVal Index As Long)
Dim Packet As String
Dim i As Long
' Send all players on current map to index
For i = 1 To High_Index
If IsPlaying(i) Then
If i Index Then
If GetPlayerMap(i) = GetPlayerMap(Index) Then
Call SendDataTo(Index, PlayerData(i))
End If
End If
End If
Next
' Send index's player data to everyone on the map including himself
Call SendDataToMap(GetPlayerMap(Index), PlayerData(Index))
End Sub