The online racing simulator
Pm
(2 posts, started )
Pm
Hello How is the code to make a Private message system? can someone explain me how to do it? pls
What insim base are you working on ?

Here is an example that you can add in chatcommands
Its a simple !pm username message

[Command("pm", "pm <username> <message>")]
public void pm(string Msg, string[] StrMsg, Packets.IS_MSO MSO)
{
if (StrMsg.Length > 2)
{
if (Connections[GetConnIdx(MSO.UCID)].Username == StrMsg[1] && StrMsg[1].Length > 1)
{
InSim.Send_MTC_MessageToConnection("^1)^7 You can't send PM to yourself!", MSO.UCID, 0);
}
else
{
clsConnection Conn = Connections[GetConnIdx(MSO.UCID)];
bool PMUserFound = false;
foreach (clsConnection C in Connections)
{
string Message = Msg.Remove(0, C.Username.Length + 5);

if (C.Username == StrMsg[1] && StrMsg[1].Length > 1)
{
PMUserFound = true;

InSim.Send_MTC_MessageToConnection("^6)^7 Message Sent To: ^7" + C.PlayerName + " [" + C.Username + "]", MSO.UCID, 0);
InSim.Send_MTC_MessageToConnection("^6)^7 Msg: ^7" + Message, MSO.UCID, 0);



InSim.Send_MTC_MessageToConnection("^6)^7 PM From: ^7" + Conn.PlayerName + " [" + Conn.Username + "]", C.UniqueID, 0);
InSim.Send_MTC_MessageToConnection("^6)^7 Msg: ^7" + Message, C.UniqueID, 0);


foreach (clsConnection F in Connections)
{
if ((F.IsAdmin == 1 && F.UniqueID != MSO.UCID))
{
InSim.Send_MTC_MessageToConnection("^1)^7 PM From: ^7" + Conn.PlayerName + " to " + C.PlayerName, F.UniqueID, 0);
InSim.Send_MTC_MessageToConnection("^1)^2 Msg: ^7" + Message, F.UniqueID, 0);
}
}
}
}
if (PMUserFound == false)
{
InSim.Send_MTC_MessageToConnection("^1)^7 Username not found.", MSO.UCID, 0);
}

}

}
else
{
InSim.Send_MTC_MessageToConnection("^1)^7 Invalid Command.", MSO.UCID, 0);
}
}

If you have any questions feel free to ask

Pm
(2 posts, started )
FGED GREDG RDFGDR GSFDG