Posted By: Razoron
[ANet] Send char array with an event - 09/05/10 11:43
Hi,
to reduce the bandwith, I decided to send data thew a achar array with an event.
The sending function:
The recieving function:
But I always get chinese characters.
to reduce the bandwith, I decided to send data thew a achar array with an event.
The sending function:
Code:
function do_dmg(var to, var dmg) { char sendchr[2]; sendchr[0] = to; sendchr[1] = dmg; enet_clsend_event(EVENT_DAMAGE, sendchr, 2, SERVER); }
The recieving function:
Code:
function server_damage(var sender, STRING* msg, var size) { char data[2]; data = _chr(msg); error(_str(data[0])); error(_str(data[1])); var victim = data[0]; var dmg = data[1]; BOOL found = FALSE; if(ent_player[victim] != NULL) { if(enet_ent_globpointer(ent_player[victim]) != ANET_ERROR) { ent_player[victim].armor -= dmg; enet_send_skills(enet_ent_globpointer(ent_player[victim]), 24, 24, BROADCAST); found = TRUE; } } }
But I always get chinese characters.