2013-02-25 89 views
1

我環顧四周,我收集到它意味着中斷是無法訪問的,但我不明白它如何無法訪問或它試圖訪問的內容。我得到了錯誤的代碼如下,也許有人能告訴我該怎麼添加使斷裂可達:控件無法從一個案例標籤跳轉到另一個案例

#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 
+6

您有一個SQL注入漏洞。 – SLaks 2013-02-25 03:42:28

+3

你的縮進很奇怪,但看起來'break'在'if'裏面? – 2013-02-25 03:42:33

+0

格式化您的代碼使其更加明顯。如果您使用Visual Studio,請嘗試按下「Ctrl-e」,然後按「Ctrl-d」或轉到「編輯/高級/格式化文檔」。 – 2013-02-25 03:44:46

回答

4

該錯誤意味着,有一些情況,其中break;不會被打到。

具體而言,if (Item == "bread")並非如此。

1

將最後}以外的break移開。使用您的代碼,如果該項目不是「麪包」,則未到達break

相關問題