Little Maths to pawn question... - 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: Little Maths to pawn question... (
/showthread.php?tid=291861)
Little Maths to pawn question... -
knackworst - 21.10.2011
Hi, I got a little question...
what maths thing do I need to make that per 3 listitems of one dialog represents one index?
so like this:
pawn Код:
if(dialogid == 3290)
{
new index;
if(!response) return 1;
switch(listitem)
{
case 0: index = 1
case 1: index = 1
case 2: index = 1
case 3: index = 2
case 4: index = 2
case 5: index = 2
case 6: index = 3
case 7: index = 3
}
but then in one simple line that I do not need to use all this cases...
thanks in advance
plus rep for helper
Re: Little Maths to pawn question... -
AeroBlast - 21.10.2011
pawn Код:
if(dialogid == 3290)
{
new index;
if(!response) return 1;
switch(listitem)
{
case 0 .. 2: index = 1
case 3 .. 5: index = 2
case 6 .. 7: index = 3
}
}
You mean this?
Re: Little Maths to pawn question... -
Joe Staff - 21.10.2011
Well according to the pattern there, you've got it so listitems are sorted in indexes of 3. e.g. 0-2 = 1, 3-5 = 2, etc.
So an easier way to get that would be to simply divide the listitem number by 3 then add 1.
pawn Код:
new index = (listitem/3)+1;
Now if you wanted to know which of the 3 the listitem is, you would use this
pawn Код:
new slot = (listitem%3)+1;
This would tell you if it's the first, second, or third of that same index. e.g.
pawn Код:
listitem = 75;
new index = (listitem/3)+1// (25+1) = 26
new slot = (listitem%3)+1// (0+1) = 1
so 75 is the first of index 26
Re: Little Maths to pawn question... -
knackworst - 21.10.2011
Wow thats very usefull thanks!
But what woes the percent symbol stand for in this case? For mercent?