Something wrong?
#1

I just wanna' know if you can use else under OnDialogResponse, like this:

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_CHOOSE)
    {
        if(response)
        {
            if(listitem == 0)
            {
                ClassInfo[playerid][Normal] = 1;
                SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Jucator {15FF00} in echipa Romaniei !");
            }
            if(listitem == 1)
            {
                if(ClassInfo[playerid][Experienta] >= 10)
                {
                    ClassInfo[playerid][Normal] = 1;
                    SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FFCC33}Sniper {15FF00} in echipa Romaniei !");
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
            }
            if(listitem == 2)
            {
                if(ClassInfo[playerid][Experienta] >= 15)
                {
                    ClassInfo[playerid][Assault] = 1;
                    SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Assault {15FF00} in echipa Romaniei !");
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
                if(listitem == 3)
                {
                    if(ClassInfo[playerid][Experienta] >= 30)
                    {
                        ClassInfo[playerid][Killer] = 1;
                        SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}KILLER {15FF00} in echipa Romaniei !");
                    }
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
                if(listitem == 4)
                {
                    if(ClassInfo[playerid][VIPP] >= 1)
                    {
                        ClassInfo[playerid][Killer] = 1;
                        SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}VIP {15FF00} in echipa Romaniei !");
                    }
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
                if(listitem == 5)
                {
                    if(ClassInfo[playerid][Donator] >= 1)
                    {
                        ClassInfo[playerid][Killer] = 1;
                        SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Donator {15FF00} in echipa Romaniei !");
                    }
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
            }
        }
    }
    return 1;
}
Will work, if player doesn't have 10, 15, 30 experience, will get message from else?
Reply
#2

I don't think it will work like that.
Why don't you add the ELSE statement under the IF statement? (And I mean the ones under listitem)

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_CHOOSE)
    {
        if(response)
        {
            if(listitem == 0)
            {
                ClassInfo[playerid][Normal] = 1;
                SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Jucator {15FF00} in echipa Romaniei !");
            }
            if(listitem == 1)
            {
                if(ClassInfo[playerid][Experienta] >= 10)
                {
                    ClassInfo[playerid][Normal] = 1;
                    SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FFCC33}Sniper {15FF00} in echipa Romaniei !");
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
            }
            if(listitem == 2)
            {
                if(ClassInfo[playerid][Experienta] >= 15)
                {
                    ClassInfo[playerid][Assault] = 1;
                    SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Assault {15FF00} in echipa Romaniei !");
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
            }
            if(listitem == 3)
            {
                if(ClassInfo[playerid][Experienta] >= 30)
                {
                    ClassInfo[playerid][Killer] = 1;
                    SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}KILLER {15FF00} in echipa Romaniei !");
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
            }
            if(listitem == 4)
            {
                if(ClassInfo[playerid][VIPP] >= 1)
                {
                    ClassInfo[playerid][Killer] = 1;
                    SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}VIP {15FF00} in echipa Romaniei !");
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
            }
            if(listitem == 5)
            {
                if(ClassInfo[playerid][Donator] >= 1)
                {
                    ClassInfo[playerid][Killer] = 1;
                    SendClientMessage(playerid, -1, "{FFCC33}COD: {15FF00}Ti-ai ales cu succes rank-ul de {FF0000}Donator {15FF00} in echipa Romaniei !");
                }
                else
                {
                     SendClientMessage(playerid, -1, "{FFCC33}Ne pare rau. Nu ai experienta necesara !");
                }
            }
        }
    }
    return 0;
}
Don't forget to return 0 in the OnDialogResponse function.
Reply
#3

Why would you do if(listitem == 2) and check under it for more listitems? If the listitem is 2, it don't have to check for i.e. listitem 3 under it.
Reply
#4

Use a switch, it's a much cleaner (and faster) solution.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)