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

52 lines
3.2 KiB
HTML

<html><head><title>Command: NetPlayerLocal </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;NetPlayerLocal (playerID)&nbsp;&nbsp;</span></p><span class='header'>Definition:</span> <br><br><table width='100%' border='0' cellspacing='2' cellpadding='2' align='center'><tr><td>Determines if the player is on the local machine.</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>playerID = a valid player ID number (get from the NetMsgFrom() command)</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).<br>
<br>
Use this command in conjunction with the <a href='NetMsgFrom().htm'>NetMsgFrom()</a> (to get the player's ID) command to check and see if the player in question is on the local machine (as opposed to a remote machine). You may wish to act differently in your program based on whether the message that came in was from a local or remote machine.<br>
<br>
You will use <a href='NetMsgType().htm'>NetMsgType()</a>, <a href='NetMsgFrom().htm'>NetMsgFrom()</a>, and <a href='NetMsgTo().htm'>NetMsgTo()</a> 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 <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>; NetPlayerLocal 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>
if NetPlayerLocal(NetMsgFrom()) then<br>
print "(This was sent from a local player)"<br>
end if<br>
End If<br>
End If<br>
Wend<br></td></tr></table><p><b><a target="_top" href="../index.htm">Index</a></b></p></body>
</html>