CreateNetPlayer.htm 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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>CreateNetPlayer (name$)</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. name$ = any valid string holding the player's name.
  13. </td>
  14. </tr>
  15. </table>
  16. <h1>Description</h1>
  17. <table>
  18. <tr>
  19. <td>
  20. Creates a new local player. This also causes a special message to be sent to all remote machines (see NetMsgType). This returns an integer player number to be used in sending/receiving messages. Note that you must create at least one player before you can send and receive messages.
  21. </td>
  22. </tr>
  23. </table>
  24. <h1><a href=../2d_examples/CreateNetPlayer.bb>Example</a></h1>
  25. <table>
  26. <tr>
  27. <td>
  28. ; CreateNetPlayer example <br />
  29. <br />
  30. newGame = StartNetGame() <br />
  31. ; Check the status of the new game. <br />
  32. If newGame = 0 Then <br />
  33. Print "Could not start or join net game." <br />
  34. End <br />
  35. <br />
  36. ElseIf newGame = 1 <br />
  37. Print "Successfully joined the network game" <br />
  38. ElseIf newGame = 2 <br />
  39. Print "A new network game was started!" <br />
  40. EndIf <br />
  41. <br />
  42. ; Create a random player name <br />
  43. name$="Player" + Rand(100) <br />
  44. <br />
  45. ; Get a unique player id number for the player <br />
  46. ; and create the player <br />
  47. playerID=CreateNetPlayer(name$) <br />
  48. <br />
  49. If playerID = 0 Then <br />
  50. Print "Player could not be created!" <br />
  51. Else <br />
  52. Print "Player " + name$ + " was created and given ID#" + playerID <br />
  53. End If <br />
  54. WaitKey() <br />
  55. </td>
  56. </tr>
  57. </table>
  58. <br>
  59. <a target=_top href=../index.htm>Index</a><br>
  60. <br>
  61. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=CreateNetPlayer&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  62. </html>