Creating a case? +rep
#1

So on my register system you can choose your age in a dialog (I.E. - (18\n19\n20\n21) etc..

But instead of doing if(listitem == 0) or whatever for all the number, is there a way I can do like

if(response)
AgeReturn(playerid);

or something then

AgeReturn(playerid)
{
case: 18, 19, 20
}

or whatever, idk, never done cases before, but something like that so it fetches the number in order?

+rep thank you
Reply
#2

PHP код:
switch(listitem)
{
    case 
0://This means if listitem = 0. It's the same as doing if(listitem) == 0)
       
{
       
//If he is 18 years old.
    
}
    case 
1:
    {
        
SendClientMessage(playerid, -1"You are 19 years old!");
    }
}
//So on... 
Reply
#3

Either way it would end up taking up hundreds of lines since ages range from 18 to like 90, so couldnt I do it like a function that isn't under the dialogresponse if it makes sense, look what I wrote at the top
Reply
#4

There are two easy ways
pawn Код:
//
    if(response) {
        new
            age1 = strval(inputtext), // inputtext stores the selected line text
            age2 = listitem + 18 // this will work if the list goes on without a gap
        ;
    }
Reply
#5

pawn Код:
Age_Return(playerid) {

    new
        szName[3] = "18";

    switch(PlayerInfo[playerid][pAge]) {
        case 0: szName = "18";
        case 1: szName = "19";
        case 2: szName = "20";
        case 3: szName = "21";
        case 4: szName = "22";
        case 5: szName = "23";
        case 6: szName = "24";
        case 7: szName = "25";
    }
    return szName;
}
I just made this, although when I choose 19 on my dialog it will say im 49..?
Reply
#6

Anyone going to help me?
****** I have no idea where to find that document
Reply
#7

Download it from here
https://sampforum.blast.hk/showthread.php?tid=289258
Reply
#8

Anyone got a fix for the age thing I posted? How it always says im 49
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)