Selecting float values from an array, making a CP, if in gang-zone
#1

Basically, I'm trying to make it so that when a gang-zone is created, it also goes through this array to determine if any of the points are in the gang-zone. If they are, it's supposed to make a dynamic check-point at the location (that's specified in the array).

I can't figure out how to do this, though. Can anyone with some experience in arrays shed a bit of light?

This is basically what I have so far, the array is actually much larger, but for the sake of not posting a ton of crap, I shortened it...

pawn Код:
static const trashArray[]
{
    {2657.1614,716.5063,10.8203},
    {2616.2979,716.4762,10.8203},
    {2578.0164,723.9280,10.8203},
    {2537.3118,716.3985,10.8203},
    {2879.6377,944.9102,10.7500},
    {2863.4600,945.1839,10.7500},
    {2765.0286,1436.8666,10.5908},
    {2761.7808,1443.0544,10.7605}
};

for(new z = 0; z < sizeof(trashArray); z++)
{
    if(IsPointInGangZone(trashArray[z][0], trashArray[z][1], gSAZones[i][SAZONE_AREA][0], gSAZones[i][SAZONE_AREA][1], gSAZones[i][SAZONE_AREA][3], gSAZones[i][SAZONE_AREA][4]))
    {
        CreateDynamicCP(trashArray[z][0], trashArray[z][1], trashArray[z][2], 1.0);
    }
    else printf("%f, %f, %f -- NOT FOUND IN ZONE", trashArray[z][0], trashArray[z][1], trashArray[z][2]);
}

stock IsPointInGangZone(Float:fPosX, Float:fPosY, Float:minx, Float:maxx, Float:miny, Float:maxy)
{
    if( fPosX >= minx && fPosX <= maxx && fPosY >= miny && fPosY <= maxy ) return 1;
    return 0;
}
Reply
#2

Firstly your definition of the array is incorrect. You need to make it hold floats and make it multidimensional:
pawn Код:
static const Float:trashArray[][] =
{
    {2657.1614,716.5063,10.8203},
    {2616.2979,716.4762,10.8203},
    {2578.0164,723.9280,10.8203},
    {2537.3118,716.3985,10.8203},
    {2879.6377,944.9102,10.7500},
    {2863.4600,945.1839,10.7500},
    {2765.0286,1436.8666,10.5908},
    {2761.7808,1443.0544,10.7605}
};
Reply
#3

Ah, such a simple fix. It's compiling now.

Other than that, it should work fine, right?
Reply
#4

whats the point of const static? ur not gonna change them? anyways.. just for fun?

ye it should work now
Reply
#5

Quote:
Originally Posted by mastermax7777
Посмотреть сообщение
whats the point of const static? ur not gonna change them? anyways.. just for fun?

ye it should work now
The compiler was bitching at me about NOT having it. However, adding the "Float:" seems to have shut the compiler up and I can use "new" again.
Reply
#6

Actually you should use "static const" in this case - unless you are planning on using the array in another file or are going to change the values at run time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)