| Mirage Source http://miragesource.net/forums/ |
|
| LocalPlayerID function problems.. [FIXED] http://miragesource.net/forums/viewtopic.php?f=201&t=3674 |
Page 1 of 1 |
| Author: | seraphelic [ Fri May 02, 2008 6:28 pm ] |
| Post subject: | LocalPlayerID function problems.. [FIXED] |
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. |
|
| Author: | Dragoons Master [ Fri May 02, 2008 6:44 pm ] |
| Post subject: | Re: LocalPlayerID function problems.. |
Code: Packet = Packet & "UpdateLocalPlayers" & END_CHAR Should be: Code: Packet = "UpdateLocalPlayers" & END_CHAR
|
|
| Author: | Dr. Spoon [ Sat May 03, 2008 10:21 pm ] |
| Post subject: | Re: LocalPlayerID function problems.. |
don't you need a SEP_CHAR seperating your packet title and the END_CHAR |
|
| Author: | Dragoons Master [ Sat May 03, 2008 11:15 pm ] |
| Post subject: | Re: LocalPlayerID function problems.. |
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. |
|
| Author: | seraphelic [ Tue May 06, 2008 12:55 am ] |
| Post subject: | Re: LocalPlayerID function problems.. |
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. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|