Im using multisync and i cant figure out a method of sorting messages so that the server can sort and send messages for more than two clients heres my code/
NOTE: I know im probably not using the best method of data transfer,so unless thats the problem, i'd rather not change it.
If you notice what i tried to do was have the server send a message that could possibly be used to tell the clients who sent the message in order to position the correct player.
Server
if(NetGetMessage())
{
PACKETS_RECIEVED++;
switch(msgfrom)
{
case 1:
{
NetGetString(tempstrX,256);
NetGetString(tempstrY,256);
NetGetString(tempstrZ,256);
NetGetString(tempstrAX,256);
NetGetString(tempstrframe,256);
NetGetString(tempstrHP,256);
sprintf(OutMsgFrom,"%i",msgfrom);
NetPutString("1");
NetPutString(tempstrX);
NetPutString(tempstrY);
NetPutString(tempstrZ);
NetPutString(tempstrAX);
NetPutString(tempstrframe);
NetPutString(tempstrHP);
if(NetPlayerConnected(2))
{
NetSend(2);
PACKETS_RETURNED++;
}
if(NetPlayerConnected(3))
{
NetSend(3);
PACKETS_RETURNED++;
}
NetSend(0);
break;
}
case 2:
{
NetGetString(tempstrX1,256);
NetGetString(tempstrY1,256);
NetGetString(tempstrZ1,256);
NetGetString(tempstrAX1,256);
NetGetString(tempstrframe1,256);
NetGetString(tempstrHP1,256);
sprintf(OutMsgFrom,"%i",msgfrom);
NetPutString("1");
NetPutString(tempstrX1);
NetPutString(tempstrY1);
NetPutString(tempstrZ1);
NetPutString(tempstrAX1);
NetPutString(tempstrframe1);
NetPutString(tempstrHP1);
if(NetPlayerConnected(1))
{
NetSend(1);
PACKETS_RETURNED++;
}
if(NetPlayerConnected(3))
{
NetSend(3);
PACKETS_RETURNED++;
}
NetSend(0);
break;
}
case 3:
{
NetGetString(tempstrX2,256);
NetGetString(tempstrY2,256);
NetGetString(tempstrZ2,256);
NetGetString(tempstrAX2,256);
NetGetString(tempstrframe2,256);
NetGetString(tempstrHP2,256);
sprintf(OutMsgFrom,"%i",msgfrom);
NetPutString("2");
NetPutString(tempstrX2);
NetPutString(tempstrY2);
NetPutString(tempstrZ2);
NetPutString(tempstrAX2);
NetPutString(tempstrframe2);
NetPutString(tempstrHP2);
if(NetPlayerConnected(1))
{
NetSend(1);
PACKETS_RETURNED++;
}
if(NetPlayerConnected(2))
{
NetSend(2);
PACKETS_RETURNED++;
}
NetSend(0);
break;
}
default:
{
NetGetString(defstr1,256);
NetGetString(defstr1,256);
NetGetString(defstr1,256);
NetGetString(defstr1,256);
NetSend(0);
break;
}
}
}
Client(s)
if(NetGetMessage())
{
InMsgFrom = atoi(msgfrom);
NetGetString(msgfrom,256);
InMsgX = atof(tempstrX);
InMsgY = atof(tempstrY);
InMsgZ = atof(tempstrZ);
InMsgAX = atof(tempstrAX);
InFrame = atof(tempstrframe);
InHP = atoi(tempstrHP);
InMsgX1 = atof(tempstrX1);
InMsgY1 = atof(tempstrY1);
InMsgZ1 = atof(tempstrZ1);
InMsgAX1 = atof(tempstrAX1);
InFrame1 = atof(tempstrframe1);
InHP1 = atoi(tempstrHP1);
InMsgX2 = atof(tempstrX2);
InMsgY2 = atof(tempstrY2);
InMsgZ2 = atof(tempstrZ2);
InMsgAX2 = atof(tempstrAX2);
InFrame2 = atof(tempstrframe2);
InHP2 = atoi(tempstrHP2);
switch(InMsgFrom)
{
case 1:
{
NetGetString(tempstrX,256);
NetGetString(tempstrY,256);
NetGetString(tempstrZ,256);
NetGetString(tempstrAX,256);
NetGetString(tempstrframe,256);
NetGetString(tempstrHP,256);
break;
}
case 2:
{
NetGetString(tempstrX1,256);
NetGetString(tempstrY1,256);
NetGetString(tempstrZ1,256);
NetGetString(tempstrAX1,256);
NetGetString(tempstrframe1,256);
NetGetString(tempstrHP1,256);
break;
}
case 3:
{
NetGetString(tempstrX2,256);
NetGetString(tempstrY2,256);
NetGetString(tempstrZ2,256);
NetGetString(tempstrAX2,256);
NetGetString(tempstrframe2,256);
NetGetString(tempstrHP2,256);
break;
}
}
}
if(dbObjectExist(NetPlayer1))
{
dbPositionObject(NetPlayer1,InMsgX,InMsgY,InMsgZ);
dbYRotateObject(NetPlayer1,InMsgAX);
dbSetObjectFrame(NetPlayer1,InFrame);
}
if(dbObjectExist(NetPlayer2))
{
dbPositionObject(NetPlayer2,InMsgX,InMsgY,InMsgZ);
dbYRotateObject(NetPlayer2,InMsgAX);
dbSetObjectFrame(NetPlayer2,InFrame);
}
if(dbObjectExist(NetPlayer3))
{
dbPositionObject(NetPlayer3,InMsgX2,InMsgY2,InMsgZ2);
dbYRotateObject(NetPlayer3,InMsgAX2);
dbSetObjectFrame(NetPlayer3,InFrame2);
}
if(You.AddCode.toPost)TGC.Users.CanHelp = true;
else return NoCodeMessage;