NetMsgData.htm 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>NetMsgData$()</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. None.
  13. </td>
  14. </tr>
  15. </table>
  16. <h1>Description</h1>
  17. <table>
  18. <tr>
  19. <td>
  20. First off, this ONLY works when you have joined a network game via StartNetGame or JoinNetGame and you have created a player via CreateNetPlayer (you must create a player, even if it is just to lurk). You must've received the message already, determined by the RecvNetMsg() command - and probably determined the type of message with (NetMsgType(). <br />
  21. <br />
  22. The string value returned from this command is the actual message text that was sent. <br />
  23. <br />
  24. You will use NetMsgType(), NetMsgFrom(), and NetMsgTo() to get other important information from the message and act on it. <br />
  25. <br />
  26. The example requires that you run it on a remote machine while the local computer runs the example in the SendNetMsg command.
  27. </td>
  28. </tr>
  29. </table>
  30. <h1><a href=../2d_examples/NetMsgData.bb>Example</a></h1>
  31. <table>
  32. <tr>
  33. <td>
  34. ; NetMsgData$() example <br />
  35. ; -------------------- <br />
  36. ; Run this program on the REMOTE computer to 'watch' <br />
  37. ; the activity of the SendNetMsg example. Run that <br />
  38. ; example on local machine. <br />
  39. ; <br />
  40. ; This program will tell you when a player involved in <br />
  41. ; the game hits a wall ... <br />
  42. <br />
  43. ; We'll use this instead of JoinHostGame - make it easier <br />
  44. StartNetGame() <br />
  45. <br />
  46. ; Create a player - a player must be created to <br />
  47. ; receive mesages! <br />
  48. playerID=CreateNetPlayer("Shane") <br />
  49. <br />
  50. ; Loop and get status <br />
  51. While Not KeyHit(1) <br />
  52. <br />
  53. ; Check to see if we've received a message <br />
  54. If RecvNetMsg() Then <br />
  55. <br />
  56. ; if we did, let's figure out what type it is <br />
  57. ; we know it will be a user message, though <br />
  58. msgType=NetMsgType() <br />
  59. <br />
  60. ; 1-99 means a user message <br />
  61. If msgType>0 And msgType<100 Then <br />
  62. <br />
  63. ; Let's see who the message was from <br />
  64. msgFrom=NetMsgFrom() <br />
  65. <br />
  66. ; Let's get the message! <br />
  67. msgData$=NetMsgData$() <br />
  68. <br />
  69. ; Print the message <br />
  70. Print msgData$ <br />
  71. Print "(Message was to:"+ NetMsgTo() + ")" <br />
  72. End If <br />
  73. End If <br />
  74. Wend <br />
  75. </td>
  76. </tr>
  77. </table>
  78. <br>
  79. <a target=_top href=../index.htm>Index</a><br>
  80. <br>
  81. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=NetMsgData&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  82. </html>