The online racing simulator
CancelJob Command Help!
Hello guys i was making a cruise insim for fun and editing stuff in it. And i was thinking how can i make a CancelJob command? Im using C# And the code i got now is
[Command("canceljob", "canceljob")]
public void canceljob(string Msg, string[] StrMsg, Packets.IS_MSO MSO)
{
clsConnection Conn = Connections[GetConnIdx(MSO.UCID)];
if (StrMsg.Length > 0)
{
if (Conn.JobToHouse2 == 1)
{
(Conn.JobToHouse2 == 0);
InSim.Send_MTC_MessageToConnection("^6--^7 Job Canceled!", MSO.UCID, 0);
}
}
}

if this is correct or wrong can you correct me? Thanks and i know this is wrong but i need help ;(
[Command("canceljob", "canceljob")]
public void canceljob(string Msg, string[] StrMsg, Packets.IS_MSO MSO)
{
clsConnection Conn = Connections[GetConnIdx(MSO.UCID)];
if (StrMsg.Length > 0)
{
if (Conn.JobToHouse2 == 1)
{
InSim.Send_MTC_MessageToConnection("^6--^7 Job Canceled!", MSO.UCID, 0);
}
Conn.JobToHouse2 == 0;
}
}

Fixed command for you. Just put the '' (Conn.JobToHouse2 == 0); '' without the ( ) , and under the }
I now get a error code :
Quote :Error 1 Only assignment, call, increment, decrement, and new object expressions can be used as a statement

Quote from Chriship :
[Command("canceljob", "canceljob")]
public void canceljob(string Msg, string[] StrMsg, Packets.IS_MSO MSO)
{
clsConnection Conn = Connections[GetConnIdx(MSO.UCID)];
if (StrMsg.Length > 0)
{
if (Conn.JobToHouse2 == 1)
{
InSim.Send_MTC_MessageToConnection("^6--^7 Job Canceled!", MSO.UCID, 0);
}
Conn.JobToHouse2 == 0;
}
}

Fixed command for you. Just put the '' (Conn.JobToHouse2 == 0); '' without the ( ) , and under the }

Conn.JobToHouse2 is still wrong in this code...
also it's in the wrong position..

[Command("canceljob", "canceljob")]
public void canceljob(string Msg, string[] StrMsg, Packets.IS_MSO MSO)
{
clsConnection Conn = Connections[GetConnIdx(MSO.UCID)];
if (StrMsg.Length > 0)
{
if (Conn.JobToHouse2 == 1)
{
InSim.Send_MTC_MessageToConnection("^6--^7 Job Canceled!", MSO.UCID, 0);
Conn.JobToHouse2 = 0;
}

}
}

the above will fix your command and also you can add other cancel jobs to it like


if (Conn.JobToHouse2 == 1)
{
InSim.Send_MTC_MessageToConnection("^6--^7 Job Canceled!", MSO.UCID, 0);
Conn.JobToHouse2 = 0;
}
else if (Conn.JobToHouse3 == 1)
{
InSim.Send_MTC_MessageToConnection("^6--^7 Job Canceled!", MSO.UCID, 0);
Conn.JobToHouse3 = 0;
}

also add an else incase you don't have a job


if (Conn.JobToHouse2 == 1)
{
InSim.Send_MTC_MessageToConnection("^6--^7 Job Canceled!", MSO.UCID, 0);
Conn.JobToHouse2 = 0;
}
else if (Conn.JobToHouse3 == 1)
{
InSim.Send_MTC_MessageToConnection("^6--^7 Job Canceled!", MSO.UCID, 0);
Conn.JobToHouse3 = 0;
}
else
{
InSim.Send_MTC_MessageToConnection("^6--^7 You have no job to cancel!", MSO.UCID, 0);
}

Not gana make a new topic but what about adding Random jobs like now i only have it set to one place? Any help Beav?
Your own your own with that one post some code i might help fix it for you tho =)

EDIT: Also thanks for saying thanks for the bug fixes *sarcasm was included in this sentence*
Gah! Was to busy fixing my code with your code so couldent say thanks. Anyways thanks beav for the code Helped me alot

FGED GREDG RDFGDR GSFDG