well I wiped everything and rewrote it from scratch. I did everything the same, and its sending the message now. This makes me realize I have no clue what Im doing, but its working... LoL
startmenu:
if startload = 0 //startload 1 is the first screen you see, with Host or Join option
AddVirtualButton(1, centerx, 300, 100)
CreateText(1, "Host Game")
SetTextSize(1, 75)
SetTextPosition(1, centerx - (GetTextTotalWidth(1)/2), 175)
AddVirtualButton(2, centerx, 500, 100)
CreateText(2, "Join Game")
SetTextSize(2, 75)
SetTextPosition(2, centerx - (GetTextTotalWidth(2)/2), 375)
startload = 1
hosting = 1
NetworkID = 0
level = 0
endif
if startload = 1 //startload 1 means you have selected either to host or to join
if GetVirtualButtonPressed(1) = 1 //you have pressed the host button,
deletetext(1)
DeleteText(2)
DeleteVirtualButton(1)
DeleteVirtualButton(2)
NetworkID = HostNetwork("TagNet", "Player 1", 44445)
hosting = 1
startload = 2
endif
endif
if startload = 1
if GetVirtualButtonPressed(2) = 1 //you have pressed the join network button
NetworkID = JoinNetwork("TagNet", "Player 2") //joins TagNet network
hosting = 0 //you are not a host (will be used for recieveing messages)
startload = 4
endif
endif
if startload = 2 //startload 2 is only seen by host, creates buttons for level select
CreateText(8, "SELECT STAGE")
SetTextSize(8, 100)
SetTextPosition(8, centerx - (GetTextTotalWidth(8)/2), 50)
AddVirtualButton(1, swidth * .25, 300, 100)
CreateText(1, "Concrete Jungle")
SetTextSize(1, 30)
SetTextPosition(1, (swidth * .25) - (GetTextTotalWidth(1) / 2), 200)
AddVirtualButton(2, swidth * .50, 300, 100)
CreateText(2, "Junk Yard")
settextsize(2, 30)
SetTextPosition(2, (swidth * .50) - (GetTextTotalWidth(2) / 2), 200)
AddVirtualButton(3, swidth * .75, 300, 100)
AddVirtualButton(4, swidth * .25, 600, 100)
AddVirtualButton(5, swidth * .50, 600, 100)
AddVirtualButton(6, swidth * .75, 600, 100)
AddVirtualButton(7, 100, sheight - 100, 100) //this will be the back button
startload = 3 //once buttons are loaded we go to startload 3
endif
if startload = 3 //startload 3 is data for level buttons on screen
if GetVirtualButtonPressed(1) = 1 //button 1 selects level 1 (concrete jungle)
level = 1
startload = 4
endif
if GetVirtualButtonPressed(2) = 1 //bytton 2 selects level 2 (junk yard)
level = 2
startload = 4
endif
endif
if GetNetworkExists(NetworkID) //guests recieve level data from host before loading map
if startload = 4 and IsNetworkActive ( NetworkID ) <> 0
id = GetNetworkFirstClient ( NetworkID )
while id <> 0
Print ( GetNetworkClientName ( NetworkID, id ) )
id = GetNetworkNextClient ( NetworkID )
endwhile
if hosting = 0
message = GetNetworkMessage ( NetworkID )
while message <> 0
level = GetNetworkMessageFloat ( message )
DeleteNetworkMessage ( message )
message = GetNetworkMessage ( NetworkID )
endwhile
endif
if level > 0 then startload = 5
endif
endif
if startload = 5 //load map and remove buttons and text
for i = 1 to 10
if GetVirtualButtonExists(i) = 1 then DeleteVirtualButton(i)
if GetTextExists(i) = 1 then deletetext(i)
next i
if level = 1
//Load a map file
Map01 as tileMapType
Map01 = loadMap( "Level1.json" )
//Create Tileset for loaded map from an image
tileset01 as tilesetType
tileset01 = createTileset( "Level1.png", Map01.tilewidth, 0 )
//draw the Map
Map01 = createMap( Map01, tileset01, 4 )
endif
if level = 2
//Load a map file
Map02 as tileMapType
Map02 = loadMap( "Level2.json" )
//Create Tileset for loaded map from an image
tileset02 as tilesetType
tileset02 = createTileset( "Level2.png", Map02.tilewidth, 0 )
//draw the Map
Map02 = createMap( Map02, tileset02, 4 )
endif
startload = 6
endif
if startload = 6 //active game mode. host continually sends level message for new players joining
if hosting = 1
message = CreateNetworkMessage ( )
AddNetworkMessageFloat ( message, level)
SendNetworkMessage ( NetworkID, 0, message )
endif
id = GetNetworkFirstClient ( NetworkID )
while id <> 0
Print ( GetNetworkClientName ( NetworkID, id ) )
id = GetNetworkNextClient ( NetworkID )
endwhile
endif
return
Thanks again, smallg for the help.
One smart fellow, he felt smart. Two smart fellows, both felt smart. Three smart fellows all felt smart...