我环顾四周,我认为这意味着休息无法到达,但我不明白它是如何无法到达或者它想要达到的目的。我得到错误的代码如下,也许有人可以告诉我要添加什么来使中断可达:
#region :buy <item>
case "buy":
string Item = stringManager.wrapParameters(args, 1);
if (Item == "bread")
{
int foodfunds;
int myfood;
int foodCheck;
int creditCheck;
using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
foodfunds = dbClient.getInt("SELECT credits FROM users WHERE name = '" + _Username + "'");
using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
myfood = dbClient.getInt("SELECT food FROM users WHERE name = '" + _Username + "'");
if (foodfunds < 10)
{
Room.sendData("BK" + "Not enough cash.");
}
if (_roomID != 193)
{
sendData("BK" + "You must be in the supermarket to buy bread");
}
else
{
using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
dbClient.runQuery("UPDATE users SET food = food + 1 WHERE name = '" + _Username + "'");
using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
foodCheck = dbClient.getInt("SELECT food FROM users WHERE name = '" + _Username + "'");
using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
dbClient.runQuery("UPDATE users SET credits = credits - 10 WHERE name = '" + _Username + "'");
using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
creditCheck = dbClient.getInt("SELECT credits FROM users WHERE name = '" + _Username + "'");
Room.sendShout(roomUser, "*Buys a loaf of bread and stashes in bag*");
Room.sendSaying(roomUser, "(Now have: " + foodCheck + " loaves of bread)");
Room.sendSaying(roomUser, "(Now have: " + creditCheck + " credits left)");
}
if (myfood > 255)
{
Room.sendData("BK" + "You cannot carry anymore food!");
}
break;
}
#endregion
答案 0 :(得分:4)
该错误意味着在某些情况下break;
不会被击中。
具体来说,if (Item == "bread")
不是真的。
答案 1 :(得分:1)
将break
移到最后}
之外。使用您的代码,如果项目不是“面包”,则无法访问break
。