hi , I created a client and a server,
the client connects to the server and sends the message of the X and Y sprite!
however, when it sends the server receives several messages. and sends to all connected clients, more does not move the sprite!
below the codes I made : >
Client :
randomplayername$=str(random(1,10000))
NetworkID = JoinNetwork("127.0.0.1", 1027, randomplayername$)
CreateSprite(1,0)
AddSpriteAnimationFrame(1,Loadimage("run1/1.png"))
AddSpriteAnimationFrame(1,Loadimage("run1/2.png"))
AddSpriteAnimationFrame(1,Loadimage("run1/3.png"))
AddSpriteAnimationFrame(1,Loadimage("run1/4.png"))
AddSpriteAnimationFrame(1,Loadimage("run1/5.png"))
AddSpriteAnimationFrame(1,loadimage("run1/6.png"))
PlaySprite(1,10,1,1,6)
do
ClientID = GetNetworkMessageFromClient(msg)
c = GetNetworkNumClients(NetworkID)
if (GetVirtualJoystickExists(1))
SetspritePosition(1,getspritex(1) + (GetVirtualJoystickX(1) * 1) , getspritey(1) + (GetVirtualJoystickY(1) * 1))
endif
If c > 1
x# = GetSpriteX ( 1 ) + GetDirectionX ( )
y# = GetSpriteY ( 1 ) + GetDirectionY ( )
ServerID = GetNetworkServerID(NetworkID)
newMsg = CreateNetworkMessage()
AddNetworkMessageFloat(newMsg, x#)
// Add the packet identifier
AddNetworkMessageFloat(newMsg, y#)
// Add the player's initials
SendNetworkMessage(NetworkID, ServerID, newMsg)
// Send it to the server
DeleteNetworkMessage(newMsg)
endif
msg = GetNetworkMessage(NetworkID)
if msg > 0
x# = GetNetworkMessageFloat ( msg )
y# = GetNetworkMessageFloat ( msg )
SetSpritePosition ( 1, x# +1, y# + 1 )
DeleteNetworkMessage( msg )
endif
Sync()
loop
print of Client works :
http://prntscr.com/7mey5r
Code of server to receive message of client :
if msg > 0
Print ("ClientID:" + Str(ClientID))
print ("msg x# :" + Str(msg))
print ("msg y# :" + Str(msg))
endif
if ClientID > 1
x# = GetNetworkMessageFloat(msg)
y# = GetNetworkMessageFLoat(msg)
newMsg = CreateNetworkMessage()
AddNetworkMessageFloat(newMsg, msg)
AddNetworkMessageFloat(newMsg, msg)
SendNetworkMessage(networkId, 0, newMsg)
DeleteNetworkMessage(newMsg)
endif
Print of Server working :
http://prntscr.com/7mf0x4
PrintC("Hello EveryOne !&quot