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

84 lines
2.5 KiB
HTML

<html>
<head>
<title>Blitz3D Docs</title>
<link rel=stylesheet href=../css/commands.css type=text/css>
</head>
<body>
<h1>NetPlayerName$ (playerID)</h1>
<h1>Parameters</h1>
<table>
<tr>
<td>
playerID = a valid player ID number (get from the NetMsgFrom() command
</td>
</tr>
</table>
<h1>Description</h1>
<table>
<tr>
<td>
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).
<br />
<br />
Use this command in conjunction with the NetMsgFrom() (to get the player's ID) command to derive the actual name of the player. This command returns a string value.
<br />
<br />
You will use NetMsgType(), NetMsgFrom(), and NetMsgTo() to get other important information from the message and act on it.
<br />
<br />
The example requires that you run it on a remote machine while the local computer runs the example in the SendNetMsg command.
</td>
</tr>
</table>
<h1><a href=../2d_examples/NetPlayerName.bb>Example</a></h1>
<table>
<tr>
<td>
; NetPlayerName$() example
<br />
; --------------------
<br />
; Run this program on the REMOTE computer to 'watch'
<br />
; the activity of the SendNetMsg example. Run that
<br />
; example on local machine.
<br />
;
<br />
; This program will tell you when a player involved in
<br />
; the game hits a wall ...
<br />
<br />
; We'll use this instead of JoinHostGame - make it easier
<br />
StartNetGame()
<br />
<br />
; Create a player - a player must be created to
<br />
; receive mesages!
<br />
playerID=CreateNetPlayer("Shane")
<br />
<br />
; Loop and get status
<br />
While Not KeyHit(1)
<br />
<br />
; Check to see if we've received a message
<br />
If RecvNetMsg() Then
<br />
<br />
; if we did, let's figure out what type it is
<br />
; we know it will be a user message, though
<br />
msgType=NetMsgType()
<br />
<br />
; 1-99 means a user message
<br />
If msgType>0 And msgType<100 Then
<br />
<br />
; Let's see who the message was from
<br />
msgFrom=NetMsgFrom()
<br />
<br />
; Let's get the message!
<br />
msgData$=NetMsgData$()
<br />
<br />
; Print the message
<br />
Print msgData$
<br />
Print "(Message was from:"+ NetPlayerName$(NetMsgFrom()) + ")"
<br />
End If
<br />
End If
<br />
Wend
<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=NetPlayerName&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
</html>