question about an array
#1

So i have this array,
pawn Код:
new gangDB[MAX_GANGS][giitem];
and for reason when loading i want it to not load into the 0th slot. Is it possible too skip it? I'm using a for loop to load stuff into it and just couldn't think of a way.
pawn Код:
new rows,fields;
    cache_get_data(rows,fields);
    for(new i; i<rows; i++)
    {
        new tmp[64];
        cache_get_row(i,0,tmp,dbHandler); gangDB[i][gid]=strval(tmp);
        cache_get_row(i,1,tmp,dbHandler); format(gangDB[i][Leader],sizeof(tmp),tmp);
         }
Reply
#2

Thats all well, but won't it then start from the 1st line of data? and skip the 0th?
Reply
#3

If you set the variable to 1 it's going to start the loop with i equaling 1. So, yes, 0 is skipped.
Reply
#4

Wait, you mean like
pawn Код:
gangDB[i][gid]
to
pawn Код:
gangDB[i+1][gid]
?
Reply
#5

You are declaring i and the default value is 0.

pawn Код:
for(new i; i<rows; i++)
If you want i to equal 1 and skip 0, then you have to set it to 1.

pawn Код:
for(new i = 1; i<rows; i++)
Reply
#6

thats the thing i don't want to skip it,kind of, i want it to start putting into an array like gangDB[1][gid], but i want the 0th line from my DB
Reply
#7

Because my brain decided that it will fail on the second try...which doesn't matter now,because everything is working fine! I thank you all, and invite you to look at my other problems.

http://forum.sa-mp.com/showthread.ph...51#post2504051
https://sampforum.blast.hk/showthread.php?tid=429376&page=3
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)