Skip to content
View in the app

A better way to browse. Learn more.

GTAGames.nl - De Nederlandse Grand Theft Auto Community!

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help! warning 225: unreachable code

Hoi, ik ben pas nieuw met scripten en probeer elke keer is iets nieuws. Dit keer ben ik gefocused op dialog boxes en ben ik een probleem tegen gekomen. Ik probeer een dialog box te verwijzen naar mijn vorige dialog box, alleen werkt dat niet zo goed, misschien dat iemand me hier kan helpen?

Dialog id 3,4, en 5 zijn niet te vinden.

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==1 && response==1)
{
 switch(listitem)
 {
  case 0:
  {
   SendClientMessage(playerid, COLOR_RED, "You have locked your house.");
  }
  case 1:
  {
   SendClientMessage(playerid, COLOR_GREEN, "You have unlocked your house.");
  }
  case 2:
  {
   ShowPlayerDialog(playerid, 2, DIALOG_STYLE_MSGBOX, "Items", "**house items**", "Confirm", "Cancel");
  }
  case 3:
  {
   ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "Deposit items", "Cash $(your amount)\nMaterials(your amount)\nCrack(your amount)\nPot(your amount)\nWeapons(your weapons)", "Proceed", "Cancel");
  }
  case 4:
  {
   ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "Withdraw items", "Cash $(house amount)\nMaterials(house amount)\nCrack(house amount)\nPot(house amount)\nWeapons(house weapons)", "Proceed", "Cancel");
  }
  case 5:
  {
   ShowPlayerDialog(playerid, 5, DIALOG_STYLE_INPUT, "Housetag", "Enter your new house nametag.", "Confirm", "Cancel");
  }
  case 6:
  {
   ShowPlayerDialog(playerid, 6, DIALOG_STYLE_INPUT, "Sellhouse", "To which player do you wish to sell your house to?", "Proceed", "Cancel");
  }
  case 7:
  {
   ShowPlayerDialog(playerid, 7, DIALOG_STYLE_MSGBOX, "Sellhouse", "Are you sure you want to sell your house to the market for $(amount)?", "Confirm", "Cancel");
  }
 }
}
return 0;

if(dialogid==3 && response==1)
{
 switch(listitem)
 {
  case 0:
  {
   ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Deposit", "How much money would you like to deposit into your safe?", "Proceed", "Cancel");
  }
  case 1:
  {
   ShowPlayerDialog(playerid, 9, DIALOG_STYLE_INPUT, "Deposit", "How much materials would you like to deposit into your safe?", "Proceed", "Cancel");
  }
  case 2:
  {
   ShowPlayerDialog(playerid, 10, DIALOG_STYLE_INPUT, "Deposit", "How much crack would you like to deposit into your safe?", "Proceed", "Cancel");
  }
  case 3:
  {
   ShowPlayerDialog(playerid, 11, DIALOG_STYLE_INPUT, "Deposit", "How much pot would you like to deposit into your safe?", "Proceed", "Cancel");
  }
  case 4:
  {
   ShowPlayerDialog(playerid, 12, DIALOG_STYLE_INPUT, "Deposit", "Which weapon would you like to deposit into your safe?", "Proceed", "Cancel");
  }
 }
}
return 0;

if(dialogid==4 && response==1)
{
 switch(listitem)
 {
  case 0:
  {
   ShowPlayerDialog(playerid, 13, DIALOG_STYLE_INPUT, "Withdraw", "How much money would you like to withdraw from your safe?", "Proceed", "Cancel");
  }
  case 1:
  {
   ShowPlayerDialog(playerid, 14, DIALOG_STYLE_INPUT, "Withdraw", "How much materials would you like to withdraw from your safe?", "Proceed", "Cancel");
  }
  case 2:
  {
   ShowPlayerDialog(playerid, 15, DIALOG_STYLE_INPUT, "Withdraw", "How much crack would you like to withdraw from your safe?", "Proceed", "Cancel");
  }
  case 3:
  {
   ShowPlayerDialog(playerid, 16, DIALOG_STYLE_INPUT, "Withdraw", "How much pot would you like to withdraw into from safe?", "Proceed", "Cancel");
  }
  case 4:
  {
   ShowPlayerDialog(playerid, 17, DIALOG_STYLE_INPUT, "Withdraw", "Which weapon would you like to withdraw into from safe?", "Proceed", "Cancel");
  }
 }
}
return 0;

if(dialogid==5 && response==1)
 {
  switch(listitem)
  {
   case 0:
   SendClientMessage(playerid, COLOR_BLUE, "Your new house tag has been set!");
  }
 }
return 1;   
}

Featured Replies

Er staat 3x dit in

return 0;

Haal dat weg. Dan werkt het. Wel de

return 1;

laten staan

Even een toelichting: de warning 'Unreachable code' duidt erop dat een bepaald stuk code nooit kan worden uitgevoerd (het is dus onbereikbaar ofwel unreachable). Dit wordt veroorzaakt door return-statements. Daarbij maakt het voor deze melding niet uit wat je returnt, het kan ook gewoon return; zijn (voor het effect op de functie maakt het soms wel uit). Een return-statement zorgt er namelijk voor dat je de functie stopt en een waarde retourneert naar datgene wat de functie heeft opgeroepen, zodat dat stuk code weet of de functie succesvol is doorlopen of niet (handig voor als je zelf een functie maakt). Hopelijk snap je hiermee ook waarom het fout gaat en waarom je dialog boxen niet verschijnen. ;)

  • Author

Resolved, een moderator kan dit sluiten. Bedankt voor jullie hulp!

@VWO-er: Het is me helemaal duidelijk gemaakt, bedankt!

>>> Door VWO-er: Dicht hoeft niet, het topic zakt vanzelf wel weg. En graag gedaan! ;)<<<

Edited by VWO-er

  • Author

Trouwens vraagje, is het mogelijk om de antwoord van een ander dialoog te pakken? Ik kan namelijk met "inputtext" de antwoord van mijn vorige dialoog achterhalen, maar is er ook een manier dat ik het antwoord van een dialoog daarvoor kan ontvangen?

is mogelijk als je de inputtext van het 1e dialog onthoud in een variable.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.