SA-MP Forums Archive
Variable to start from 1? - 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: Variable to start from 1? (/showthread.php?tid=664291)



Variable to start from 1? - masuzaron - 24.02.2019

PHP код:
new MafiaRank[][SomeInfo] =

  { 
blablablablablabla }, // MafiaRank[0][SomeInfo]
  
blablablablablabla }, // MafiaRank[1][SomeInfo]
  
blablablablablabla }, // ...
  
blablablablablabla }, // ...
  
blablablablablabla // ...
}; 
Is there any way to make this variable to start with MafiaRank[1][SomeInfo] insted of MafiaRank[0][SomeInfo] ??


Re: Variable to start from 1? - Banditul18 - 24.02.2019

No. This how arrays work. But you can introduce dummy info in the index 0 and use it from 1


Re: Variable to start from 1? - masuzaron - 24.02.2019

Okay, and how to change loop than to skip that dummy field?
PHP код:
for(0sizeof(MafiaRank); i++) 



Re: Variable to start from 1? - Banditul18 - 24.02.2019

Start i from 1 not 0


Re: Variable to start from 1? - TheToretto - 24.02.2019

pawn Код:
for(i = 0; i < sizeof(MafiaRank); i++)  
{
    if(MafiaRank[i] == 0) continue;
}



Re: Variable to start from 1? - masuzaron - 24.02.2019

Thee is another problem, when I loop through all ranks, and skip this dummy and add other ranks in the dialog list, dialog starts from case 0: I need it to start from case 1: too, any suggestions?


Re: Variable to start from 1? - TheToretto - 24.02.2019

Why do you need it for that too..? If you insist the only way to do it is to create an empty listitem, then it would count as 0.


Re: Variable to start from 1? - Pottus - 24.02.2019

This is why you use #define.....

#define MAFIA_RANK_1 0
#define MAFIA_RANK_2 1

etc


Re: Variable to start from 1? - TheToretto - 24.02.2019

Quote:
Originally Posted by TheToretto
Посмотреть сообщение
Why do you need it for that too..? If you insist the only way to do it is to create an empty listitem, then it would count as 0.
My bad, I thought you were asking about listitem parameter OnDialogResponse, either use #define as Pottus said, or use an enum.

Код:
enum
{
    MAFIA_RANK_1 = 1,
    MAFIA_RANK_2,
    MAFIA_RANK_3
}
Rank 2 will get value 2, 3 : 3 etc.


Re: Variable to start from 1? - coool - 24.02.2019

Код:
listitem++;
? Just above the code where you want to start lisitems from 1... Am I right?