The online racing simulator
MTC problem
(10 posts, started )
MTC problem
Can't seem to get it to send a message to a connection.

meh. damn insim! lol.

Anything wrong with this?


<?php 
            $packet
=pack("C"72);
            
$packet.=pack("C"ISP_MTC);
            
$packet.=pack("C"0);
            
$packet.=pack("C"$data['conn_num']);
            
$packet.=pack("C"$data['unique_id']);
            
$packet.=pack("C"0);
            
$packet.=pack("C"0);
            
$packet.=str_pad($msgtosend64"\0");
?>

Quote from Krammeh :Can't seem to get it to send a message to a connection.

meh. damn insim! lol.

Anything wrong with this?


<?php 
            $packet
=pack("C"72);
            
$packet.=pack("C"ISP_MTC);
            
$packet.=pack("C"0);
            
$packet.=pack("C"$data['conn_num']);
            
$packet.=pack("C"$data['unique_id']);
            
$packet.=pack("C"0);
            
$packet.=pack("C"0);
            
$packet.=str_pad($msgtosend64"\0");
?>


Im not really an expert on programming but isnt the first packet meant to be $packet.=pack("C", 72); not $packet=pack("C", 72);? (notice the dot?)

Matt
Quote from dmwright :Im not really an expert on programming but isnt the first packet meant to be $packet.=pack("C", 72); not $packet=pack("C", 72);? (notice the dot?)

Nope
Try this;
$packet=pack("C", 72);
$packet.=pack("C", ISP_MTC);
$packet.=pack("C", 0);
$packet.=pack("C", 0); // MISSING THIS ZERO BYTE
$packet.=pack("C", $data['conn_num']);
$packet.=pack("C", $data['unique_id']);
$packet.=pack("C", 0);
$packet.=pack("C", 0);
$packet.=str_pad($msgtosend, 64, "\0");



Not bad for a guess
thanks, that worked
just another question, haha! sorry.

About conn_nums... when someone leaves, does the highest ID take that persons conn_num?
I must be being a pleb, "'cos I ain't following you jist"
well, when someone left on the previous insim, the connection number was say 4.

Then connection number 23 (or whatever the highest was), moved into the connection 4 ID. does it do this on the new insim?
No - it makes life much easier
Quote from Krammeh :Can't seem to get it to send a message to a connection.

meh. damn insim! lol.

Anything wrong with this?


<?php 
            $packet
=pack("C"72);
            
$packet.=pack("C"ISP_MTC);
            
$packet.=pack("C"0);
            
$packet.=pack("C"$data['conn_num']);
            
$packet.=pack("C"$data['unique_id']);
            
$packet.=pack("C"0);
            
$packet.=pack("C"0);
            
$packet.=str_pad($msgtosend64"\0");
?>


is ISP_MTC defined as 14?
and there're some mistakes, 72 bytes packet is too short in your example,
this is mine php function:


<?php 
function send_mtc (&$socket,$ucId,$plId=0,$message){
 
$packet  "";
 
$packet .= pack("c"72);
 
$packet .= pack("c"14);
 
$packet .= pack("c"0);
 
$packet .= pack("c"0);
 
$packet .= pack("c"$ucId);
 
$packet .= pack("c"$plId);
 
$packet .= pack("c"0);
 
$packet .= pack("c"0);
 if (
strlen($message)>64){
  
$message=substr($message,0,64);
 }
 
$packet .= str_pad($message64"\0");
  
fwrite($socket$packetstrlen($packet));
  return 
true;
}
?>


MTC problem
(10 posts, started )
FGED GREDG RDFGDR GSFDG