The online racing simulator
Searching in All forums
(208 results)
Beaver08
No longer welcome
ok after many hours of drinking and thinking i managed to do what i needed and for other people just like me learning i might aswell show the coding which was required.


// A player submitted a custom textbox
private void BTT_TextBoxOkClicked(Packets.IS_BTT BTT)
{
try
{
switch (BTT.ClickID)
{
case 191:
if (Connections[GetConnIdx(BTT.UCID)].InBank == 1) // Deposit
{
int Deposit = int.Parse(BTT.Text);
if (BTT.Text.Contains("-"))
{
InSim.Send_MTC_MessageToConnection("^1* ^3Deposit Error. Please don't use minus values!", Connections[GetConnIdx(BTT.UCID)].UniqueID, 0);
}
else if (Connections[GetConnIdx(BTT.UCID)].Cash >= Deposit)
{
Connections[GetConnIdx(BTT.UCID)].BankBalance += Deposit;
Connections[GetConnIdx(BTT.UCID)].Cash -= Deposit;
Connections[GetConnIdx(BTT.UCID)].TodaysCash -= Deposit;
Connections[GetConnIdx(BTT.UCID)].Timer = 60;
InSim.Send_MTC_MessageToConnection("^1*^3 You successfully deposited ^7£" + Deposit, Connections[GetConnIdx(BTT.UCID)].UniqueID, 0);
InSim.Send_MTC_MessageToConnection("^1*^3 Your new Bank Balance is ^7£" + Connections[GetConnIdx(BTT.UCID)].BankBalance, Connections[GetConnIdx(BTT.UCID)].UniqueID, 0);
}
else if (Connections[GetConnIdx(BTT.UCID)].Cash < Deposit)
{
InSim.Send_MTC_MessageToConnection("^1* ^3You don't have enough cash to complete the transaction.", Connections[GetConnIdx(BTT.UCID)].UniqueID, 0);
}
}
break;

case 193:
if (Connections[GetConnIdx(BTT.UCID)].InBank == 1) // Withdraw
{
int Withdraw = int.Parse(BTT.Text);
if (BTT.Text.Contains("-"))
{
InSim.Send_MTC_MessageToConnection("^1* ^3Error. Please don't use minus values!", Connections[GetConnIdx(BTT.UCID)].UniqueID, 0);
}
else if (Connections[GetConnIdx(BTT.UCID)].BankBalance >= Withdraw)
{
Connections[GetConnIdx(BTT.UCID)].BankBalance -= Withdraw;
Connections[GetConnIdx(BTT.UCID)].Cash += Withdraw;
Connections[GetConnIdx(BTT.UCID)].Timer = 60;
Connections[GetConnIdx(BTT.UCID)].TodaysCash += Withdraw;
InSim.Send_MTC_MessageToConnection("^1*^3 You successfully withdrew ^7£" + Withdraw, Connections[GetConnIdx(BTT.UCID)].UniqueID, 0);
InSim.Send_MTC_MessageToConnection("^1*^3 Your new Bank Balance is ^7£" + Connections[GetConnIdx(BTT.UCID)].BankBalance, Connections[GetConnIdx(BTT.UCID)].UniqueID, 0);
}
else if (Connections[GetConnIdx(BTT.UCID)].BankBalance < Withdraw)
{
InSim.Send_MTC_MessageToConnection("^1* ^3You don't have enough cash to complete the transaction.", Connections[GetConnIdx(BTT.UCID)].UniqueID, 0);
}

}
break;

}
}
catch (Exception EX)
{
//MessageBox.Show("STA - " + EX.Message);
}
}

Hope this helps others for future reference.
Another Button Question (BTT)
Beaver08
No longer welcome
hi guys got another problem i've made a button when clicked for it to open a text box to allow user input i just don't know how to code the input that was made.


if (Connections[GetConnIdx(BTC.UCID)].InBank == 1) // Withdraw
{

}

that's the header i need to put the input but i need it to use my !withdraw command i know i gotta use BTT packets but i just dont know how to code it the forums so far hasn't been much help in telling me exactly what i need to code/write


case "!withdraw":
if (Connections[GetConnIdx(MSO.UCID)].InBank == 1)
{
int Withdraw = int.Parse(StrMsg[1]);
{
if (StrMsg[1].Contains("-"))
{
InSim.Send_MTC_MessageToConnection("^1* ^3Error. Please don't use minus values!", MSO.UCID, 0);
}
else if (Connections[GetConnIdx(MSO.UCID)].BankBalance >= Withdraw)
{
Connections[GetConnIdx(MSO.UCID)].BankBalance -= Withdraw;
Connections[GetConnIdx(MSO.UCID)].Cash += Withdraw;
Connections[GetConnIdx(MSO.UCID)].Timer = 60;
Connections[GetConnIdx(MSO.UCID)].TodaysCash += Withdraw;
InSim.Send_MTC_MessageToConnection("^1*^3 Your new Bank Balance is ^7£" + Connections[GetConnIdx(MSO.UCID)].BankBalance, MSO.UCID, 0);
}
else if (Connections[GetConnIdx(MSO.UCID)].BankBalance < Withdraw)
{
InSim.Send_MTC_MessageToConnection("^1* ^3You don't have enough cash to complete the transaction.", MSO.UCID, 0);
}
}
}
break;

If somebody could help me on how to write/code the first line even on how to read the input and take it from the players bank and into the players cash, would be greatly appreciated.
Beaver08
No longer welcome
to be honest i saw that same answer in a post to do with some other query so i did try using c.blah blah but it was spamming the commands twice when i clicked the button once.

i really dont get why it doesnt work unfortantly this bug is running on my server now if you wana test it out for yourself and if you can think of any other ideas to fix this as i'm also asking quite a few other people who are all telling me there is not a problem in the code. i'm completely baffled

Server: [WKD] Cruise Server


EDIT: ok problem solved i just decided to re-write the whole lot seems to work now. no idea why it didnt before tho.
Last edited by Beaver08, .
Click Button Only Works For One Player?
Beaver08
No longer welcome
hi guys i have a new problem i've made a few menus on my server for shops and for some reason when any player other than the first player that joined clicks one of the buttons they do nothing, where as the first player that joins has all the buttons working perfectly.

my code is :



private void BTC_ButtonClicked(Packets.IS_BTC BTC)
{
try
{

switch (BTC.ClickID)
{


case 186: // Close Button

if (Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].InShop == 1) // Close Pizza
{
// Shop Menu
InSim.Send_BFN_DeleteButton(0, 176, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
// Shop Name
InSim.Send_BFN_DeleteButton(0, 177, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
// Shop Items
InSim.Send_BFN_DeleteButton(0, 178, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 179, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 180, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 181, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 182, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 183, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 184, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 185, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
// Click buttons
InSim.Send_BFN_DeleteButton(0, 186, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Close
InSim.Send_BFN_DeleteButton(0, 187, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 1
InSim.Send_BFN_DeleteButton(0, 188, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 2
InSim.Send_BFN_DeleteButton(0, 189, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 3
InSim.Send_BFN_DeleteButton(0, 190, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 4
InSim.Send_BFN_DeleteButton(0, 191, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 5
InSim.Send_BFN_DeleteButton(0, 192, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 6
InSim.Send_BFN_DeleteButton(0, 193, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 7

}
if (Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].InLotto == 1) // Close Lotto
{
// Shop Menu
InSim.Send_BFN_DeleteButton(0, 176, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
// Shop Name
InSim.Send_BFN_DeleteButton(0, 177, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
// Shop Items
InSim.Send_BFN_DeleteButton(0, 178, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 179, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 180, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 181, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 182, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 183, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 184, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
InSim.Send_BFN_DeleteButton(0, 185, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);
// Click buttons
InSim.Send_BFN_DeleteButton(0, 186, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Close
InSim.Send_BFN_DeleteButton(0, 187, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 1
InSim.Send_BFN_DeleteButton(0, 188, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 2
InSim.Send_BFN_DeleteButton(0, 189, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 3
InSim.Send_BFN_DeleteButton(0, 190, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 4
InSim.Send_BFN_DeleteButton(0, 191, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 5
InSim.Send_BFN_DeleteButton(0, 192, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 6
InSim.Send_BFN_DeleteButton(0, 193, Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID);// Info 7
}

break;

case 187: // Buy Button 1

if (Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].InShop == 1) // Buy Pizza
{
if (Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].Health <= 89)
{
Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].Cash -= 10;
Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].Health += 10;
Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].TodaysCash -= 10;
InSim.Send_MTC_MessageToConnection("^1* ^3You bought a ^7Pizza", Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID, 0);
}
else
{
InSim.Send_MTC_MessageToConnection("^1* ^3Your health is too high to buy more food", (Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID), 0);
}
}
if (Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].InLotto == 1) // Buy Lotto Ticket
{
if (Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].InLotto == 1 && Environment.TickCount - Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].LastLotto > 1296000) //3 hours
{
Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].Cash -= 250;
Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].TodaysCash -= 250;
int prize = new Random().Next(0, 2000);
Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].Prize += prize;
Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].Cash += Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].Prize;
InSim.Send_MTC_MessageToConnection("^1* ^3You have received ^2£" + Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].Prize + " ^3from Lotto", Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID, 0);
Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].TodaysCash += Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].Prize;
Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].LastLotto = Environment.TickCount;
}
else if (Environment.TickCount - Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].LastLotto < 1296000)
{
InSim.Send_MTC_MessageToConnection("^1* ^3You have to wait ^73 ^3hours to buy another ticket", Connections[GetConnIdx(Players[GetPlyIdx(BTC.UCID)].UniqueID)].UniqueID, 0);
//Connections[GetConnIdx(MSO.UCID)].InLotto = 1;
}
}

break;



}
}
catch (Exception EX)
{
//MessageBox.Show("BTC - " + EX.Message);
}
}


the code is longer i just couldnt fit it all in

i dont see anything that i could have done wrong here, but like i said it only works for the first player that joined the server any ideas?
Beaver08
No longer welcome
so many views and not a post?
Buttons On View Change
Beaver08
No longer welcome
hi guys am a new Coder learning C#

i have an insim from the forums as a base, but i'm having a problem figuring out how to get which camera view the client is in.

i would like it if the clients camera is in "In-car view" for it to show a button and when the clients view has changed by pressing "V" that it delete that button. would it be possible for somebody to give me an example of how to code it, i know that it's gotta be in


// A player changed it's camera
private void CCH_CameraChanged(Packets.IS_CCH CCH)
{
}

just unsure on how to do it


EDIT:


private void CCH_CameraChanged(Packets.IS_CCH CCH)
{

//C.UniqueID = CCH.PLID;
if (CCH.Camera == Enums.View.VIEW_FOLLOW)// Arcade
{

Connections[GetConnIdx(CCH.PLID)].Cam = 0;
}
if (CCH.Camera == Enums.View.VIEW_HELI)// Helicopter
{


Connections[GetConnIdx(CCH.PLID)].Cam = 1;
}
if (CCH.Camera == Enums.View.VIEW_CAM)// TV Cam
{


Connections[GetConnIdx(CCH.PLID)].Cam = 2;
}
if (CCH.Camera == Enums.View.VIEW_DRIVER)// Cockpit
{


Connections[GetConnIdx(CCH.PLID)].Cam = 3;
}
if (CCH.Camera == Enums.View.VIEW_CUSTOM)// Custom Cam
{

Connections[GetConnIdx(CCH.PLID)].Cam = 4;
}

}

i have this now and it doesnt seem to change the .Cam id to any int that is there any ideas?
Last edited by Beaver08, .
Beaver08
No longer welcome
i appreciate your feedback however i wouldnt of posted first without fulling reading them posts i have been reading through the forums for a few days now i have actually created a very small program which has not much use but i was just requeting help on how to send packets ( the buttons ) to the client side i havent had much luck yet but i am still learning all i would need is a code to connect to a LFS Client ( IE Mine) and then show the buttons similiar to interior gauges i have seen but instead of them just buttons
Outsim Help
Beaver08
No longer welcome
hey guys (1st Post )

I am very new to LFS Coding and have started to create a simple Outsim program to show simple things ie car name, speed and RPM but how would i go about creating buttons which would send the data from the Outsim program into the LFS Client so i can see it on my screen any help would be greately appreciated

P.S i have done C# before but nothing like this xD
FGED GREDG RDFGDR GSFDG