The online racing simulator
Another Button Question (BTT)
(2 posts, started )
Another Button Question (BTT)
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.
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)
(2 posts, started )
FGED GREDG RDFGDR GSFDG