Making a dialog with an input switch
#1

I've tried using this (the dialog works fine):
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 1)
  {
    switch(inputtext)
    {
      case "TDM":
      {
        SendClientMessage(playerid, COLOR_WHITE, "You picked Team Deathmatch.");
      }
      case "FFA":
      {
        SendClientMessage(playerid, COLOR_WHITE, "You picked Free For All.");
      }
      case "RP":
      {
        SendClientMessage(playerid, COLOR_WHITE, "You picked Roleplay.");
      }
    }
  }
  return 0;
}
But I get these errors:
Quote:

C:\Users\James\Desktop\SAMP\gamemodes\DM.pwn(227) : error 033: array must be indexed (variable "-unknown-")
C:\Users\James\Desktop\SAMP\gamemodes\DM.pwn(229) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\James\Desktop\SAMP\gamemodes\DM.pwn(233) : error 001: expected token: "-string end-", but found "-identifier-"
C:\Users\James\Desktop\SAMP\gamemodes\DM.pwn(237) : error 001: expected token: "-string end-", but found "-identifier-"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Reply
#2

You can't use case with strings.
Reply
#3

Can't I? You can in Java, so I assumed you can here.
An if statement gives the same error.
Reply
#4

Pawn is not Java. Most likely you used if statement in switch(inputtext)

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(dialogid == 1)
  {
    if(!strcmp(inputtext, "TDM", true)) {
       SendClientMessage(playerid, COLOR_WHITE, "You picked Team Deathmatch.");
    }
    else if(!strcmp(inputtext, "FFA", true)) {
       SendClientMessage(playerid, COLOR_WHITE, "You picked Free for all.");
    }
    else if(!strcmp(inputtext, "RP", true)) {
       SendClientMessage(playerid, COLOR_WHITE, "You picked Roleplay.");
    }
  }
  return 0;
}
Reply
#5

Ah, thanks, I'm a fool xD
Reply
#6

Quote:
Originally Posted by jameskmonger
Ah, thanks, I'm a fool xD
Lol, don't call yourself a fool, I guess you're new, you're just learning.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)