Hmm, you may be right there. In that simple program I posted the players now seem to always be fine. But in the FPS module code, there are always at least 6 other players who appear randomly on the list. This is very weird as there are no essential differences between that code, and the test code, all the commands I'm using are identical, the only difference is the player system that I've built around your plugin commands to make it easier to manage. I tried changing the ports but it makes no difference. I've tried calling TSync after connection but no difference, in fact it reports these "ghost" players constantly. I really am bewildered at the moment as to why this is happening so randomly
. I doubt it'll help, but here is the module used to control the player connections...
remstart
Network Module
Joseph Thomson
08/06/05
This module controls all communications between players in a game
remend
#constant C_MAXPLAYERS 255
#constant C_HOST 0
#constant C_NOTHOST 1
type Type_Player
exist as boolean
name as string
endtype
type TYPE_PlayerMessage
player as integer `Player slot
str as string
endtype
declareNetwork:
global G_NetStatus as integer
global G_Connected as integer
global dim G_Player(0) as Type_Player
global dim G_Message(0) as TYPE_PlayerMessage
return
function setupNetwork()
endfunction
function updateNetwork()
local x as integer
if G_Connected = 1
TSync
NET_CheckForPlayers()
for x = 0 to TGetMaximumPlayers()-1
text 20,50+20*x,str$(TPlayerExist(x))+" | "+TGetPlayerName(x)
next x
endif
endfunction
function unloadNetwork()
endfunction
function NET_HostGame(IP as string, maxPlayers as dword, name as string)
if not G_Connected
`TSetLocalPort 3734
`TSetRemotePort 12803
`G_Connected = THost(IP, maxPlayers, name)
G_Connected = THost("192.168.0.2",10,"Joseph")
if G_Connected = 1
G_NetStatus = C_HOST
NET_AddPlayer(0,name)
CSL_Print("Hosted Game Successfully",rgb(0,255,0))
CSL_Print("You are '"+name+"'",rgb(255,255,255))
else
CSL_Print("Failed To Host Game",rgb(255,0,0))
endif
else
exitfunction 0
endif
endfunction G_Connected
function NET_JoinGame(localIP as string, hostIP as string, name as string)
local x as integer
if not G_Connected
`TSetLocalPort 12803
`TSetRemotePort 3734
` G_Connected = TJoin(localIP, hostIP, name)
G_Connected = TJoin("192.168.0.2","192.168.0.2","Tramp Man")
if G_Connected = 1
G_NetStatus = C_NOTHOST
NET_AddPlayer(0,name)
CSL_Print("Joined Game Successfully",rgb(0,255,0))
CSL_Print("Local IP: "+localIP,rgb(0,255,0))
CSL_Print("Host IP: "+hostIP,rgb(0,255,0))
CSL_Print("You are '"+name+"'",rgb(255,255,255))
for x = 0 to TGetMaximumPlayers()-1
if TPlayerExist(x) = 1
NET_AddPlayer(x,TGetPlayerName(x))
if x = 1
CSL_Print("Host is '"+TGetPlayerName(x)+"'",rgb(255,255,255))
else
CSL_Print("Player '"+TGetPlayerName(x)+"' Currently In Game",rgb(255,255,255))
endif
endif
next x
else
CSL_Print("Failed To Join Game",rgb(255,0,0))
CSL_Print("Local IP: "+localIP,rgb(255,0,0))
CSL_Print("Host IP: "+hostIP,rgb(255,0,0))
endif
else
exitfunction 0
endif
endfunction G_Connected
function NET_AddPlayer(playerID as dword, name as string)
local x as integer
if playerID > array count(G_Player(0))
for x = array count(G_Player(0))+1 to playerID
array insert at bottom G_Player(0)
next x
endif
G_Player(playerID).name = name
G_Player(playerID).exist = 1
endfunction
function NET_CheckForPlayers()
local x as integer
`Check for players having left or joined
for x = 1+(G_NetStatus = C_NOTHOST) to array count(G_Player(0))
if G_Player(x).exist and (not TPlayerExist(x))
CSL_Print("Player '"+G_Player(x).name+"' Left Game",rgb(255,255,255))
G_Player(x).exist = 0
G_Player(x).name = ""
if x = array count(G_Player(0)) then array delete element G_Player(0),array count(G_Player(0))
endif
if (not G_Player(x).exist) and TPlayerExist(x) = 1
NET_AddPlayer(x,TGetPlayerName(x))
CSL_Print("Player '"+G_Player(x).name+"' Joined Game",rgb(255,255,255))
endif
next x
`Check for player beyond list of players joining
if array count(G_Player(0)) < C_MAXPLAYERS
if TPlayerExist(array count(G_Player(0))+1) = 1
NET_AddPlayer(array count(G_Player(0))+1,TGetPlayerName(array count(G_Player(0))+1))
CSL_Print("Player '"+G_Player(array count(G_Player(0))).name+"' Joined Game",rgb(255,255,255))
endif
endif
endfunction
More tea Vicar?