The online racing simulator
InSim Commands problem (LFSLib.NET)
Hey,

I have a problem with getting commands when people have weird characters in their name..

Normally for as far as I know to remove the playername from the message + : etc u do:
e.MessageText.Substring(e.Playername.Length + 7,e.MessageText.Length-e.Playername.Length - 7);

Seems to work fine on normal names but when u start using weird characters it doesn't function...

Is their anybody who knows a different way?

Greetz Glenn
#2 - filur
struct IS_MSO // MSg Out - system messages and user messages
{
byte Size; // 136
byte Type; // ISP_MSO
byte ReqI; // 0
byte Zero;

byte UCID; // connection's unique id (0 = host)
byte PLID; // player's unique id (if zero, use UCID)
byte UserType; // set if typed by a user (see User Values below)
[B]byte TextStart; // first character of the actual text (after player name)[/B]

char Msg[128];
};

substr(MSO.Msg, MSO.TextStart);

Quote from filur :
struct IS_MSO // MSg Out - system messages and user messages
{
byte Size; // 136
byte Type; // ISP_MSO
byte ReqI; // 0
byte Zero;

byte UCID; // connection's unique id (0 = host)
byte PLID; // player's unique id (if zero, use UCID)
byte UserType; // set if typed by a user (see User Values below)
[B]byte TextStart; // first character of the actual text (after player name)[/B]

char Msg[128];
};

substr(MSO.Msg, MSO.TextStart);


hmm jeah but the problem is that i work with a Library, so can't edit it... I better create my own?
Create your own library? Not good idea... not exactly a straight forward thing either. The LFSLib is GPL'd so you can get the code and modified the code and use a custom version of the library!

Something as silly as a while loop could be a hack, i.e.


string command = string.empty;
for(int i = 0; i < e.MessageText.count; i++)
{
if (e.MessageText[i].equals(e.MessageTextStart))
{
command = e.MessageText.substring(i);
break;
}
}

Quote from windstyle :hmm jeah but the problem is that i work with a Library, so can't edit it... I better create my own?

I'd have look at home to see what I did to strip the commands myself in my LFSLib based applications.
Quote from windstyle :hmm jeah but the problem is that i work with a Library, so can't edit it... I better create my own?

I'm pretty sure the library does provide all data which is included in the default lfs packet. so the textstart should be there, too...
Quote from GeForz :I'm pretty sure the library does provide all data which is included in the default lfs packet. so the textstart should be there, too...

nope i had to add it myself... but still it doesn't work on special names :s code:

string message = e.MessageText.Substring(e.TextStart);

it does work fine on my player name, but it doesn't on "Laport" with special characters in it, on my old insim it works fine with:


string bericht = MSO.Msg.Substring(Connections[GetConnIdx(MSO.UCID)].PlayerName.Length + 10)

Screenshot from when u say something with normal player name and when with a special name

string message = e.MessageText.Substring(e.TextStart);
sendMessage(message);

Attached images
string.jpg
Ah, went back to look at my code... I cheated.

Quote :
log.Debug("HandleInSimCommands", "MessageText", e.MessageText);
string message = string.Empty;
string command = e.MessageText;
int pos = command.IndexOf(": ");
if (pos > -1)
command = command.Substring(pos + 2);
if (!command.StartsWith(InSimCommandPrefix))
return isCommand;
command = command.Remove(0, 1);
command = command.ToLower();
log.Debug("HandleInSimCommands", "command", command);

That's only a bad thing if a playername contains a ": "

You probably just need to fix the library because it never delivers the playername for a message iirc

FGED GREDG RDFGDR GSFDG