NETNUMPLAYERS() returns wrong value

Previous topic - Next topic

Yommy

if i add 2 players to the server and then remove them in the order they was created
the last player stays in the server :(

server
Code (glbasic) Select

WHILE TRUE
num% = NETNUMPLAYERS()
GLOBAL gIDs%[]
DIM gIDs%[num%]
PRINT "ID  - Player name",10,40
FOR i% = 0 TO num%-1
   gIDs%[i%] = NETGETPLAYERID(i%)
   PRINT gIDs%[i] + " - " + NETPLAYERNAME$(gIDs%[i%]),10,60+20*i
NEXT

WEND



Kitty Hello

Code (glbasic) Select

IF NETJOINGAME("127.0.0.1", 12345)
STDOUT "join\n"
bJoin=TRUE
p1=NETCREATEPLAYER("p1")
p2=NETCREATEPLAYER("p2")
ELSE
STDOUT "host\n"
NETHOSTGAME(12345)
ENDIF


WHILE TRUE
num% = NETNUMPLAYERS()
STDOUT "ID  - Player name\n"
FOR i% = 0 TO num%-1
   gIDs% = NETGETPLAYERID(i%)
   STDOUT gIDs% + " - " + NETPLAYERNAME$(gIDs%)+"\n"
NEXT
KEYWAIT
IF moo=0 AND bJoin
moo=1
NETDESTROYPLAYER p1
NETDESTROYPLAYER p2
ENDIF
WEND

Run twice, works for me. Can you change it to reproduce your behaviour?

Yommy

Quite random, i cannot recreate this bug o_O
im not sure what i was doing wrong the first time.

you fixed it Gernot, iseewhatyoudidthar ("\(^_^)/")

Yommy
glad to be back :D

Kitty Hello

Yes, we're glad, too. What was wrong?