The online racing simulator
!pm command help!
i am making a command in a insim to private message people and here is a example of the code i made. i desided to just let the forum help me because i have no clue on how to finish this command. sorry if it such a simple command i just dont know!!!

[Command("pm", "pm <username> <message>")]
public void pm(string Msg, string[] StrMsg, Packets.IS_MSO MSO)
{
// string Send = StrMsg[1];

foreach (clsConnection i in Connections)
{
if (i.Username == Msg.Remove(0, 4))
{
InSim.Send_MTC_MessageToConnection("^6> ^7Private Message from " + Connections[GetConnIdx(MSO.UCID)].PlayerName, i.UniqueID, 0);
InSim.Send_MTC_MessageToConnection("^6> ^7" + Msg.Remove(0, StrMsg[1].Length + 1), i.UniqueID, 0);
}

}

-
(mariuba2) DELETED by mariuba2
the next strmsg must be removed so the messge will be received

I'll give a sample for yah c'ya in msn
#3 - PoVo
Quote from skywatcher122 :the next strmsg must be removed so the messge will be received

I'll give a sample for yah c'ya in msn

Is it so hard posting the code here? Or you want 1202419347803174 more threads like this?
Here it is guys...
what a pitty that no other coder post codes.. like this easy things..


<?php 
                   
case "!pmsg":
                    if (
StrMsg.Length 2)
                    {
                        
string Message Msg.Remove(0StrMsg[1].Length);
                        
bool SendComplete false;

                        foreach (
clsConnection Conn in Connections)
                        {
                            if (
Conn.Username.ToUpper().Contains(StrMsg[1].ToUpper()))
                            {
                                if (
Connections[GetConnIdx(MSO.UCID)].Username == StrMsg[1])
                                {
                                    
InSim.Send_MTC_MessageToConnection("^3>^7 You cant can send a pm to yourself!"MSO.UCID0);
                                }
                                else
                                {

                                        
SendComplete true;
                                        
InSim.Send_MTC_MessageToConnection("Private Message :"MSO.UCID0);
                                        
InSim.Send_MTC_MessageToConnection("To " Conn.PlayerName MSO.UCID0);

                                        
InSim.Send_MTC_MessageToConnection("^7 " MessageMSO.UCID0);
                                        
                                        
InSim.Send_MTC_MessageToConnection("Private Message :"Conn.UniqueID0);
                                        
InSim.Send_MTC_MessageToConnection("From " Connections[GetConnIdx(MSO.UCID)].PlayerNameConn.UniqueID0);

                                        
InSim.Send_MTC_MessageToConnection("^^7 " MessageConn.UniqueID0);
                                        }
                                    

                                }
                            }

                        }
                    
                    else
                    {
                        
InSim.Send_MTC_MessageToConnection("^3>^7 Invalid message or username."MSO.UCID0);
                    }
                    break;
?>

Quote from Heiko1 :Here it is guys...
what a pitty that no other coder post codes.. like this easy things..


<?php 
                   
case "!pmsg":
                    if (
StrMsg.Length 2)
                    {
                        
string Message Msg.Remove(0StrMsg[1].Length);
                        
bool SendComplete false;

                        foreach (
clsConnection Conn in Connections)
                        {
                            if (
Conn.Username.ToUpper().Contains(StrMsg[1].ToUpper()))
                            {
                                if (
Connections[GetConnIdx(MSO.UCID)].Username == StrMsg[1])
                                {
                                    
InSim.Send_MTC_MessageToConnection("^3>^7 You cant can send a pm to yourself!"MSO.UCID0);
                                }
                                else
                                {

                                        
SendComplete true;
                                        
InSim.Send_MTC_MessageToConnection("Private Message :"MSO.UCID0);
                                        
InSim.Send_MTC_MessageToConnection("To " Conn.PlayerName MSO.UCID0);

                                        
InSim.Send_MTC_MessageToConnection("^7 " MessageMSO.UCID0);
                                        
                                        
InSim.Send_MTC_MessageToConnection("Private Message :"Conn.UniqueID0);
                                        
InSim.Send_MTC_MessageToConnection("From " Connections[GetConnIdx(MSO.UCID)].PlayerNameConn.UniqueID0);

                                        
InSim.Send_MTC_MessageToConnection("^^7 " MessageConn.UniqueID0);
                                        }
                                    

                                }
                            }

                        }
                    
                    else
                    {
                        
InSim.Send_MTC_MessageToConnection("^3>^7 Invalid message or username."MSO.UCID0);
                    }
                    break;
?>


that code is like !pmsg <message> <username> sounds like sending a cash

why not try this


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

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

                            
InSim.Send_MTC_MessageToConnection("^4|^3 Message Sent To: ^7" C.NoColPlyName " (" C.Username ")"MSO.UCID0);
                            
InSim.Send_MTC_MessageToConnection("^4|^3 Msg: ^7" MessageMSO.UCID0);
                            
                            
InSim.Send_MTC_MessageToConnection("^4|^3 PM From: ^7" Conn.NoColPlyName " (" Conn.Username ")"C.UniqueID0);
                            
InSim.Send_MTC_MessageToConnection("^4|^3 Msg: ^7" MessageC.UniqueID0);
                            
InSim.Send_MTC_MessageToConnection("^4|^3 To reply use ^2!pm " Conn.Username " <message>"C.UniqueID0);

                            foreach (
clsConnection F in Connections)
                            {
                                if ((
F.IsAdmin == && F.IsSuperAdmin == 1) && F.UniqueID != MSO.UCID)
                                {
                                    
InSim.Send_MTC_MessageToConnection("^4|^3 PM From: ^7" Conn.NoColPlyName " to " C.NoColPlyNameF.UniqueID0);
                                    
InSim.Send_MTC_MessageToConnection("^4|^3 Msg: ^7" MessageF.UniqueID0);
                                }
                            }
                        }
                    }
                    if (
PMUserFound == false)
                    {
                        
InSim.Send_MTC_MessageToConnection("^4|^7 Username not found."MSO.UCID0);
                    }
                }
            }
            else
            {
                
InSim.Send_MTC_MessageToConnection("^4|^7 Invalid Command."MSO.UCID0);
            }
        }
?>

note: NoColPlyName is like removing all colors of playername so just replace it in PlayerName perhaps and remove the IsSuperAdmin if only u don't have it :P

Quote from PoVo :Is it so hard posting the code here? Or you want 1202419347803174 more threads like this?

why not post yours? so it would be helpful for those 1202419347803174 threads that possibly in the future?
Quote from skywatcher122 :that code is like !pmsg <message> <username> sounds like sending a cash


your code is the same as mine -.-
and im not using <msg> <username>
im doing the same as you.. !pm <username> <msg>

first read then talk
im using StrMsg not msg removing
read what ive got includet StrMsg[x] -.- its the same
AFAIK, the codes like StrMsg[1] u did on sample works only in non-spaced usernames so thats why i made StrMsg[1] && StrMsg[1].Lenghts > 1 well lets just not fight with the !pm code anyways
haha thanks both of you.
ok the code worked i just done a bit of a mod to it and it worked fine thanks
Both of these won't work with usernames, containing spaces.

I recently stripped out my pm command from OsC, which is based on dougie-lampkin's cruise thingo, because I was sending it to someone. It's not very optimized, I'm sure, that I can rewrite it in a much better way, but it works, so here it is:

case "!pm":
try
{
if (Msg.Remove(0, 4).Length > 1)
{
string message = Msg.Remove(0, 3);
string userright = "wrong";
foreach (clsConnection PMuser in Connections)
{
if (message.IndexOf(PMuser.Username) == 1)
{
userright = "right";
string PMmsg = message.Remove(message.IndexOf(PMuser.Username), (PMuser.Username.Length + 1));
InSim.Send_MTC_MessageToConnection("^3» ^7Personal message to " + PMuser.PlayerName + "^7:", MSO.UCID, 0);
InSim.Send_MTC_MessageToConnection("^3»^7" + PMmsg, MSO.UCID, 0);
InSim.Send_MTC_MessageToConnection("^3» ^7Personal message from " + Connections[GetConnIdx(MSO.UCID)].PlayerName + "^7:", PMuser.UniqueID, 0);
InSim.Send_MTC_MessageToConnection("^3»^7" + PMmsg, PMuser.UniqueID, 0);
}
}
if (userright != "right")
{
InSim.Send_MTC_MessageToConnection("^3» ^1Wrong syntax.", MSO.UCID, 0);
InSim.Send_MTC_MessageToConnection("^3» ^2The right syntax is: !pm [username] [message].", MSO.UCID, 0);
}
}
}
catch
{
InSim.Send_MTC_MessageToConnection("^3» ^1Your message could not be sent.", MSO.UCID, 0);
}
break;

I'm not very happy about it. In fact - I am not at all happy about it. But when I reach that point in my current project, I'll post the pm snippet, probably in the thread I posted a while ago.

Quote from Heiko1 :[..]
what a pitty that no other coder post codes.. like this easy things..
[..]

?!
actually I forgot to add this syntax


<?php 
C
.Username.Contains(StrMsg[1]) == true && C.Username.Contains(StrMsg[2]) == true
?>


but meh your code is doing fine broken
Quote from skywatcher122 :actually I forgot to add this syntax


<?php 
C
.Username.Contains(StrMsg[1]) == true && C.Username.Contains(StrMsg[2]) == true
?>


but meh your code is doing fine broken

Your snippet is even worse than mine.. I, personally, would never count on such a thing. Sorry..
Maybe try this?

PHP Code:
C.Username.Contains.(" ") + (StrMsg[1]) == true && C.Username.Contains.(" ") + (StrMsg[2]) == true *


Or

PHP Code:
C.Username.(StrMsg[1]) == true && C.Username.Contains(StrMsg[2]) == true *
{*
If Contains(StrMsg[1]) == true

.....blah blah

Maybe try InSim.Parse("Crash"); ??
Quote from mariuba2 :Maybe try this?

PHP Code:
C.Username.Contains.(" ") + (StrMsg[1]) == true && C.Username.Contains.(" ") + (StrMsg[2]) == true *


Or

PHP Code:
C.Username.(StrMsg[1]) == true && C.Username.Contains(StrMsg[2]) == true *
{*
If Contains(StrMsg[1]) == true

.....blah blah

Maybe try InSim.Parse("Crash"); ??

How can you count on such a thing? O_O

What would you count on more:
1 - A script that iterates through all the connections, and checks if the string after "!pm " starts with the username of somebody;
Or 2 - A script that checks whether the 1st and 2nd word after !pm are contained(anywhere) in the username?


I would never count on 2. It makes no sense, and if you have a 3 word username after !pm, it just becomes irrelevant.

Sorry if I sound a bit harsh, I had no intentions to, but this just isn't the way.
Quote from broken :How can you count on such a thing? O_O

What would you count on more:
1 - A script that iterates through all the connections, and checks if the string after "!pm " starts with the username of somebody;
Or 2 - A script that checks whether the 1st and 2nd word after !pm are contained(anywhere) in the username?


I would never count on 2. It makes no sense, and if you have a 3 word username after !pm, it just becomes irrelevant.

Sorry if I sound a bit harsh, I had no intentions to, but this just isn't the way.

^^ i dont know, i was just trying to see if i was right with the code.

FGED GREDG RDFGDR GSFDG