NetMsgTo().htm 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <html><head><title>Command: NetMsgTo() </title><meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'><link rel='stylesheet' href='../css/commands.css' type='text/css'></head><body><span class='Command'>&nbsp;&nbsp;NetMsgTo() &nbsp;&nbsp;</span></p><span class='header'>Definition:</span> <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>Returns the ID of the recipient of a network message.</td></tr></table><span class='header'><br>Parameter Description:</span> <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>None.</td></tr></table><p class='header'>Command Description: <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>First off, this ONLY works when you have joined a network game via <a href='StartNetGame.htm'>StartNetGame</a> or <a href='JoinNetGame.htm'>JoinNetGame</a> and you have created a player via <a href='CreateNetPlayer.htm'>CreateNetPlayer</a> (you must create a player, even if it is just to lurk). You must've received the message already, determined by the <a href='RecvNetMsg().htm'>RecvNetMsg()</a> command - and probably determined the type of message with (<a href='NetMsgType().htm'>NetMsgType()</a>.<br>
  2. <br>
  3. The value returned from this command denotes the messages's intended recipient's ID number assigned to them when they were created with <a href='CreateNetPlayer.htm'>CreateNetPlayer</a>.<br>
  4. <br>
  5. You will use <a href='NetMsgType().htm'>NetMsgType()</a>, <a href='NetMsgFrom().htm'>NetMsgFrom()</a>, and <a href='NetMsgData$().htm'>NetMsgData$()</a> to get other important information from the message and act on it.<br>
  6. <br>
  7. The example requires that you run it on a remote machine while the local computer runs the example in the <a href='SendNetMsg.htm'>SendNetMsg</a> command.</td></tr></table><p class='header'>Example: <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>; NetMsgTo() example<br>
  8. ; --------------------<br>
  9. ; Run this program on the REMOTE computer to 'watch'<br>
  10. ; the activity of the SendNetMsg example. Run that<br>
  11. ; example on local machine.<br>
  12. ;<br>
  13. ; This program will tell you when a player involved in<br>
  14. ; the game hits a wall ...<br>
  15. <br>
  16. ; We'll use this instead of JoinHostGame - make it easier<br>
  17. StartNetGame()<br>
  18. <br>
  19. ; Create a player - a player must be created to<br>
  20. ; receive mesages!<br>
  21. playerID=CreateNetPlayer("Shane")<br>
  22. <br>
  23. ; Loop and get status<br>
  24. While Not KeyHit(1)<br>
  25. <br>
  26. ; Check to see if we've received a message<br>
  27. If RecvNetMsg() Then<br>
  28. <br>
  29. ; if we did, let's figure out what type it is<br>
  30. ; we know it will be a user message, though<br>
  31. msgType=NetMsgType()<br>
  32. <br>
  33. ; 1-99 means a user message<br>
  34. If msgType>0 And msgType<100 Then<br>
  35. <br>
  36. ; Let's see who the message was from<br>
  37. msgFrom=NetMsgFrom()<br>
  38. <br>
  39. ; Let's get the message!<br>
  40. msgData$=NetMsgData$()<br>
  41. <br>
  42. ; Print the message<br>
  43. Print msgData$<br>
  44. Print "(Message was to:"+ NetMsgTo() + ")"<br>
  45. End If<br>
  46. End If<br>
  47. Wend<br></td></tr></table><p><b><a target="_top" href="../index.htm">Index</a></b></p></body>
  48. </html>