Hello.
Me and a friend are having a few issues with our code, he has built the server.dba and I have the client.dba
we have come accross an error about an array not existing or array subscript out of bounds (Runtime error 118) which appears at this line:
ar_players(playerNum).plx = net get float()
When the server is running (at a diffrence place so I use his external ip to connect) I can get on to it fine, but when he joins on his internal ip (it has been coded so that you can use either) it crashes out with the error above on that line.
neither of us can figure out what is causing it.
Is there something wrong in our code?
I know its a mess, but it works
client.dba
REM Project: Void
REM Authors: Richard Sparrow & Jamie Davies
REM Team: Silentium Games
OPEN TO READ 1, "assets/system/server.dat"
READ STRING 1,server$
READ STRING 1,inters$
CLOSE FILE 1
debug_mode = 1
global server_ip as string = server$
global intern_ip as string = inters$
#constant SENDGAP 0
#constant MAXIMUM_PLAYERS 10
#constant MESSAGE_ID_NAME 0
#constant MESSAGE_ID_GENERAL 1
#constant MESSAGE_ID_GENERALFULL 2
#constant MESSAGE_ID_PLAYERJOINED 3
#constant MESSAGE_ID_PLAYERQUIT 4
thisver$ = "Alpha 1.0 - Build 160912-4"
current_state$ = "INIT"
DO
if current_state$ = "INIT"
SYNC ON:SYNC RATE 30
desktopwidth = DESKTOP WIDTH():desktopheight = DESKTOP HEIGHT()
if desktopwidth > 1280 then desktopwidth = 1280
if desktopheight > 1024 then desktopheight = 1024
if debug_mode = 1
desktopheight = 480
desktopwidth = 640
endif
SET DISPLAY MODE desktopwidth,desktopheight,32,1
if debug_mode <> 1
SET WINDOW OFF:HIDE MOUSE
endif
current_state$ = "SPLASH"
error_message$ = ""
endif
if current_state$ = "SPLASH"
bar(0):LOAD IMAGE "assets/system/s3.png",1002
bar(8.3):LOAD IMAGE "assets/system/s1.png",1000
bar(16.6):LOAD IMAGE "assets/system/s2.png",1001
bar(25):LOAD IMAGE "assets/system/g2.png",1008
bar(33.3):LOAD IMAGE "assets/system/s4.png",1003
bar(41.6):LOAD IMAGE "assets/system/s5.png",1004
bar(50):LOAD IMAGE "assets/system/s6.png",1005
bar(58.3):LOAD IMAGE "assets/system/s7.png",1006
bar(66.6):LOAD IMAGE "assets/system/g1.png",1007
bar(75):LOAD IMAGE "assets/system/menu-1.png",1100
LOAD IMAGE "assets/system/menu-2.png",1102
LOAD IMAGE "assets/system/menu-3.png",1103
LOAD IMAGE "assets/system/err_box.png",1104
bar(83.3):LOAD IMAGE "assets/system/void-logo.png",1101
bar(91.6):LOAD IMAGE "assets/system/mainmenu.jpg",1009
bar(100)
logo_y = desktopheight/2 - 85:logo_x = desktopwidth/2 - 203
l=logo_x
k=1006
CLS:SYNC:wait 1000
REPEAT:CLS
PASTE IMAGE k,logo_x,logo_y:
SYNC:k=k-1:wait 100:UNTIL k < 1000
l=0
REPEAT:CLS
k=int(rnd(5))+1000:x=int(rnd(10)):PASTE IMAGE k,logo_x,logo_y
if x < 3 then PASTE IMAGE 1007,int(rnd(desktopwidth))+300,int(rnd(desktopheight))+300,1
if x > 7 then PASTE IMAGE 1008,int(rnd(desktopwidth))+300,int(rnd(desktopheight))+300,1
l=l+1:sync:wait int(rnd(100))
UNTIL l > 10:k=1000
REPEAT:CLS
PASTE IMAGE k,logo_x,logo_y:
SYNC:k=k+1:wait 100:UNTIL k > 1006
CLS:SYNC
current_state$ = "LOAD MAIN MENU"
endif
if current_state$ = "LOAD MAIN MENU"
WAIT 1000
SHOW MOUSE
menu_s = 1
menu_x = desktopwidth/2 - 144
username$= ""
password$= ""
SYNC
current_state$ = "MAIN MENU"
endif
if current_state$ = "MAIN MENU"
mm#=mm#+0.3
px# = sin(mm#) * 25 - 150
py# = cos(mm#) * 25 - 150
PASTE IMAGE 1009,px#,py#
PASTE IMAGE 1100,menu_x,200,1
PASTE IMAGE 1101,desktopwidth/2-188,30,1
text menu_x+16,210,"Login!"
text menu_x+16,250,"Username"
text menu_x+16,320,"Password"
text menu_x+16,425,"Please register for an account"
text menu_x+16,440,"at our website"
text menu_x+16,455,"http://www.silentium.co.uk/void"
text 10,desktopheight-15,thisver$
PASTE IMAGE 1102,menu_x+11,278
PASTE IMAGE 1102,menu_x+11,348
PASTE IMAGE 1102,menu_x+11,490
PASTE IMAGE 1102,menu_x+11,540
PASTE IMAGE 1103,menu_x+139,382
text menu_x+22,285,username$
passseen$ = ""
for k=1 to len(password$)
passseen$ = passseen$ + "*"
next k
text menu_x+22,355,passseen$
text menu_x+190,389,"Login"
text menu_x+110,497,"Options"
text menu_x+120,547,"Exit"
if error_message$ <> ""
PASTE IMAGE 1104,(desktopwidth/2)-290,(desktopheight/2)-40,1
center text desktopwidth/2,(desktopheight/2)-27,error_message$
PASTE IMAGE 1103,(desktopwidth/2)-(137/2),(desktopheight/2)
center text (desktopwidth/2),(desktopheight/2)+7,"OK"
if mousex() > (desktopwidth/2)-(137/2) and mousey() > (desktopheight/2) and mousex() < (desktopwidth/2)+(137/2) and mousey() < (desktopheight/2)+30 and mouseclick() then error_message$=""
else
if mousex() > menu_x + 11 and mousey() > 278 and mousex() < menu_x + 276 and mousey() < 308 and mouseclick()
menu_s = 1
rem tim = timer()
endif
if mousex() > menu_x + 11 and mousey() > 348 and mousex() < menu_x + 276 and mousey() < 378 and mouseclick()
menu_s = 2
rem tim = timer()
endif
if mousex() > menu_x + 139 and mousey() > 382 and mousex() < menu_x + 276 and mousey() < 412 and mouseclick()
menu_s = 3
endif
if mousex() > menu_x + 11 and mousey() > 490 and mousex() < menu_x + 276 and mousey() < 520 and mouseclick()
menu_s = 4
endif
if mousex() >menu_x + 11 and mousey() > 540 and mousex() < menu_x + 276 and mousey() < 570 and mouseclick()
goto quitgame
endif
if menu_s = 1
a$ = ENTRY$(1)
if keystate(14) and timer()>tim+100
username$ = left$(username$,len(username$)-1)
a$=""
tim = timer()
endif
username$=username$+a$
text menu_x+22,285,username$ + "|"
if keystate(15)
menu_s = 2
clear entry buffer
endif
endif
if menu_s = 2
a$ = ENTRY$(1)
if keystate(14) and timer()>tim+100
password$ = left$(password$,len(password$)-1)
a$=""
tim = timer()
endif
password$ = password$ + a$
passseen$ = ""
for k=1 to len(password$)
passseen$ = passseen$ + "*"
next k
text menu_x+22,355,passseen$ + "|"
if keystate(28) then menu_s = 3
endif
if menu_s = 3
current_state$ = "SETTYPES"
menu_s = 1
endif
if menu_s = 4
current_state$ = "OPTIONS"
menu_s = 1
endif
if old_s <> menu_s then clear entry buffer
endif
SYNC
endif
if current_state$ = "OPTIONS"
endif
if current_state$ = "AUTHENTICATE"
result = net connect(server_ip)
if not result
result2 = net connect(intern_ip)
if not result2
error_message$ = "Error Connecting to VOIDNet. Please try again later."
current_state$ = "MAIN MENU"
error=1
CLS
SYNC
endif
endif
if error = 0
current_state$ = "INITPLANET"
net put byte MESSAGE_ID_NAME
net put string username$
net send
playerid=1
ar_players(playerid).ship = 13
remstart
repeat
until net get message() = 0
select net get byte()
case MESSAGE_ID_NAME
playerid = net get int()
ar_players(playerid).name = username$
ar_players(playerid).plx = net get float()
ar_players(playerid).ply = net get float()
ar_players(playerid).angle = 0
ar_players(playerid).ship = net get int()
ar_players(playerid).speed = 0
ar_players(playerid).mspee = 20
print "Message Recieved"+ str$(ar_players(playerid).ship)
endcase
endselect
remend
else
error=0
endif
endif
if current_state$ = "SETTYPES"
CLS
paste image 1101,desktopwidth/2-188,desktopheight/2,1
center text desktopwidth/2,desktopheight-20,"Connecting..."
bar(0)
TYPE planet
id AS INTEGER
name AS STRING
typ AS INTEGER
plx AS FLOAT
ply AS FLOAT
ENDTYPE
TYPE players
id AS FLOAT
name AS STRING
ship AS INTEGER
angle AS FLOAT
plx AS FLOAT
ply AS FLOAT
speed as FLOAT
mspee as FLOAT
ENDTYPE
TYPE planetsp
typ AS INTEGER
plx AS INTEGER
ply AS INTEGER
ENDTYPE
current_state$ = "DIMARRAY"
endif
if current_state$ = "DIMARRAY"
DIM ar_planet(830) AS planet
DIM ar_planesp(830) AS planetsp
DIM ar_players(MAXIMUM_PLAYERS) AS players
current_state$ = "AUTHENTICATE"
endif
if current_state$ = "INITPLANET"
OPEN TO READ 1, "assets/planet/planet.csv"
FOR k=1 TO 830
READ STRING 1, a$
ar_planet(k).id = VAL(FIRST TOKEN$(a$, ","))
ar_planet(k).name = NEXT TOKEN$(",")
ar_planet(k).typ = VAL(NEXT TOKEN$(","))
ar_planet(k).plx = VAL(NEXT TOKEN$(","))
ar_planet(k).ply = VAL(NEXT TOKEN$(","))
NEXT K
FOR k=1 to 830
ar_planesp(k).typ = ar_planet(k).typ
ar_planesp(k).plx = ar_planet(k).plx
ar_planesp(k).ply = ar_planet(k).ply
NEXT K
CLOSE FILE 1
bar(50)
current_state$ = "LOADIMAGES"
endif
if current_state$ = "LOADIMAGES"
LOAD IMAGE "assets/space/1.png",1
LOAD IMAGE "assets/space/2.png",2
LOAD IMAGE "assets/space/3.png",3
LOAD IMAGE "assets/space/4.png",4
LOAD IMAGE "assets/space/1.png",5
LOAD IMAGE "assets/space/2.png",6
LOAD IMAGE "assets/space/3.png",7
LOAD IMAGE "assets/space/4.png",8
LOAD IMAGE "assets/space/5.png",9
LOAD IMAGE "assets/ships/1_1.png",10
LOAD IMAGE "assets/ships/1_2.png",11
LOAD IMAGE "assets/ships/1_3.png",12
LOAD IMAGE "assets/ships/1_4.png",13
LOAD IMAGE "assets/ships/1_5.png",14
LOAD IMAGE "assets/ships/1_6.png",15
LOAD IMAGE "assets/ships/1_7.png",16
LOAD IMAGE "assets/ships/1_8.png",17
LOAD IMAGE "assets/ships/2_1.png",20
LOAD IMAGE "assets/ships/2_2.png",21
LOAD IMAGE "assets/ships/2_3.png",22
LOAD IMAGE "assets/ships/2_4.png",23
LOAD IMAGE "assets/ships/2_5.png",24
LOAD IMAGE "assets/ships/2_6.png",25
LOAD IMAGE "assets/ships/2_7.png",26
LOAD IMAGE "assets/ships/2_8.png",27
LOAD IMAGE "assets/ships/3_1.png",30
LOAD IMAGE "assets/ships/3_2.png",31
LOAD IMAGE "assets/ships/3_3.png",32
LOAD IMAGE "assets/ships/3_4.png",33
LOAD IMAGE "assets/ships/3_5.png",34
LOAD IMAGE "assets/ships/3_6.png",35
LOAD IMAGE "assets/ships/3_7.png",36
LOAD IMAGE "assets/ships/3_8.png",37
LOAD IMAGE "assets/system/ch.png",1010
LOAD IMAGE "assets/planet/planet1.png",100
LOAD IMAGE "assets/planet/planet2.png",101
LOAD IMAGE "assets/planet/planet3.png",102
LOAD IMAGE "assets/planet/planet4.png",103
LOAD IMAGE "assets/planet/planet5.png",104
LOAD IMAGE "assets/planet/planet6.png",105
LOAD IMAGE "assets/planet/planet7.png",106
LOAD IMAGE "assets/planet/planet8.png",107
LOAD IMAGE "assets/planet/planet9.png",108
LOAD IMAGE "assets/planet/planet10.png",109
LOAD IMAGE "assets/planet/planet11.png",110
LOAD IMAGE "assets/planet/planet12.png",111
LOAD IMAGE "assets/planet/planet13.png",112
LOAD IMAGE "assets/planet/planet14.png",113
LOAD IMAGE "assets/planet/planet15.png",114
LOAD IMAGE "assets/planet/planet16.png",115
LOAD IMAGE "assets/planet/planet17.png",116
LOAD IMAGE "assets/planet/planet18.png",117
LOAD IMAGE "assets/planet/planet19.png",118
LOAD IMAGE "assets/planet/planet20.png",119
LOAD IMAGE "assets/planet/sp/planet1.png",120
LOAD IMAGE "assets/planet/sp/planet2.png",121
LOAD IMAGE "assets/planet/sp/planet3.png",122
LOAD IMAGE "assets/planet/sp/planet4.png",123
LOAD IMAGE "assets/planet/sp/planet5.png",124
LOAD IMAGE "assets/planet/sp/planet6.png",125
LOAD IMAGE "assets/planet/sp/planet7.png",126
LOAD IMAGE "assets/planet/sp/planet8.png",127
LOAD IMAGE "assets/planet/sp/planet9.png",128
LOAD IMAGE "assets/planet/sp/planet10.png",129
LOAD IMAGE "assets/planet/sp/planet11.png",130
LOAD IMAGE "assets/planet/sp/planet12.png",131
LOAD IMAGE "assets/planet/sp/planet13.png",132
LOAD IMAGE "assets/planet/sp/planet14.png",133
LOAD IMAGE "assets/planet/sp/planet15.png",134
LOAD IMAGE "assets/planet/sp/planet16.png",135
LOAD IMAGE "assets/planet/sp/planet17.png",136
LOAD IMAGE "assets/planet/sp/planet18.png",137
LOAD IMAGE "assets/planet/sp/planet19.png",138
LOAD IMAGE "assets/planet/sp/planet20.png",139
bar(66.6)
current_state$ = "INITPLAYER"
endif
if current_state$ = "INITPLAYER"
HIDE MOUSE
for k=10 to 17
sprite k,-50,-50,k
offset sprite k,sprite width(k)*.5, sprite height(k)*.5
next k
for k=20 to 27
sprite k,-50,-50,k
offset sprite k,sprite width(k)*.5, sprite height(k)*.5
next k
for k=30 to 37
sprite k,-50,-50,k
offset sprite k,sprite width(k)*.5, sprite height(k)*.5
next k
spx=(screen width()*.5)-(sprite width(ar_players(playerid).ship)*.5)
spy=(screen height()*.5)-(sprite height(ar_players(playerid).ship)*.5)
sprite ar_players(playerid).ship,spx,spy,ar_players(playerid).ship
position mouse spx,spy
ar_players(playerid).mspee = 20
ar_players(playerid).plx = desktopwidth/2
ar_players(playerid).ply = desktopheight/2
bar(83.3)
current_state$ = "INITSPACE"
endif
if current_state$ = "INITSPACE"
DIM SX(9)
DIM SY(9)
k=0
for x = 0 to 2048 step 1024
for y = 0 to 2048 step 1024
k=k+1
SX(k) = x
SY(k) = y
next y
next x
bar(100)
current_state$ = "GAME"
endif
if current_state$ = "GAME"
cls
curMouseX = mousex() - sprite x(ar_players(playerid).ship)
curMouseY = mousey() - sprite y(ar_players(playerid).ship)
ar_players(playerid).angle = -atanfull(curMouseX,curMouseY)
IF KEYSTATE(200) or KEYSTATE(208)
if keystate(200)
ar_players(playerid).speed = ar_players(playerid).speed + 0.4
if ar_players(playerid).speed > ar_players(playerid).mspee then ar_players(playerid).speed = ar_players(playerid).mspee
endif
if keystate(208)
ar_players(playerid).speed = ar_players(playerid).speed - 0.4
if ar_players(playerid).speed < -ar_players(playerid).mspee then ar_players(playerid).speed = -ar_players(playerid).mspee
endif
ELSE
if ar_players(playerid).speed > 0.2 then ar_players(playerid).speed = ar_players(playerid).speed - 0.2
if ar_players(playerid).speed < 0.2 then ar_players(playerid).speed = ar_players(playerid).speed + 0.2
ENDIF
curx# = sprite x(ar_players(playerid).ship)
cury# = sprite y(ar_players(playerid).ship)
move sprite ar_players(playerid).ship,-ar_players(playerid).speed
newx# = sprite x(ar_players(playerid).ship)
newy# = sprite y(ar_players(playerid).ship)
move sprite ar_players(playerid).ship,ar_players(playerid).speed
movx# = curx# - newx#
movy# = cury# - newy#
ar_players(playerid).plx = ar_players(playerid).plx - movx#
ar_players(playerid).ply = ar_players(playerid).ply - movy#
for k = 1 to 9
SX(k) = SX(k) + movx#
SY(k) = SY(k) + movy#
if SX(k)<-1024 then SX(k) = 2048
if SY(k)<-1024 then SY(k) = 2048
if SX(k)>2048 then SX(k) = -1024
if SY(k)>2048 then SY(k) = -1024
PASTE IMAGE k,SX(k),SY(k)
next k
for k = 1 to 830
ar_planet(k).plx = ar_planet(k).plx + movx#
ar_planet(k).ply = ar_planet(k).ply + movy#
if ar_planet(k).plx > -300 and ar_planet(k).ply > -300 and ar_planet(k).plx < desktopwidth and ar_planet(k).ply < desktopheight
text ar_planet(k).plx + 150 - ((len(ar_planet(k).name)/2)*8),ar_planet(k).ply+10,ar_planet(k).name
rem == Fixed by TheComet
PASTE IMAGE ar_planet(k).typ + 99 ,ar_planet(k).plx,ar_planet(k).ply,1
else
tex = ar_planet(k).plx+150
tey = ar_planet(k).ply+150
if tex > -5000 and tex< 5000 and tey>-5000 and tey < 5000
if tex < 0 then tex =0
if tex > desktopwidth - 30 then tex = desktopwidth - 20
if tey < 0 then tey = 0
if tey > desktopheight - 20 then tey = desktopheight - 20
PASTE IMAGE ar_planesp(k).typ + 119,tex,tey,1
endif
endif
next k
net put byte MESSAGE_ID_GENERAL
net put float ar_players(playerid).plx
net put float ar_players(playerid).ply
net put float ar_players(playerid).angle
net put int ar_players(playerid).ship
net put float ar_players(playerid).speed
net send
ROTATE SPRITE ar_players(playerid).ship,ar_players(playerid).angle
SPRITE 1010,mousex(),mousey(),1010
offset sprite 1010,25,25
text 10,10,str$(ar_players(playerid).plx)
text 10,30,str$(ar_players(playerid).ply)
text 10,50,str$(scancode())
SYNC
while net get message()
select net get byte()
case MESSAGE_ID_GENERAL
playerNum = net get int()
ar_players(playerNum).plx = net get float()
ar_players(playerNum).ply = net get float()
ar_players(playerNum).angle = net get float()
ar_players(playerNum).ship = net get int()
ar_players(playerNum).speed = net get float()
SPRITE ar_players(playerNum).ship,ar_players(playerNum).plx,ar_players(playerNum).ply,ar_players(playerNum).ship
ROTATE SPRITE ar_players(playerNum).ship,ar_players(playerNum).angle
endcase
endselect
endwhile
endif
LOOP
REM Functions go here
function bar(P#)
width = 400
height = 5
desktopwidth = DESKTOP WIDTH():desktopheight = DESKTOP HEIGHT()
if desktopwidth > 1280 then desktopwidth = 1280
if desktopheight > 1024 then desktopheight = 1024
x=(desktopwidth / 2) - (width /2)
y=(desktopheight - 30) - (height/2)
P# = P#/100
if P#<0.0 then P#=0.0
rem gradient bar
seg = width / 3
box x-2,y-2,x+width+2,y+height+2,rgb(255,255,255),rgb(255,255,255),rgb(255,255,255),rgb(255,255,255)
box x-1,y-1,x+width+1,y+height+1,rgb(0,0,0),rgb(0,0,0),rgb(0,0,0),rgb(0,0,0)
box x, y, x+seg, y+height, rgb(0,0,0),rgb(0,0,0),rgb(0,85,85),rgb(0,85,85)
box x+seg, y, x+seg+seg, y+height, rgb(0,85,85),rgb(0,85,85),rgb(0,170,170),rgb(0,170,170)
box x+seg+seg, y, x+width, y+height, rgb(0,170,170),rgb(0,170,170),rgb(0,255,255),rgb(0,255,255)
rem empty bit
ink rgb(92,92,92),0
box x+width*P#, y, x+width, y+height
rem highlight
c1 = 0xCCFFFFFF
c2 = 0x33FFFFFF
rem box x, y, x+width, y+height*0.5, c2,c1,c2,c1
ink rgb(255,255,255),rgb(0,0,0)
SYNC
wait 50
endfunction
REM End Game
quitgame:
Server
// VOIDnet 1.0
// Silentium Games 2012
` Constants --------------------------------------
#constant MAXIMUM_PLAYERS 10
#constant MESSAGE_ID_NAME 0
#constant MESSAGE_ID_GENERAL 1 : ` Contains just player data
#constant MESSAGE_ID_GENERALFULL 2 : ` Contains player numbers and player data
#constant MESSAGE_ID_PLAYERJOINED 3
#constant MESSAGE_ID_PLAYERQUIT 4
` ------------------------------------------------
` Types ------------------------------------------
type players
active as boolean
exist AS INTEGER
id AS INTEGER
name AS STRING
ship AS INTEGER
angle AS float
plx AS float
ply AS float
speed as FLOAT
mspee as FLOAT
endtype
` ------------------------------------------------
` Variables --------------------------------------
global dim player(MAXIMUM_PLAYERS) as players
global MOUSE_LBM_PRESSED as boolean
` ------------------------------------------------
sync off
autocam off
result = net host(MAXIMUM_PLAYERS)
if not result
print "Could not start server: "+chr$(34)+net get error()+chr$(34)+"."
print "Press any key to exit."
wait key
end
endif
sync on : sync rate 60
do
cls
text 0, 0, str$(screen fps())
text 0, 13, "There are "+str$(net get player amount())+" players connected."
text 0,300, "KICK: "
for x = 1 to MAXIMUM_PLAYERS
if player(x).exist = 1
text 0, 25*x, str$(player(x).id)+player(x).name+str$(player(x).plx)+str$(player(x).ply)
endif
next x
if spacekey() then net kick 1
HandleNetwork()
sync
loop
function HandleNetwork()
` Player joining ------------
` ---------------------------
result = net player joined()
while result > 0
player(result).exist = 1
// net put byte MESSAGE_ID_GENERAL
// net put int result
// net put float 500 //plx
// net put float 500 //ply
// net put int 10 //ship
// net send result
rem send states & positions of players
net put byte MESSAGE_ID_GENERAL
for x = 1 to MAXIMUM_PLAYERS
if net player connected(x)
if player(x).active
net put int x
net put float player(x).plx
net put float player(x).ply
net put float player(x).angle
net put int player(x).ship
net put float player(x).speed
endif
endif
net send result
next x
result = net player joined()
endwhile
` Player leaving -------------
` ----------------------------
result = net player left()
while result > 0
ResetPlayer(result)
net put byte MESSAGE_ID_PLAYERQUIT
net put byte result
net send all
result = net player left()
endwhile
` Message processing ---------
` ----------------------------
while net get message()
playerNum = net message from()
select net get byte()
case MESSAGE_ID_NAME
playerNum = net message from()
player(playerNum).name = net get string()
player(playerNum).exist = 1
player(playerNum).active = 1
player(playerNum).id = int(playerNum)
net put int playerNum
net send playerNum
` Notify other players
net put byte MESSAGE_ID_PLAYERJOINED
net put int playerNum
net put string player(playerNum).name
for x = 1 to MAXIMUM_PLAYERS
if net player connected(x)
if x <> playerNum
net send x, 1
endif
endif
next x
` Clear message data
net send 0
endcase
case MESSAGE_ID_GENERAL
player(playerNum).plx = net get float()
player(playerNum).ply = net get float()
player(playerNum).angle = net get float()
player(playerNum).ship = net get int()
player(playerNum).speed = net get float()
` Forward message on
net put byte MESSAGE_ID_GENERAL
net put int playerNum
net put float player(playerNum).plx
net put float player(playerNum).ply
net put float player(playerNum).angle
net put int player(playerNum).ship
net put float player(playerNum).speed
SendAllExcept(playerNum)
endcase
endselect
endwhile
endfunction
function ResetPlayer(playerNum as integer)
player(playerNum).active = 0
player(playerNum).exist = 0
player(playerNum).id = 0
player(playerNum).name = ""
player(playerNum).ship = 0
player(playerNum).plx = 0
player(playerNum).ply = 0
player(playerNum).speed = 0
player(playerNum).mspee = 0
endfunction
function SendAllExcept(except as integer)
for x = 1 to MAXIMUM_PLAYERS
if net player connected(x)
if x <> except
net send x, 1
endif
endif
next x
net send 0
endfunction
Thanks
10 PRINT "Hello World"
20 GOTO 10