The online racing simulator
problem with bank
hi,
my problem is that i am the only one that can see the bank but the other players can not see the bank. what can i do for the other players also see the bank ?
the code of bank is:


// City Bank
int BankDist = ((int)Math.Sqrt(Math.Pow(MCI.Info[i].X - (284 * 196608), 2) + Math.Pow(MCI.Info[i].Y - (-334 * 196608), 2)) / 65536);
if (BankDist <= 10)
{
if ((MCI.Info[i].Speed / 147) <= 3)

if (Conn.InBank == 0)
{
// <<Bank Display>>
InSim.Send_BTN_CreateButton("", Flags.ButtonStyles.ISB_DARK, 50, 100, 50, 50, 160, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("", Flags.ButtonStyles.ISB_DARK, 50, 100, 50, 50, 161, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7Welcome to City ^6Bank", Flags.ButtonStyles.ISB_LIGHT, 7, 98, 51, 51, 162, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7Your bank balance is ^6€" + Conn.BankBalance, Flags.ButtonStyles.ISB_LEFT, 4, 40, 65, 54, 163, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7Time until Bonus ^6" + Conn.Timer + "^6 Minute(s)", Flags.ButtonStyles.ISB_LEFT, 4, 40, 69, 54, 164, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^6Insert", "Enter amount to Insert", Flags.ButtonStyles.ISB_LIGHT | Flags.ButtonStyles.ISB_CLICK, 4, 10, 73, 54, 54, 165, Conn.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("^6Withdraw", "Enter amount to Withdraw", Flags.ButtonStyles.ISB_LIGHT | Flags.ButtonStyles.ISB_CLICK, 4, 10, 73, 64, 64, 166, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7CLOSE", Flags.ButtonStyles.ISB_LIGHT | Flags.ButtonStyles.ISB_CLICK, 4, 10, 92, 95, 167, Conn.UniqueID, 2, false);
Conn.InBank = 1;
}
}

else if (BankDist > 14 && Conn.InBank == 1)
{
Conn.InBank = 0;
// <<Bank Display Removal>>
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 160, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 161, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 162, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 163, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 164, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 165, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 166, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 167, Conn.UniqueID);
}

dont use MCI.Info rather use the compcar packets as i find it works alot more effecient and it can be used anywhere within the source.
#4 - smcsc
the conn.compcar gives an error


// City Bank
int BankDist = ((int)Math.Sqrt(Math.Pow(Conn.CompCar.X - (296 * 196608), 2) + Math.Pow(Conn.CompCar.Y - (-331 * 196608), 2)) / 65536);
if (BankDist < 4 && (Conn.CompCar.Speed / 147) <= 3)
{

if (Conn.InBank == 0)
{
// <<Bank Display>>
InSim.Send_BTN_CreateButton("", Flags.ButtonStyles.ISB_DARK, 50, 100, 50, 50, 160, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("", Flags.ButtonStyles.ISB_DARK, 50, 100, 50, 50, 161, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7Welcome to City ^6Bank", Flags.ButtonStyles.ISB_LIGHT, 7, 98, 51, 51, 162, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7Your bank balance is ^6€" + Conn.BankBalance, Flags.ButtonStyles.ISB_LEFT, 4, 40, 65, 54, 163, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7Time until Bonus ^6" + Conn.Timer + "^6 Minute(s)", Flags.ButtonStyles.ISB_LEFT, 4, 40, 69, 54, 164, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^6Insert", "Enter amount to Insert", Flags.ButtonStyles.ISB_LIGHT | Flags.ButtonStyles.ISB_CLICK, 4, 10, 73, 54, 54, 165, Conn.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("^6Withdraw", "Enter amount to Withdraw", Flags.ButtonStyles.ISB_LIGHT | Flags.ButtonStyles.ISB_CLICK, 4, 10, 73, 64, 64, 166, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7CLOSE", Flags.ButtonStyles.ISB_LIGHT | Flags.ButtonStyles.ISB_CLICK, 4, 10, 92, 95, 167, Conn.UniqueID, 2, false);
Conn.InBank = 1;
}
}

else if (BankDist > 14 && Conn.InBank == 1)
{
Conn.InBank = 0;
// <<Bank Display Removal>>
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 160, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 161, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 162, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 163, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 164, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 165, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 166, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 167, Conn.UniqueID);
}

what i do?
all conn. gives an error
Which is the first loop in the MCI packet? You can use foreach instead of for(in case you use this).
#6 - smcsc
the error is:



DarkKostas i can´t use that program because i don´t know how i use him.
try to use C. and not Conn.
Quote from peugeot206 :hi,
my problem is that i[..]

Quote from smcsc :but the conn.compcar[..]

If both of those accounts are yours, then, in my list, you classify as a spammer. You were close before with your many threads, and no knowledge in programming, but this will top it off if confirmed.

And just so I give you some help on the topic, before I stop seeing any point in doing it: Have you ever declared a variable with the name Conn?

(not trying to sound important, but this is slowly getting.. call it demotivating)
#9 - smcsc
bronken the peugeot206 is my brother. you have problems?
Quote from smcsc :bronken the peugeot206 is my brother. you have problems?

Relax dude.. Its her brother broken.

Broken, this topic its for help smcsc with her insim, if you dont like the topic or something go away and dont come back ok ?

He only need help
and now?

Replace them with Conn.Speed instead of Conn.Compcar.Speed
The most logical thing to do is to read the definition of Conn in Conn.cs file and find out what members it actually contains.
now the error is in X and Y

i dont understand why you have a conn.cs all you need to do is define the var


var Conn = Connections[GetConnIdx(PACKET HERE.UCID)];

with the packet here you can replace it with whatever packet you are coding under.
CompCar should not be defined as "byte", but as a data structure (or Object in case of C#), are you sure you're doing in the right way? It looks like Conn.CompCar only returns an index to a CompCar structure in the MCI packet.
Quote from Beaver08 :i dont understand why you have a conn.cs all you need to do is define the var

var Conn = Connections[GetConnIdx(PACKET HERE.UCID)];

with the packet here you can replace it with whatever packet you are coding under.

They both mean the same thing, only in one instance you're telling the compiler what type you want, in the other you're telling the compiler "go figure out the type for me". It's entriely down to preference whether you use it or not, the only situation it's required (and why it was added to the language) is for declaring an anonymous object. Sometimes using var makes the code clearer, sometimes it makes the code less clear, sometimes it's needed, sometimes you must declare the full type. There is no right or wrong here.
And now what is the problem because the bank does not appear on the screen?

Please don't post screenshots of your code, it's pain in the ass to wait for the images to load and read it from them. PHP tags and CTRL+C/V are your friends.

Is the statement that triggers displaying the bank interface ever true? Have you tried displaying the actual values of BankDist and Speed to see if it ever meets your conditions? Does it work if you display the buttons globally to every player? It's impossible to give you any really useful answer without having the whole source...
the full code of my bank.


// City Bank
int BankDist = ((int)Math.Sqrt(Math.Pow(Conn.CompCar.X - (-208 * 196608), 2) + Math.Pow(Conn.CompCar.Y - (-70 * 196608), 2)) / 65536);
if (BankDist < 10 && (Conn.CompCar.Speed / 147) <= 3)
{

if (Conn.InBank == 0)
{
// <<Bank Display>>
InSim.Send_BTN_CreateButton("", Flags.ButtonStyles.ISB_DARK, 50, 100, 50, 50, 160, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("", Flags.ButtonStyles.ISB_DARK, 50, 100, 50, 50, 161, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7Welcome to City ^6Bank", Flags.ButtonStyles.ISB_LIGHT, 7, 98, 51, 51, 162, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7Your bank balance is ^6€" + Conn.BankBalance, Flags.ButtonStyles.ISB_LEFT, 4, 40, 65, 54, 163, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7Time until Bonus ^6" + Conn.Timer + "^6 Minute(s)", Flags.ButtonStyles.ISB_LEFT, 4, 40, 69, 54, 164, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^6Insert", "Enter amount to Insert", Flags.ButtonStyles.ISB_LIGHT | Flags.ButtonStyles.ISB_CLICK, 4, 10, 73, 54, 54, 165, Conn.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("^6Withdraw", "Enter amount to Withdraw", Flags.ButtonStyles.ISB_LIGHT | Flags.ButtonStyles.ISB_CLICK, 4, 10, 73, 64, 64, 166, Conn.UniqueID, 2, false);
InSim.Send_BTN_CreateButton("^7CLOSE", Flags.ButtonStyles.ISB_LIGHT | Flags.ButtonStyles.ISB_CLICK, 4, 10, 92, 95, 167, Conn.UniqueID, 2, false);
Conn.InBank = 1;
}
}

else if (BankDist > 14 && Conn.InBank == 1)
{
Conn.InBank = 0;
// <<Bank Display Removal>>
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 160, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 161, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 162, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 163, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 164, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 165, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 166, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 167, Conn.UniqueID);
}

Now I would start my cruise insim and gave me this error what can I do?

http://img23.imageshack.us/img23/4331/erromv.jpg

i go translate to english the error:

"MSO - Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: Index"
I guess this happend when you try to type a command. Make sure the command is ok or the code before commands. If it crashes for every command then the problem is at the code before any command
I think the error is in code what can I do to fix it?
Run the app from MSVS in debugging mode, it'll show you where in the code you hit this error.
Quote from MadCatX :Run the app from MSVS in debugging mode, it'll show you where in the code you hit this error.

thanks.

FGED GREDG RDFGDR GSFDG