NetPlayerLocal (playerID)

Параметры

playerID = номер ID игрока ( полученный командой NetMsgFrom())

Описание

Учтите, что эта команда работает, ТОЛЬКО когда Вы присоединились к сетевой игре с помощью команд StartNetGame или JoinNetGame и создали игрока командой CreateNetPlayer (Вы должны создать игрока, даже если он будет скрыт).

Используйте эту команду вместе с командой NetMsgFrom () (чтобы получить номер ID игрока), чтобы проверить, находится ли рассматриваемый игрок на локальной машине (в противоположность удаленной машине). Вы можете предусмотреть какой-то другой алгоритм в Вашей программе, основанной на анализе того, было ли входящее сообщение от локальной или удаленной машины.

Вы должны будете использовать команды NetMsgFrom, NetMsgTo и NetMsgData$, чтобы получить другую важную информацию из сообщения.

Пример требует, чтобы Вы выполняли его на удаленной машине, в то время как локальный компьютер выполняет пример из команды SendNetMsg.

Пример

; NetPlayerLocal example
; --------------------
; Run this program on the REMOTE computer to 'watch'
; the activity of the SendNetMsg example. Run that
; example on local machine.
;
; This program will tell you when a player involved in
; the game hits a wall ...

; We'll use this instead of JoinHostGame - make it easier
StartNetGame()

; Create a player - a player must be created to
; receive mesages!
playerID=CreateNetPlayer("Shane")

; Loop and get status
While Not KeyHit(1)

; Check to see if we've received a message
If RecvNetMsg() Then

; if we did, let's figure out what type it is
; we know it will be a user message, though
msgType=NetMsgType()

; 1-99 means a user message
If msgType>0 And msgType<100 Then

; Let's see who the message was from
msgFrom=NetMsgFrom()

; Let's get the message!
msgData$=NetMsgData$()

; Print the message
Print msgData$
if NetPlayerLocal(NetMsgFrom()) then
print "(This was sent from a local player)"
end if
End If
End If
Wend

Главная страница

Нажмите сюда, чтобы увидеть последнюю версию этой страницы в Интернете