Files
BlitzNext/_release/help/commands/2d_commands/CreateNetPlayer.htm
T
2014-12-08 12:43:20 +13:00

64 lines
1.7 KiB
HTML

<html>
<head>
<title>Blitz3D Docs</title>
<link rel=stylesheet href=../css/commands.css type=text/css>
</head>
<body>
<h1>CreateNetPlayer (name$)</h1>
<h1>Parameters</h1>
<table>
<tr>
<td>
name$ = any valid string holding the player's name.
</td>
</tr>
</table>
<h1>Description</h1>
<table>
<tr>
<td>
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.
</td>
</tr>
</table>
<h1><a href=../2d_examples/CreateNetPlayer.bb>Example</a></h1>
<table>
<tr>
<td>
; CreateNetPlayer example
<br />
<br />
newGame = StartNetGame()
<br />
; Check the status of the new game.
<br />
If newGame = 0 Then
<br />
Print "Could not start or join net game."
<br />
End
<br />
<br />
ElseIf newGame = 1
<br />
Print "Successfully joined the network game"
<br />
ElseIf newGame = 2
<br />
Print "A new network game was started!"
<br />
EndIf
<br />
<br />
; Create a random player name
<br />
name$="Player" + Rand(100)
<br />
<br />
; Get a unique player id number for the player
<br />
; and create the player
<br />
playerID=CreateNetPlayer(name$)
<br />
<br />
If playerID = 0 Then
<br />
Print "Player could not be created!"
<br />
Else
<br />
Print "Player " + name$ + " was created and given ID#" + playerID
<br />
End If
<br />
WaitKey()
<br />
</td>
</tr>
</table>
<br>
<a target=_top href=../index.htm>Index</a><br>
<br>
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>
</html>