BlitzPlay Problem

Blitz3D Forums/Blitz3D Programming/BlitzPlay Problem

System4 Studios(Posted 2009) [#1]
So I've completely made a modified version of FPSNet using Blitzplay..

All is fine until someone else join a game.. and I come across these two screens..

http://img210.imageshack.us/i/error1g.png/
http://img33.imageshack.us/i/error2v.png/


source code below.. If someone can help me out here.. would be nice.. :)


Edit by System4


GfK(Posted 2009) [#2]
Holy mother of Christ.

You're going to have to provide a LOT more information, like, where the error happens, which object its referring to etc. You could also try to narrow it down a bit instead of expecting people to wade through that lot.

If you must post it all, at least put your code in CODEBOX tags - that way it won't make the forum page tall enough to reach the moon.


System4 Studios(Posted 2009) [#3]
Haha.. lol..

Alright.. I tried to get a friend to join me.. All was successful until a few seconds later.. He started to appear in multiples instead of just one networked player.. then I got the error message..

For some reason.. That error message is dealing with the BP_UDPMessage() Function..


;New Player Joins

Case 255 ; Player Joins
				
				p.Player = New Player
				p\iD = msg\msgFrom
				p\mesh[1] = CreateSphere(8)
				p\name$ =  msg\msgData
				EntityColor(p\mesh[1], 0, 255, 0)
				PositionEntity(p\mesh[1], 5, 1.5, Rand(50,100))
				EntityType(p\mesh[1],BODY)
				EntityRadius(p\mesh[1], 1.5)
				EntityPickMode(p\mesh[1], 2)
				
				p\mesh[2] = CreateCube(p\mesh[1])
				PositionEntity(p\mesh[2], 1, -.5, 1)
				ScaleEntity(p\mesh[2], .1, .1, .4)
				EntityColor(p\mesh[2], 20, 20, 20)
				
				p\mesh[3] = CreatePivot(p\mesh[1])
				PositionEntity(p\mesh[3], 0, 0, 5)
				
				If hosting
					p.Player = Object.Player(localPlayerPointer)
					;SendNetMsg(7, randPos + "," + randNum + "-", p\iD#, NetMsgFrom(), 1)
					BP_UDPMessage(msg\msgFrom,7,randPos + "," + randNum + "-")
				EndIf



Hosting/Joining Code

If enterKeyPressed
	gns.GNET_Server = Object.GNET_Server(serverPointer)
	My_Port=Rand(1000,2000)
	FlushKeys
	Color(255,0,0)
	Locate(200,195)
	cablename$ = Input("Name - ")
	Select BP_JoinSession(cablename$,My_Port,gns\ip$,4545)
		Case BP_NOREPLY
			Cls
			RuntimeError "No reply from server.."
			End
		Case BP_IAMBANNED
			Cls
			RuntimeError "You have been banned.. Contact an admin for unban on the forums."
			End
		Case BP_GAMEISFULL
			Cls
			RuntimeError "The game session is currently 
			
		Case BP_PORTNOTAVAILABLE
			Cls
			RuntimeError "Port: " + My_Port + " was not available.. exiting"
			End
		Case BP_USERABORT
			Cls
			RuntimeError "Connection attempt aborted!"
			End
	End Select
	
	p.Player = New Player
	localPlayerPointer = Handle(p.Player)
	p\iD = BP_My_ID
	Cls
	Setup("Game")
	hosting = False
	
EndIf
If spaceKeyPressed
	FlushKeys
	Color(255,0,0)
	Locate(200,195)
	servername$ = Input("Name - ")
	Delay(100)
	FlushKeys
	
	If GNET_AddServer("Soul Shooter Online", username$)
		If BP_HostSession(servername$,10,1,4545,10)= 1
				p.Player = New Player
				localPlayerPointer = Handle(p.Player)
				p\iD = BP_My_ID
				Cls
				Setup("Game")
				hosting = True
				serverRefreshTimer# = MilliSecs()
			Else
				RuntimeError("Failed to Add Server!")
			EndIf
		EndIf 	
		
	
EndIf



Update Network Code;

Function UpdateNetwork()
	
	For msg.MsgInfo=Each MsgInfo
		
		Select msg\msgType
				
			Case 1
				
				For p.Player = Each Player
					If p\iD = msg\msgFrom
						DecodeIncomingMessage(msg\msgData)
						PositionEntity(p\mesh[1], incoming$(1), incoming$(2), incoming$(3))
						RotateEntity(p\mesh[1], incoming$(4), incoming$(5), 0)
						If incoming$(6) <> ""	
							p\score = incoming$(6)
						EndIf
					EndIf
				Next
				
			Case 2
				
				p.Player = Object.Player(localPlayerPointer)
				CreateSomeParticles(EntityX(p\mesh[1]), EntityY(p\mesh[1]), EntityZ(p\mesh[1]), 255, 0, 0, 10)
				
				If justDied# + 500 < MilliSecs()
					DecodeIncomingMessage(msg\msgData)
					Select incoming$(1)
						Case 1
							health# = health# - 5
						Case 2
							count = 0
							If incoming$(2) <> 0
								count = count + 1
							EndIf
							If incoming$(3) <> 0
								count = count + 1
							EndIf
							If incoming$(4) <> 0
								count = count + 1
							EndIf
							health# = health# - (5 * count)
						Case 3
							health# = health# - 25
					End Select
				EndIf
				
				If health# <= 0
					health# = 100
					PositionEntity(p\mesh[1],5,1,Rand(0, 50))
					;SendNetMsg(3, "1", p\iD, NetMsgFrom(), 1)
					BP_UDPMessage(0,3,"1")
					CreateSomeParticles(EntityX(p\mesh[1]), EntityY(p\mesh[1]), EntityZ(p\mesh[1]), 255, 0, 0, 100)
					;SendNetMsg(5, "1",p\iD, 0, 0)
					BP_UDPMessage(0,5,"1")
					justDied# = MilliSecs()
				EndIf
				
			Case 3
				
				p.Player = Object.Player(localPlayerPointer)
				p\score = p\score + 1
				
			Case 4
				
				DecodeIncomingMessage(msg\msgData)
				
				Select incoming$(1)
						
					Case 1
						CreateSomeParticles(incoming$(2), incoming$(3), incoming$(4), 50, 50, 50, 10)
						PM_AddEmitter(1,incoming$(2),incoming$(3),incoming$(4),0,"",True,False)
						PlaySound sounds$(12)
					Case 2
						CreateSomeParticles(incoming$(2), incoming$(3), incoming$(4), 255, 255, 255, 10)
						CreateSomeParticles(incoming$(5), incoming$(6), incoming$(7), 255, 255, 255, 10)
						CreateSomeParticles(incoming$(8), incoming$(9), incoming$(10), 255, 255, 255, 10)
						PM_AddEmitter(5,incoming$(2),incoming$(3), incoming$(4),0,"",True,False)
						PM_AddEmitter(5,incoming$(5),incoming$(6), incoming$(7),0,"",True,False)
						PM_AddEmitter(5,incoming$(8),incoming$(9), incoming$(10),0,"",True,False)
					Case 3
						CreateSomeParticles(incoming$(2), incoming$(3), incoming$(4), 255, 200, 100, 10)
						PM_AddEmitter(5,incoming$(2),incoming$(3),incoming$(4),0,"",True,False)
						
				End Select
				
			Case 5
				
				For p.Player = Each Player
					If p\iD = msg\msgData
						CreateSomeParticles(EntityX(p\mesh[1]), EntityY(p\mesh[1]), EntityZ(p\mesh[1]), 255, 0, 0, 100)
					EndIf
				Next
				
			Case 6
				
				c.chatMsg = New chatMsg
				c\msg = msg\msgData
				c\born# = MilliSecs()
				c\from = msg\msgFrom
				
			Case 7
				
				DecodeIncomingMessage(msg\msgData)
				pup.powerUp = New powerUp
				pup\mesh = CopyEntity(copyPowerUp)
				powerUpSpawned = True
				
				PositionEntity(pup\mesh, EntityX(incoming$(1)),1,EntityX(incoming$(2)))
				
				Select incoming$(3)
						
					Case 1
						pup\name$ = "Spark"
						EntityTexture(pup\mesh,ammotextures$(1))
					Case 2
						pup\name$ = "Deadly Gas"
						EntityTexture(pup\mesh,ammotextures$(3))
					Case 3
						pup\name$ = "Flamethrower"
						EntityTexture(pup\mesh,ammotextures$(2))
						
				End Select
				randPosX = incoming$(1)
				randPosZ = incoming$(2)
				randNum = incoming$(3)
				
			Case 8
				
				For pup.powerUp = Each powerUp
					FreeEntity(pup\mesh)
					Delete(pup)
				Next
				powerUpSpawned = False
				
			Case 9
				
				For op.Player = Each Player
					If op\iD = msg\msgFrom
						DecodeIncomingMessage(msg\msgData)
						CreateSomeParticles(EntityX(op\mesh[2],True), EntityY(op\mesh[2], True), EntityZ(op\mesh[2], True), 255, 200, 100, 10,  incoming$(1) + Rnd(-.05, .05), incoming$(2) + Rnd(-.05, .05), incoming$(3), "Flame")
					EndIf
				Next
				
			Case 255 ; Player Joins
				
				p.Player = New Player
				p\iD = msg\msgFrom
				p\mesh[1] = CreateSphere(8)
				p\name$ =  msg\msgData
				EntityColor(p\mesh[1], 0, 255, 0)
				PositionEntity(p\mesh[1], 5, 1.5, Rand(50,100))
				EntityType(p\mesh[1],BODY)
				EntityRadius(p\mesh[1], 1.5)
				EntityPickMode(p\mesh[1], 2)
				
				p\mesh[2] = CreateCube(p\mesh[1])
				PositionEntity(p\mesh[2], 1, -.5, 1)
				ScaleEntity(p\mesh[2], .1, .1, .4)
				EntityColor(p\mesh[2], 20, 20, 20)
				
				p\mesh[3] = CreatePivot(p\mesh[1])
				PositionEntity(p\mesh[3], 0, 0, 5)
				
				If hosting
					p.Player = Object.Player(localPlayerPointer)
					;SendNetMsg(7, randPos + "," + randNum + "-", p\iD#, NetMsgFrom(), 1)
					BP_UDPMessage(msg\msgFrom,7,randPos + "," + randNum + "-")
				EndIf
				
			Case 254 ; Player Leaves
				
				For p.Player = Each Player
					If p\iD = msg\msgFrom
						FreeEntity(p\mesh[1])
						Delete(p)
					EndIf
				Next
				
			Case 253
				
				GNET_AddServer("Soul Shooter Online", username$)
				hosting = True
				
		End Select
		
	Next
	
	p.Player = Object.Player(localPlayerPointer)
	If positionUpdateTimer# + 50 < MilliSecs()
		;SendNetMsg(1, EntityX(p\mesh[1]) + "," + EntityY(p\mesh[1]) + "," + EntityZ(p\mesh[1]) + "," + EntityPitch(camera) + "," + EntityYaw(p\mesh[1]) + "," + p\score + "-", p\iD, 0, 0)
		BP_UDPMessage(0,1,EntityX(p\mesh[1]) + "," + EntityY(p\mesh[1]) + "," + EntityZ(p\mesh[1]) + "," + EntityPitch(camera) + "," + EntityYaw(p\mesh[1]) + "," + p\score + "-")
		positionUpdateTimer# = MilliSecs()
	EndIf
	
	For op.Player = Each Player
		Select weapon$
				
			Case "Spark"
				If shot = op\mesh[1]
					CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 255, 0, 0, 10)
					;SendNetMsg(2, "1-", p\iD, op\iD, 0)
					BP_UDPMessage(op\iD,2,"1-")
				EndIf
			Case "Deadly Gas"
				If shot = op\mesh[1] Or shot2 = op\mesh[1] Or shot3 = op\mesh[1]
					Select op\mesh[1]
						Case shot
							CreateSomeParticles(pickedArray(1, 1), pickedArray(1, 2), pickedArray(1, 3), 255, 0, 0, 10)
						Case shot2
							CreateSomeParticles(pickedArray(2, 1), pickedArray(2, 2), pickedArray(2, 3), 255, 0, 0, 10)
						Case shot3
							CreateSomeParticles(pickedArray(3, 1), pickedArray(3, 2), pickedArray(3, 3), 255, 0, 0, 10)
					End Select
					BP_UDPMessage(op\iD,2,"2," + Left(Str(shot), 1) + "," + Left(Str(shot2), 1) + "," + Left(Str(shot3), 1) + "-")
					;SendNetMsg(2, "2," + Left(Str(shot), 1) + "," + Left(Str(shot2), 1) + "," + Left(Str(shot3), 1) + "-", p\iD, op\iD, 0)
				EndIf
			Case "Flamethrower"
				If shot = op\mesh[1]
					CreateSomeParticles(PickedX(), PickedY(), PickedZ(), 255, 0, 0, 10)
					BP_UDPMessage(op\iD,2,"3-")
					;SendNetMsg(2, "3-", p\iD, op\iD, 0)
				EndIf
				
		End Select
	Next	 
	
	If hosting = True
		If serverRefreshTimer# + 25000 < MilliSecs()
			GNET_RefreshServer( "Soul Shooter Online",username$ )
			serverRefreshTimer# = MilliSecs()
		EndIf
	EndIf
	
End Function


If you need more details or shortening.. Please let me know..