Ive been working on multisync for about a week and a half trying to figure out a way to update player movement in the game(both client and server)
Right now i have
void HostGame()
{
connection = NetPlayerJoined();
if (connection != 0)
{
NetPutString(MultiSyncServerName);
NetSend(connection);
connections++;
::MakePlayer(iPlayer2,"Colonel-X.x",553.715,108.501,-734.154);
}
playerleft = NetPlayerLeft();
if (playerleft)
{
dbDeleteObject(iPlayer2);
connections--;
}
//
sprintf(tempstr, "%i connected.", connections);
dbText(150, 32, tempstr);
}
bool TryMultiSyncServerConnect(char *ipaddress)
{
DWORD start;
sprintf(tempstr, "BUFFER CONTENT UNCHANGED.");
if (NetConnect(ipaddress))
{
start = GetTickCount();
while (GetTickCount() - start < 5000);
if (NetGetMessage())
{
NetGetString(tempstr, 256);
::MessageBox(NULL,tempstr,MultiSyncServerName,MB_OK);
::MakePlayer(iPlayer2,"Colonel-X.x",553.715,108.501,-734.154);
__PCE = true;
}else{
sprintf(tempstr, ErrorNoConnectMessage);
MessageBox(NULL, tempstr,
MultiSyncClientName, MB_ICONINFORMATION);
return true;
}
}else{
MessageBox(NULL, ErrorNoConnection,
MultiSyncClientName, MB_ICONEXCLAMATION);
return false;
}
return true;
}
void DS_MessageLoop(void)
{
/*for(int timer; timer >= 5; timer++);*/
while(NetGetMessage())
{
NetGetString(tempstr,256);
DS_GetCoord();
}
}
void DS_SendCoord()
{
float pX = dbObjectPositionX(iPlayer1);
float pY = dbObjectPositionY(iPlayer1);
float pZ = dbObjectPositionZ(iPlayer1);
NetPutFloat(pX);
NetPutFloat(pY);
NetPutFloat(pZ);
NetSend(connection);
}
void DS_GetCoord()
{
float pX2 = NetGetFloat();
float pY2 = NetGetFloat();
float pZ2 = NetGetFloat();
dbPrint(pX2);
dbPrint(pY2);
dbPrint(pZ2);
dbPositionObject(iPlayer2,pX2,pY2,pZ2);
}
void Multiplayer()
{
DS_MessageLoop();
for(int timer = 0; timer < 500; timer++)
{
if(timer >= 500)
{
DS_SendCoord();
timer = 0;
}
}
}
With this , it creates a player for about a second and deletes or moves it, then the client screen goes black and FPS drops literally to 0(i know because the player coordinates update eventually)
SO i need to know how to do this successfully.