Variable to start from 1?
#1

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] ??
Reply
#2

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

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

Start i from 1 not 0
Reply
#5

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

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?
Reply
#7

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.
Reply
#8

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

#define MAFIA_RANK_1 0
#define MAFIA_RANK_2 1

etc
Reply
#9

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.
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)