S
superm1ch0
Guest
Hello,
I have a problem with the send_packet function, I want to loop trough an array and send a packet when a value is equal to 1. This is my code:
The problem is that it shows the message box "Test" so I'm sure that the if statement is true but it doesn't send the packet to a socket.
When I do this:
With this code he sends the packet now every frame (Because it's in a step event). But if I put this code into the if statement he doesn't.
Does anyone know how to fix this?
I have a problem with the send_packet function, I want to loop trough an array and send a packet when a value is equal to 1. This is my code:
Code:
///Loop door de unit queue
for(var i = 0; i < array_height_2d(global.unit_queue); i++) {
if(global.unit_queue[i, 0] == 1) {
buffer_seek(global.tcp_buffer, buffer_seek_start, 0);
buffer_write(global.tcp_buffer, buffer_u8, global.SEND_CREATE_UNIT_MSG);
network_send_packet(global.socket[0], global.tcp_buffer, buffer_tell(global.tcp_buffer));
show_message("Test");
//Maak de queue leeg
global.unit_queue[i, 0] = noone;
global.unit_queue[i, 1] = noone;
}
}
When I do this:
Code:
///Loop door de unit queue
for(var i = 0; i < array_height_2d(global.unit_queue); i++) {
if(global.unit_queue[i, 0] == 1) {
//Maak de queue leeg
global.unit_queue[i, 0] = noone;
global.unit_queue[i, 1] = noone;
}
}
buffer_seek(global.tcp_buffer, buffer_seek_start, 0);
buffer_write(global.tcp_buffer, buffer_u8, global.SEND_CREATE_UNIT_MSG);
network_send_packet(global.socket[i], global.tcp_buffer, buffer_tell(global.tcp_buffer));
Does anyone know how to fix this?