Author Topic: NETNUMPLAYERS() returns wrong value  (Read 1586 times)

Offline Yommy

  • Mc. Print
  • *
  • Posts: 14
    • View Profile
NETNUMPLAYERS() returns wrong value
« on: 2009-Aug-25 »
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


Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10746
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: NETNUMPLAYERS() returns wrong value
« Reply #1 on: 2009-Aug-25 »
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?

Offline Yommy

  • Mc. Print
  • *
  • Posts: 14
    • View Profile
Re: NETNUMPLAYERS() returns wrong value
« Reply #2 on: 2009-Aug-27 »
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

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10746
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: NETNUMPLAYERS() returns wrong value
« Reply #3 on: 2009-Aug-27 »
Yes, we're glad, too. What was wrong?