PDA

View Full Version : Need help with this bit of code


=C.R= Boomshanka
12th March 2009, 01:46
Hia guys can anyone tell me were i went wrong here, all im trying to do is make a button apper on the screen to a player and give the option to take away cash.

When playerA types the command !tow (AMOUNT) playerB, it should create a few buttons to playerB saying PlayerA wants to tow you do you except yes/no, if yes then -(AMOUNT) and gives to playerA if no then says playerB refuses your offer

here's the code

case"!tow":
if (StrMsg.Length > 2)
{
int TradeCash = 0;
try
{
TradeCash = Convert.ToInt32(StrMsg[2]);
if (TradeCash >= 0)
{
foreach (clsConnection Recipient in Connections)
{
if (Recipient.Username == Msg.Remove(0, (9 + StrMsg[1].Length + StrMsg[2].Length)))
{
if (Recipient.Cash >= TradeCash)
{
InSim.Send_BTN_CreateButton("^7" + Connections[GetConnIdx(MSO.UCID)].Username + " wants to tow you.", Flags.ButtonStyles.ISB_LEFT, 5, 100, 30, 72, 215, Recipient.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("^7Price: €" + TradeCash, Flags.ButtonStyles.ISB_LEFT, 5, 100, 35, 72, 216, Recipient.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("^7Do you except the tow?", Flags.ButtonStyles.ISB_LEFT, 5, 100, 40, 72, 217, Recipient.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("^2Yes", Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 5, 10, 47, 77, 218, Recipient.UniqueID, 40, false);
InSim.Send_BTN_CreateButton("^1No", Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK, 5, 10, 47, 97, 219, Recipient.UniqueID, 40, false);
SenderUCID = MSO.UCID;
SentMoney = TradeCash;
}
else
{
InSim.Send_MTC_MessageToConnection("^6|^7 The recipient doesn't have enough cash!", MSO.UCID, 0);
}
}
}
}
else
{
InSim.Send_MTC_MessageToConnection("^6|^7 Invalid selection. Please try again", MSO.UCID, 0);
}
}
catch
{
InSim.Send_MTC_MessageToConnection("^6|^7 an error in code has happened please contact a admin", MSO.UCID, 0);
}
}
else
{
InSim.Send_MTC_MessageToConnection("^6|^7 Invalid command. Please see ^2!help^7 for a command list", MSO.UCID, 0);
}
break;


thanks guys

=C.R= Boomshanka
12th March 2009, 01:48
costom button bit forgot sry


case 215:
Connections[GetConnIdx(SenderUCID)].Cash += Convert.ToInt32(SentMoney - (SentMoney / 20));
Connections[GetConnIdx(BTC.UCID)].Cash -= SentMoney;
InSim.Send_BFN_DeleteButton(0, 215, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 216, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 217, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 218, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 219, BTC.UCID);
InSim.Send_MTC_MessageToConnection("^6|^7 Transaction complete. Thank you for you custom!", BTC.UCID, 0);
InSim.Send_MTC_MessageToConnection("^6|^7 Transaction complete.", SenderUCID, 0);
InSim.Send_MTC_MessageToConnection("^6|^7 You received €" + SentMoney + " - 5% tax (€" + Convert.ToInt32(SentMoney - (SentMoney / 20)) + ")", SenderUCID, 0);
InSim.Send_MST_Message("/msg ^6|^7 " + Connections[GetConnIdx(SenderUCID)].Username + " Towed");
InSim.Send_MST_Message("/msg ^6|^7 " + Connections[GetConnIdx(BTC.UCID)].Username + " for €" + SentMoney);
break;

case 216:
InSim.Send_BFN_DeleteButton(0, 215, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 216, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 217, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 218, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 219, BTC.UCID);
InSim.Send_MTC_MessageToConnection("^6|^7 " + Connections[GetConnIdx(BTC.UCID)].Username + " rejected your offer", SenderUCID, 0);
break;

=C.R= Boomshanka
12th March 2009, 17:25
anyone got any ideas.?

=C.R= Boomshanka
13th March 2009, 23:30
Sweet sorry just got in, testin it now

thanks in advance :D

=C.R= Boomshanka
14th March 2009, 01:44
tryed it like this still not playing well :( no erros just when u try to do it halts at error cant find user ?


case "!tow":
if (StrMsg.Length > 2)
{
try
{
int Send = int.Parse(StrMsg[1]);
bool SendComplete = false;
foreach (clsConnection i in Connections)
{
if (i.Username == Msg.Remove(0, 7 + StrMsg[1].Length))
{
SendComplete = true;
if (StrMsg[1].Contains("-"))
{
InSim.Send_MTC_MessageToConnection("^1Send Error. Please don't use minus values!", MSO.UCID, 0);
}
else if (Connections[GetConnIdx(MSO.UCID)].Cash >= Send)
{
InSim.Send_BTN_CreateButton("^1" + Connections[GetConnIdx(MSO.UCID)].Username + "^7 wants to tow you for^2 " + Connections[GetConnIdx(MSO.UCID)] .Cash + "€", Flags.ButtonStyles.ISB_DARK, 8, 60, 30, 20, 215, i.UniqueID, 1, false);
InSim.Send_BTN_CreateButton("Accept", Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK | Flags.ButtonStyles.ISB_C4, 6, 15, 40, 20, 216, i.UniqueID, 1, false);
InSim.Send_BTN_CreateButton("Denied", Flags.ButtonStyles.ISB_DARK | Flags.ButtonStyles.ISB_CLICK | Flags.ButtonStyles.ISB_C1 | Flags.ButtonStyles.ISB_C4, 6, 15, 40, 40, 217, i.UniqueID, 1, false);
}
else if (Connections[GetConnIdx(MSO.UCID)].Cash < Send)
{
InSim.Send_MTC_MessageToConnection("^1You don't have enough cash to complete the transaction.", MSO.UCID, 0);
}
}
}
if (SendComplete == false)
{
InSim.Send_MTC_MessageToConnection("^1Send Error. User not found.", MSO.UCID, 0);
}
}
catch
{
InSim.Send_MTC_MessageToConnection("^1Error has occured. Amount too high.", MSO.UCID, 0);
}
}
else
{
InSim.Send_MTC_MessageToConnection("^1Invalid send command. Please try again.", MSO.UCID, 0);
}
break;



case 215:
Connections[GetConnIdx(SenderUCID)].Cash += Convert.ToInt32(SentMoney - (SentMoney / 20));
Connections[GetConnIdx(BTC.UCID)].Cash -= SentMoney;
InSim.Send_BFN_DeleteButton(0, 215, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 216, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 217, BTC.UCID);
InSim.Send_MTC_MessageToConnection("^6|^7 Transaction complete. Thank you for you custom!", BTC.UCID, 0);
InSim.Send_MTC_MessageToConnection("^6|^7 Transaction complete.", SenderUCID, 0);
InSim.Send_MTC_MessageToConnection("^6|^7 You received €" + SentMoney + "for this tow" , SenderUCID, 0);
InSim.Send_MST_Message("/msg ^6|^7 " + Connections[GetConnIdx(SenderUCID)].Username + " Towed");
InSim.Send_MST_Message("/msg ^6|^7 " + Connections[GetConnIdx(BTC.UCID)].Username + " for €" + SentMoney);
break;

case 216:
InSim.Send_BFN_DeleteButton(0, 215, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 216, BTC.UCID);
InSim.Send_BFN_DeleteButton(0, 217, BTC.UCID);
InSim.Send_MTC_MessageToConnection("^6|^7 " + Connections[GetConnIdx(BTC.UCID)].Username + " rejected your offer", SenderUCID, 0);
break;