Files
BlitzNext/_release/help/commands/2d_commands/CreateNetPlayer.htm
T
2014-02-26 16:08:39 +13:00

31 lines
2.0 KiB
HTML

<html><head><title>Command: CreateNetPlayer </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;CreateNetPlayer (name$)&nbsp;&nbsp;</span></p><span class='header'>Definition:</span> <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>Creates a new local player on the network game.</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>name$ = any valid string holding the player's name.</td></tr></table><p class='header'>Command Description: <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>Creates a new local player. This also causes a special message to be sent to all remote machines (see <a href='NetMsgType.htm'>NetMsgType</a>). 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><p class='header'>Example: <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><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><p><b><a target="_top" href="../index.htm">Index</a></b></p></body>
</html>