The online racing simulator
HELP MESSAGE
(7 posts, started )
HELP MESSAGE
Good, what I want to do is a message that is editable from a .txt appears, but it does not work

struct IS_BTN Btn36; //Base del semaforo
memset(&Btn36, 0, sizeof(Btn36));
Btn36.Size = sizeof(struct IS_BTN);
Btn36.Type = ISP_BTN;
Btn36.ReqI = 1;
Btn36.UCID = 255;
Btn36.ClickID = 2;
Btn36.BStyle = ISB_DARK; // ISB_DARK FONDO OSCURO
Btn36.L = posx_semasxxe;
Btn36.T = posy_semasxxe;
Btn36.H = 250;
Btn36.W = 13;
sprintf(Btn36.Text, "^7%s", buffer5);
insim.send_packet(&Btn36);

#2 - ab12
Try:
StreamReader sr = new StreamReader("YourFile.txt")

Quote :Btn36.ClickID = 2;

That is the id-number of the button, it should be unique. Did you mean =36?

Otherwise the posted part seems okay.
Other possible problems could be:
-Text is limited to 240 characters. In the "simplex" project from your other thread, all buffers are defined as char[256] so possible they do not fit.
-Something goes wrong during reading the file. Try displaying the read value on screen (printf / cout) and see if it comes out right.
Thanks for the help !
Can you tell me how to add a command !kick username
and tell the user X has thrown X

Sorry for my bad English
Check for the "!kick" string and send an IS_MST with the appropriate "/kick" command back to LFS. Use sprintf() to add the username of the player to be kicked to the "/kick" command.
In insim.h see the part about // MESSAGES OUT (FROM LFS)



if (packetType == ISP_MSO) {
text_message ();
}

Then to get the message and do something:

void text_message ()
{
struct IS_MSO* textPacket = (struct IS_MSO*)insim.get_packet(); //packet abholen
byte UserType = textPacket->UserType;
if (UserType == MSO_O)
{
char *msg;
msg = textPacket->Msg; //[128]
std::cout<<"The recieved textmessage is:" <<msg<<std::endl;
if (strcmp (msg, "placecamera")==0)
{
requestCameraInfo (PLACE_CAMERA);
}

if (strcmp (msg, "stoptracking")==0)
{
isTracking = false;
}

if (strcmp (msg, "starttracking")==0)
{
isTracking = true;
}
...
...

I only ever used messages with UserType == MSO_O : That means chatmessages prefixed with /o in chat, those do not appear in chat typed and so so do not disturb other players when used online.

For normal chatmessages use UserType == MSO_USER,_O meaning:
// 1 - normal visible user message


For a !kick command you will want to filter the username out of the message.
"!kick" is five characters:

!kick BadDriver
123456789.....

plus a space. So the the username begins after 6 characters which you can get like:
string username = msg.substr(6);
Or since here msg is not a std::string but a *char:
string username = string(s).substr(6);
Quote from Gutholz :In insim.h see the part about // MESSAGES OUT (FROM LFS)



if (packetType == ISP_MSO) {
text_message ();
}

Then to get the message and do something:

void text_message ()
{
struct IS_MSO* textPacket = (struct IS_MSO*)insim.get_packet(); //packet abholen
byte UserType = textPacket->UserType;
if (UserType == MSO_O)
{
char *msg;
msg = textPacket->Msg; //[128]
std::cout<<"The recieved textmessage is:" <<msg<<std::endl;
if (strcmp (msg, "placecamera")==0)
{
requestCameraInfo (PLACE_CAMERA);
}

if (strcmp (msg, "stoptracking")==0)
{
isTracking = false;
}

if (strcmp (msg, "starttracking")==0)
{
isTracking = true;
}
...
...

I only ever used messages with UserType == MSO_O : That means chatmessages prefixed with /o in chat, those do not appear in chat typed and so so do not disturb other players when used online.

For normal chatmessages use UserType == MSO_USER,_O meaning:
// 1 - normal visible user message


For a !kick command you will want to filter the username out of the message.
"!kick" is five characters:

!kick BadDriver
123456789.....

plus a space. So the the username begins after 6 characters which you can get like:
string username = msg.substr(6);
Or since here msg is not a std::string but a *char:
string username = string(s).substr(6);

Thanks!

HELP MESSAGE
(7 posts, started )
FGED GREDG RDFGDR GSFDG