Nowhere in your code do you host the game. In order for computers to be able to connect to each other you need one host, and the rest clients.
Further, you also try to send data with multisync before you set up the connections. I don't think that's going to work.
I modified your code to this:
SET WINDOW LAYOUT 0, 1, 2
width = 1280
height = 720
set display mode width, height, 32, 1 ``set any display mode you want
` Constants -------------------------------------
#constant SENDGAP 0
#constant MAXIMUM_PLAYERS 3200
#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
#constant FLAG_UP 1
#constant FLAG_DOWN 2
#constant FLAG_LEFT 4
#constant FLAG_RIGHT 8
#Constant FLAG_ROLL_LEFT 16
#Constant FLAG_ROLL_RIGHT 32
#Constant FLAG_PITCH_UP 64
#Constant FLAG_PITCH_DOWN 128
` Constants -----------------------------------
#constant MAXIMUM_TEXTLINE_AMOUNT 30
#constant MESSAGE_ID_FAIL 0
#constant MESSAGE_ID_SUCCESS 1
#constant MESSAGE_ID_REGISTER 0
#constant MESSAGE_ID_LOGIN 1
#constant MESSAGE_ID_CHAT 2
#constant MESSAGE_ID_NEWCLIENT 4
#constant MESSAGE_ID_CLIENTLEFT 5
` ---------------------------------------------
` Variables -----------------------------------
dim TextLines(MAXIMUM_TEXTLINE_AMOUNT) as string
global CURRENT_TEXTLINE_AMOUNT as integer
global CURRENT_TEXT_ENTRY as string
global KEYDOWN_RETURN as boolean
` ----------------------------------
` -----------------------------------------------
` Types ------------------------------------------
type player_data
exist as boolean
name as string
x as float
Y as float
z as float
realx as float
realz as float
angle as float
key_up as boolean
key_down as boolean
key_left as boolean
key_right as boolean
endtype
Type Object
File as String
x as float
y as float
z as float
Rotate as Byte
endtype
Type GameType
PvE as string
PvP as string
Normal as string
RP as string
ClanBattle
EndType
` -----------------------------------------------
` Variables --------------------------------------
global LASTSENT as integer
global NAME as string
global dim player(MAXIMUM_PLAYERS) as player_data
global lastFlags as byte
global toSend
` ------------------------------------------------
sync off
autocam off
input "1 - host 2 - client :",Iam
rem host or join
if Iam = 1
success = net host( MAXIMUM_PLAYERS )
if not success
print "Could not connect: "+chr$(34)+net get error()+chr$(34)+"."
print "Press any key to exit."
wait key
end
endif
endif
if Iam = 2
ip$="127.0.0.1"
result = net connect(ip$)
if not result
print "Could not connect: "+chr$(34)+net get error()+chr$(34)+"."
print "Press any key to exit."
wait key
end
endif
input "Name: ", NAME
net put byte MESSAGE_ID_NAME
net put string NAME
net send
endif
if Iam < 1 or Iam > 2 then end
sync on
sync rate 60
width = 1280
height = 720
set display mode width, height, 32, 1 ``set any display mode you want
`maximize window
set window position width/3,height/3
set ambient light 20
backdrop on
color backdrop 0
set camera fov 45
basewidth = width ``this is the mode for which you GUI was designed
baseheight = height
xMultiplier(width,basewidth)
yMultiplier(height,baseheight)
set global collision on
load object "Media/Nova.x",1
load image "Media/star.png",98362,1
make object cube 1999,20
position object 1999,0,0,100
ghost object on 1999
set object collision on 1
set object collision to polygons 1
set object collision to boxes 1999
Health=100
health_time =timer()
healthRecovery_delay =5000
objnum = 1
Lvl=1
PlayerExp=0
XPMod#=1.34
rem ** you can start out with whatever number u choose
rem ** in order to make your first level up Xp=(whatever number)
Xp=250
Txp=0
TotalXp=0
Dim Object(100) as Object
Object(1).File="Media/Nova.x"
Object(1).x=0
Object(1).y=0
Object(1).z=0
Object(1).Rotate=0
player(x).name=NAME
if file exist("PlayerData.bc2")
delete file "PlayerData.bc2"
Endif
Open to write 1,"PlayerData.bc2"
for t=1 to 3
write string 1,Object(t).File
write float 1,Object(t).x
write float 1,Object(t).y
write float 1,Object(t).z
write byte 1,Object(t).Rotate
write string 1,player(x).name
next t
close file 1
` Clear the data
for t=1 to 3
Object(t).File="Media/Nova.x"
Object(t).x=0
Object(t).y=0
Object(t).z=0
Object(t).Rotate=0
player(x).name=player(x).name
next t
print "Data cleared"
print ""
for t=1 to 3
print "Object("+str$(t)+")"
print " Filename = "+Object(t).File
print " x coordinate = "+str$(Object(t).x)
print " y coordinate = "+str$(Object(t).y)
print " z coordinate = "+str$(Object(t).z)
print " Rotate = "+str$(Object(t).Rotate)
print "Name: "+player(x).name
print ""
print ""
next t
` Read the data
open to read 1,"PlayerData.bc2"
for t=1 to 3
read string 1,Object(t).File
read float 1,Object(t).x
read float 1,Object(t).y
read float 1,Object(t).z
read byte 1,Object(t).Rotate
read string 1,player(x).name
next t
close file 1
` Show the data (after its been loaded from the file)
cls
print "Data loaded from file."
print ""
for t=1 to 3
print "Object("+str$(t)+")"
print " Filename = "+Object(t).File
print " x coordinate = "+str$(Object(t).x)
print " y coordinate = "+str$(Object(t).y)
print " z coordinate = "+str$(Object(t).z)
print " Rotate = "+str$(Object(t).Rotate)
print "Name: "+player(x).name
print ""
print ""
next t
do
if returnkey()=1
HandleInput()
endif
while net get message()
ProcessMessage()
endwhile
yrotate object 1999,1
update_time=timer()
gosub draw_starfield
text 0, 400, str$(screen fps())
box 30 * xMulti,27 * yMulti,31+Health * xMulti,35 * yMulti,rgb(175,0,0),rgb(175,0,0),rgb(200,0,0),rgb(200,0,0)
Health$="Health: "+str$(Health)+"%" : text 5,5,Health$
if spacekey()=1
dec Health,1
endif
`if health_time=timer()
if object hit (1999,1)
XpIncVal=50
inc PlayerExp, XpIncVal
inc TotalXp, XpIncVal
endif
if health=<0
CenterBox(screen width()/2, screen height()/2, 200, 26, "You're Dead!")
endif
if returnkey()=1
inc PlayerExp,1
inc TotalXp,1
Endif
Lv$="Level: "+str$(Lvl) : text 5,50,Lv$
GainedXp$="Xp: "+str$(PlayerExp) : text 5,75,GainedXp$
NeededXp$="Xp needed: "+str$(Xp) : text 5,100,NeededXp$
TotalXp$="Total XP: "+str$(TotalXp) : text 5,125,TotalXp$
if PlayerExp=Xp
Lvl=Lvl+1
dec PlayerExp,PlayerExp
Xp=Xp*XPMod#
Txp=PlayerExp
endif
if net connected()
HandleNetwork()
else
CenterBox(screen width()/2, screen height()/2, 200, 26, "Connection to server lost.")
endif
HandleControls()
HandleMovement()
`HandleCamera()
camera_follow(0,1,object scale z(1)-50,1)
sync
loop
function HandleMovement()
for x = 1 to MAXIMUM_PLAYERS
if player(x).exist
rem real values are the actual current values
if player(x).key_up
player(x).realx = player(x).realx + sin(player(x).angle)
player(x).realz = player(x).realz + cos(player(x).angle)
endif
if player(x).key_down
player(x).realx = player(x).realx - sin(player(x).angle)
player(x).realz = player(x).realz - cos(player(x).angle)
endif
if player(x).key_left then player(x).angle = wrapvalue(player(x).angle-1)
if player(x).key_right then player(x).angle = wrapvalue(player(x).angle+1)
distx# = abs(player(x).realx-player(x).x)
speedx# = distx# / 10.0
distz# = abs(player(x).realz-player(x).z)
speedz# = distz# / 10.0
angle# = atanfull(player(x).realx-player(x).x, player(x).realz-player(x).z)
player(x).x = player(x).x + (sin(angle#)*speedx#)
player(x).z = player(x).z + (cos(angle#)*speedz#)
yrotate object x+10, player(x).angle
position object x+10, player(x).x, 0, player(x).z
center text object screen x(x+10), object screen y(x+10)-13, player(x).name
endif
next x
endfunction
function HandleNetwork()
while net get message()
inc MSGSRECVD
select net get byte()
case MESSAGE_ID_GENERAL
playerNum = net get byte()
player(playerNum).realx = net get float()
player(playerNum).realz = net get float()
player(playerNum).angle = net get byte() * 1.411
ApplyFlags(playerNum, net get byte())
endcase
case MESSAGE_ID_GENERALFULL
while net get message remainder() > 0
playerNum = net get byte()
player(playerNum).exist = 1
player(playerNum).name = net get string()
player(playerNum).realx = net get float()
player(playerNum).realz = net get float()
player(playerNum).angle = net get byte() * 1.411
ApplyFlags(playerNum, net get byte())
make object cube playerNum+10, 10
ApplyPosition(playerNum)
endwhile
endcase
case MESSAGE_ID_PLAYERJOINED
playerNum = net get byte()
player(playerNum).exist = 1
player(playerNum).name = net get string()
make object cube playerNum+10, 10
endcase
case MESSAGE_ID_PLAYERQUIT:
ResetPlayer(net get byte())
endcase
endselect
endwhile
if toSend and LASTSENT+SENDGAP<timer()
net put byte MESSAGE_ID_GENERAL
net put float object position x(1)
net put float object position z(1)
net put byte (object angle y(1) / 1.411)
flags = (upkey() || downkey() << 1 || leftkey() << 2 || rightkey() << 3)
net put byte flags
net send
toSend = 0
endif
endfunction
function HandleControls()
flags = 0
if upkey() then move object 1, 1 : flags = flags || FLAG_UP `or keystate (17)=1
if downkey() then move object 1, -1 : flags = flags || FLAG_DOWN `or keystate (31)=1
if leftkey() or keystate (30)=1 then yrotate object 1, wrapvalue(object angle y(1)-1) : flags = flags || FLAG_LEFT
if rightkey() or keystate (32)=1 then yrotate object 1, wrapvalue(object angle y(1)+1) : flags = flags || FLAG_RIGHT
if keystate (16)=1 then zrotate object 1, wrapvalue(object angle z(1)+1) : flags = flags || FLAG_ROLL_LEFT
if keystate (18)=1 then zrotate object 1, wrapvalue(object angle z(1)-1) : flags = flags || FLAG_ROLL_RIGHT
if keystate (17)=1 then xrotate object 1,object angle x(1)+1 : flags = flags || FLAG_PITCH_UP
if keystate (31)=1 then xrotate object 1,object angle x(1)-1 : flags = flags || FLAG_PITCH_DOWN
if flags <> lastFlags
toSend = 1
lastFlags = flags
LASTSENT = timer()
endif
endfunction
function HandleCamera()
xPos# = object position x(1) + cos(270-object angle y(1)) * 50
zPos# = object position z(1) + sin(270-object angle y(1)) * 500
`position camera xPos#, 90, zPos#
`point camera object position x(1), 40, object position z(1)
set camera to follow object position x(1), object position y(1), object position z(1), 25, object scale z(1), 10, 1, 1
endfunction
function ResetPlayer(playerNum as integer)
if object exist(playerNum+10) then delete object playerNum+10
player(playerNum).exist = 0
player(playerNum).name = ""
player(playerNum).x = 0
player(playerNum).z = 0
player(playerNum).angle = 0
player(playerNum).key_up = 0
player(playerNum).key_down = 0
player(playerNum).key_left = 0
player(playerNum).key_right = 0
endfunction
function ApplyFlags(playerNum as integer, flags as integer)
if flags && FLAG_UP
player(playerNum).key_up = 1
else
player(playerNum).key_up = 0
endif
if flags && FLAG_DOWN
player(playerNum).key_down = 1
else
player(playerNum).key_down = 0
endif
if flags && FLAG_LEFT
player(playerNum).key_left = 1
else
player(playerNum).key_left = 0
endif
if flags && FLAG_RIGHT
player(playerNum).key_right = 1
else
player(playerNum).key_right = 0
endif
endfunction
function ApplyPosition(playerNum as integer)
position object playerNum+10, player(playerNum).x, 0, player(playerNum).z
yrotate object playerNum+10, player(playerNum).angle
endfunction
function CenterBox(x as integer, y as integer, xSize as integer, ySize as integer, textString as string)
xPos = x-(xSize/2)
yPos = y-(ySize/2)
ink rgb(200, 200, 200), 0
box xPos, yPos, xPos+xSize, yPos+ySize
ink rgb(255, 255, 255), 0
center text x, y-(text height("A")/2), textString
endfunction
function CameraFollowObject(Camera,Object,FollowX#,FollowY#,FollowZ#,XAng#,Yang#,ZAng#)
xpos#=object position x(Object)+(FollowZ#*cos(object angle x(Object))+FollowY#*sin(object angle x(Object)))*sin(object angle y(Object))+FollowX#*cos(object angle y(Object))
ypos#=object position y(Object)-FollowZ#*sin(object angle x(Object))+FollowY#*cos(object angle x(Object))
zpos#=object position z(Object)+(FollowZ#*cos(object angle x(Object))+FollowY#*sin(object angle x(Object)))*cos(object angle y(Object))-FollowX#*sin(object angle y(Object))
position camera Camera,xpos#,ypos#,zpos#
set camera to object orientation Camera,Object
pitch camera down Camera,XAng#
turn camera right Camera,YAng#
roll camera left Camera,ZAng#
endfunction
function third_person_camera(obj#,cam#,dist#,height#)
rem this sets camera's x angle back to 0
pitch camera up height#
rem positions camera in object position
position camera cam#,object position x(obj#),object position y(obj#),object position z(obj#)
rem rotate camera to object angles
set camera to object orientation cam#,obj#
rem tilt camera
pitch camera down height#
rem move camera at a distance away
move camera -dist#
endfunction
function xMultiplier(x,basex)
xMulti = x / basex
endfunction xMulti
function yMultiplier(y,basey)
yMulti = y / basey
endfunction yMulti
draw_starfield:
rem base sprite number
base=600000
rem How widely to spread the stars
spread=1000
rem How many starts to display
stars=1000
rem The initial distance to start the stars displaying
dist=-50
`Calculate a point in front of the camera to start drawing the starfield
cx#=camera position x()
cy#=camera position y()
cz#=camera position z()
pick screen screen width()/2,screen height()/2,dist
sx#=get pick vector x()
sy#=get pick vector y()
sz#=get pick vector z()
if object exist(600000)=0
make object plane 600000,.5,.5
for i=600001 to 600000+stars
clone object i,600000
rem stars should not be affected by light or included in collisions
set object light i,0
set object collision off i
position object i,rnd(spread*2)-spread,rnd(spread*2)-spread,camera position z()+rnd(dist)
next i
endif
for i=600000 to 600000+stars
`reposition stars if they are out of camera shot
if object in screen(i)=0
position object i,cx#+sx#+(rnd(spread)-(spread/2)),cy#+sy#+(rnd(spread)-(spread/2)),cz#+sz#+(rnd(spread*2)-(spread/2))
endif
`Calculate distance of star from camera and scale star accordingly
dist#=distance(cx#,cy#,cz#,i)
scale object i,.1*(dist#*2),.1*(dist#*2),2000*speed#
set object to object orientation i,1
rem The multiple of 1.2 will need to be changed depending on the frame rate.
rem This value works best with a sync rate of 60
move object i,speed#*-1.2
next i
return
function distance(x1#,y1#,z1#,obj)
x2#=object position x(obj)
y2#=object position y(obj)
z2#=object position z(obj)
dist#=sqrt((x1#-x2#)*(x1#-x2#)+(y1#-y2#)*(y1#-y2#)+(z1#-z2#)*(z1#-z2#))
endfunction dist#
function camera_follow(cam as integer,object as integer,maxdist# as float,smoothing as integer)
`capture camera positions
camx#=camera position x(cam)
camy#=camera position y(cam)
camz#=camera position z(cam)
`capture object positions
objx#=object position x(object)
objy#=object position y(object)
objz#=object position z(object)
`get the distance between object and camera
dist#=abs(sqrt(((camx#-objx#)^2)+((camy#-objy#)^2)+((camz#-objz#)^2)))
`calculate the x and z of where the camera should end up around the
`object with a buffer radius of maxdist#
goalx#=(objx#+(sin(atanfull((camx#-objx#),(camz#-objz#)))*maxdist#))
goalz#=(objz#+(cos(atanfull((camx#-objx#),(camz#-objz#)))*maxdist#))
`calculate the new x and z for the camera if the object strays too far away
if dist#>maxdist#
camx#=curvevalue(goalx#,camx#,smoothing)
camz#=curvevalue(goalz#,camz#,smoothing)
endif
`calculate the camera's height at object position, plus 1-1/5 the object's height
camy#=curvevalue(objy#+((object size y(object)/5)*6),camy#,smoothing)
`point the camera at the object
point camera cam,objx#,objy#,objz#
`position the camera on the new calculated destination
position camera cam,camx#,camy#,camz#
endfunction
function HandleInput()
` Get new text input
newData$ = entry$()
if newData$ <> ""
CURRENT_TEXT_ENTRY = CURRENT_TEXT_ENTRY + newData$
clear entry buffer
` Process backspace
lenHigh = len(CURRENT_TEXT_ENTRY)
lenLow = lenHigh - len(newData$)
for x = lenHigh to lenLow step -1
char = asc(mid$(CURRENT_TEXT_ENTRY, x))
if char = 8
CURRENT_TEXT_ENTRY = left$(CURRENT_TEXT_ENTRY, x-2) + right$(CURRENT_TEXT_ENTRY, len(CURRENT_TEXT_ENTRY)-x)
else
if char < 32
CURRENT_TEXT_ENTRY = left$(CURRENT_TEXT_ENTRY, x-1) + right$(CURRENT_TEXT_ENTRY, len(CURRENT_TEXT_ENTRY)-x)
endif
endif
next x
DrawEntry()
endif
if returnkey()
if not KEYDOWN_RETURN
if CURRENT_TEXT_ENTRY <> ""
` Send chat message
net put byte MESSAGE_ID_CHAT
net put string CURRENT_TEXT_ENTRY
net send
CURRENT_TEXT_ENTRY = ""
DrawEntry()
endif
KEYDOWN_RETURN = 1
endif
else
if KEYDOWN_RETURN
KEYDOWN_RETURN = 0
endif
endif
endfunction
function ProcessMessage()
msgID = net get byte()
select msgID
case MESSAGE_ID_CHAT
username$ = net get string()
message$ = net get string()
AddTextLine("<"+username$+"> "+message$)
endcase
case MESSAGE_ID_NAME
while net get message remainder() > 0
if name$ <> "" then name$ = name$ + ", "
name$ = name$ + net get string()
endwhile
AddTextLine("Name list: "+name$+".")
endcase
case MESSAGE_ID_NEWCLIENT
AddTextLine(net get string()+" has joined.")
endcase
case MESSAGE_ID_CLIENTLEFT
AddTextLine(net get string()+" has left.")
endcase
endselect
endfunction
function AddTextLine(textLine as string)
` If message buffer full, scroll
if CURRENT_TEXTLINE_AMOUNT = MAXIMUM_TEXTLINE_AMOUNT
TextLines(CURRENT_TEXTLINE_AMOUNT) = textLine
for x = 1 to MAXIMUM_TEXTLINE_AMOUNT
TextLines(x-1) = TextLines(x)
next x
TextLines(MAXIMUM_TEXTLINE_AMOUNT) = ""
DrawTextLines()
else
TextLines(CURRENT_TEXTLINE_AMOUNT) = textLine
inc CURRENT_TEXTLINE_AMOUNT
text 0, (CURRENT_TEXTLINE_AMOUNT-1)*13, TextLines((CURRENT_TEXTLINE_AMOUNT-1))
endif
endfunction
function DrawTextLines()
ink 0, 0
box 0, 0, screen width(), MAXIMUM_TEXTLINE_AMOUNT*13
ink rgb(255, 255, 255), 0
for x = 0 to CURRENT_TEXTLINE_AMOUNT
text 0, x*13, TextLines(x)
next x
line 0, (MAXIMUM_TEXTLINE_AMOUNT+1)*13, 640, (MAXIMUM_TEXTLINE_AMOUNT+1)*13
endfunction
function DrawEntry()
ink rgb(100, 100, 100), 0
box 0, 460, 640, 480
ink rgb(255, 255, 255), 0
text 0, 463, "> "+CURRENT_TEXT_ENTRY
endfunction
function SleepApplication(pauseTime as integer)
if not dll exist(255) then load dll "kernel32.dll", 255
call dll 255, "Sleep", pauseTime
endfunction
I can't test it though because you didn't supply any media.
TheComet