Loading/Using multiple values
#1

I have this code;
pawn Код:
enum aaaa
{
    Float:test[3]
}
new tesst[][aaaa];

for(new i = 0; i < PicksCount; i++)
        {
            format(Pickstr[0], 128, "map/racepickup[%d]/@type", i);
            format(Pickstr[1], 128, "map/racepickup[%d]/@posX", i);
            format(Pickstr[2], 128, "map/racepickup[%d]/@posY", i);
            format(Pickstr[3], 128, "map/racepickup[%d]/@posZ", i);
            for(new a = 0; a < sizeof(tesst[]); a++)
            {
                tesst[a][test][0] = xml_get_float(MAP, Pickstr[1]);
                tesst[a][test][1] = xml_get_float(MAP, Pickstr[2]);
                tesst[a][test][2] = xml_get_float(MAP, Pickstr[3]);
//              printf("%0.4f, %0.4f, %0.4f", tesst[a][test][0], tesst[a][test][1], tesst[a][test][2]);
All values from xml_get_float are saved into tesst[a][test][0/1/2] variables perfectly(around 60 values). But when I wanted to use the variables;

pawn Код:
public PickUps() //SetTimer
{
    for(new a = 0; a < sizeof(PickAmount); a++)
    {
//        printf("%0.4f, %0.4f, %0.4f", tesst[a][test][0], tesst[a][test][1], tesst[a][test][2]);
    }
    return 1;
}
It only loads 1 value instead of 60~.
Reply
#2

Just shooting in the wild here but don't you need to start at 0?
pawn Код:
tesst[a][test][0] = xml_get_float(MAP, Pickstr[0]);
tesst[a][test][1] = xml_get_float(MAP, Pickstr[1]);
tesst[a][test][2] = xml_get_float(MAP, Pickstr[2]);
Reply
#3

I'm saving a float, not integer.
pawn Код:
format(Pickstr[0], 128, "map/racepickup[%d]/@type", i); //integer
            format(Pickstr[1], 128, "map/racepickup[%d]/@posX", i); //float
            format(Pickstr[2], 128, "map/racepickup[%d]/@posY", i); //float
            format(Pickstr[3], 128, "map/racepickup[%d]/@posZ", i); //float
Reply
#4

Wow, I am either really tired, or it is incredibly difficult to make sense of your arbitrary test naming/snippets lol. First thing is first, why is tesst's first dimension's size not set? I've generally only seen this when you are explicitly assigning something to it/filling it in...for example:

Код:
new test[][aaaa] = {{1.0,2.0,3.0}, {2.0,3.0,4.0}};  //Might not be 100% valid...haven't touched pawn in like 3 years...
Second, what does "sizeof(tesst[])" print out? 1? I believe all your problems are rooted from you not declaring that first dimension's size (Could have created a constant like MAX_TESST for that, and used that constant instead of sizeof(PickAmount) and sizeof(tesst[]) too...making it a bit nicer).

Anyways, the reason it probably looks like everything is "saving" into tesst is because of the first loop... it formats all the dimensions of "Pickstr" fine, and then you basically start a loop (which i suspect goes 1 time), assign the float data to the tesst array/print it out, and basically over write the tesst array with the next iteration of the first loop (i) and repeat the process.
Reply
#5

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
Wow, I am either really tired, or it is incredibly difficult to make sense of your arbitrary test naming/snippets lol. First thing is first, why is tesst's first dimension's size not set? I've generally only seen this when you are explicitly assigning something to it/filling it in...for example:

Код:
new test[][aaaa] = {{1.0,2.0,3.0}, {2.0,3.0,4.0}};  //Might not be 100% valid...haven't touched pawn in like 3 years...
Well... as far as I know, if we didn't know the first dimension's size, we can leave it empty so PAWN can fill them later(for example, in looping).

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
Second, what does "sizeof(tesst[])" print out? 1? I believe all your problems are rooted from you not declaring that first dimension's size (Could have created a constant like MAX_TESST for that, and used that constant instead of sizeof(PickAmount) and sizeof(tesst[]) too...making it a bit nicer).
It prints out;
Код:
0
1
2
3
4
5
0
1
2
3
4
5
0
1
2
3
4
5
and so on ...
That's weird.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)