Więc napisałem sobie client i sever, wiadomo o co chodzi wszystko wykonane przy
użyciu biblioteki 39DLL. Zamieszczam tutaj kod clien'ta i server'a, a problem polega
na tym że gracze się nie widzą. Server widzi ich, wie kiedy gracz wchodzi i wychodzi,
no i właśnie tego gracze nie widzą:
SEVER
GML (STEP)
sock = tcpaccept(listen, 1);
if(sock)
{
numb+=1
global.players+=1
global.pID[numb]=sock
clearbuffer();
writebyte(1);
writeshort(global.players);
writeshort(numb);
}
if global.players>0
{
while(ii<=global.players
)
{
ii+=1
size=receivemessage(global.pID[ii]);
hii=readbyte();
if size==0 or size<0{}
else
if hii==2
{
xx=readshort( );
yy=readshort( );
while(iii<=global.pID[iii])
{
iii+=1
clearbuffer();
writebyte(2);
writebyte(iii);
writeshort(xx);
writeshort(yy);
sendmessage(global.pID[iii]);
}
}
else
if hii==9
{
hi=readshort();
global.pID[hi]=-1
global.players-=1
}
}
}
ii=0
iii=0
CLIENT
oOthers:
GML (STEP)
size = receivemessage(global.sock)
ff=readbyte();
fff=readbyte();
if ff==2 and fff==idd
{
x=readshort();
y=readshort();
}
oPlayer:
GML (STEP)
direction=random(260)
speed=1
clearbuffer();
writebyte(2);
writeshort(x);
writeshort(y);
sendmessage(global.sock);
oConnect:
GML (CREATE)
dllinit(0,true,false)
ip = get_string("Podaj IP do ktorego chcesz sie polaczyc:", "127.0.0.1");
global.sock = tcpconnect(ip, 7777, 1);
if(!global.sock)
{
game_end();
exit;
}
size=receivemessage(global.sock)
i=readshort();
ii=readshort();
idd=ii;
ii=1;
while(ii<=i)
{
if ii!=idd
{
a=instance_create(x,y,oOthers)
a.idd=ii
}
ii+=1;
}