I can send x, y, username and image angles perfectly fine, but sending image colour blending is the problem... I send the colour variable through writeint(), but when the game is running, the other player's sprite is just black and not the actual colour sent...
I am wondering what I am doing wrong, and how to go about this issue. I know that the message actually sends since the other player's sprite changes colour, but it seems as if the message data is only 0 resulting in the colour black.
Here is the code for the client sending the message:
clearbuffer(); writebyte(2); writebyte(global.myid); writeshort(x); writeshort(y); writeshort(sprite_index); writeshort(image_speed); writeshort(image_index); writeshort(direction); writeint(colour); sendmessage(global.clienttcp); alarm[11] = 1;
And here is the code for receiving and sending via the server:
var messagesize, messageid;
while(1)
{
messagesize = receivemessage(obj_server.serverudp);
if (messagesize <=0) messagesize = receivemessage(tcp);
if (messagesize <=0) break;
messageid = readbyte();
switch(messageid)
{
case 2:
var player, value;
value = readbyte();
(string(global.players[value]),c_black);
player = global.players[value];
player.x = readshort();
player.y = readshort();
player.sprite_index = readshort();
player.image_speed = readshort();
player.image_index = readshort();
player.direction = readshort();
player.colour = readint();
clearbuffer();
writebyte(5);
writebyte(value);
writeshort(player.x);
writeshort(player.y);
writeshort(player.sprite_index);
writeshort(player.image_speed);
writeshort(player.image_index);
writeshort(player.direction);
writeint(player.colour);
with(obj_client)
{
sendmessage(tcp);
}
break;
case 3:
var playerid, username;
playerid = readbyte();
username = readstring();
clearbuffer();
writebyte(6);
writebyte(playerid);
writestring(username,true);
with(obj_client)
{
sendmessage(tcp);
}
script_addline(username + " has left.",c_black);
with(global.players[playerid])
{
instance_destroy();
}
global.players[playerid] = -1;
break;
case 4:
chatmessage = readstring();
script_addline(chatmessage,c_black);
clearbuffer();
writebyte(8)
writestring(chatmessage,true);
with(obj_client)
{
sendmessage(tcp);
}
break;
}
}If you could help, that would be greatly appreciated, thankyou.
Edited by BlackEnergy, 03 July 2012 - 08:51 AM.











