Creating a case? +rep - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Creating a case? +rep (
/showthread.php?tid=387642)
Creating a case? +rep -
RLGaming - 25.10.2012
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
Re: Creating a case? +rep -
gtakillerIV - 25.10.2012
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...
Re: Creating a case? +rep -
RLGaming - 25.10.2012
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
AW: Creating a case? +rep -
Nero_3D - 25.10.2012
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
;
}
Re: Creating a case? +rep -
RLGaming - 25.10.2012
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..?
Re: Creating a case? +rep -
RLGaming - 25.10.2012
Anyone going to help me?
****** I have no idea where to find that document
Re: Creating a case? +rep -
Mr.Anonymous - 25.10.2012
Download it from here
https://sampforum.blast.hk/showthread.php?tid=289258
Re: Creating a case? +rep -
RLGaming - 25.10.2012
Anyone got a fix for the age thing I posted? How it always says im 49