SA-MP Forums Archive
IsInRangeofDynamicArea - 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: IsInRangeofDynamicArea (/showthread.php?tid=656752)



IsInRangeofDynamicArea - Stefand - 23.07.2018

Hello,

Does anyone know if there is a IsInRangeofDynamicArea function? I cant seem to find anything..

It would check if a point/person is in range of a dynamic area with a specified range.


Re: IsInRangeofDynamicArea - Calisthenics - 23.07.2018

https://github.com/samp-incognito/sa...atives-(Areas)

IsPlayerInDynamicArea function.


Re: IsInRangeofDynamicArea - Stefand - 25.07.2018

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Im looking for a function to check if a point is in range, not a player

I made
Код:
stock GetClosestStreetEx(Float:X, Float:Y, Float:Z, Float:range)
{
    new
        Float:distance = range,
        Float:curdistance,
		closestStreet = -1;

    for(new s=1; s <= loadedStreets; s++){
        Streamer_GetDistanceToItem(X, Y, Z, 6, Street[s][streetArea], curdistance, 2);
		printf("%f, %f", curdistance, range);
        if(curdistance < distance)
        {
            closestStreet = s;
            distance = curdistance;
        }

    }
    return closestStreet;
}
But its not working properly, when standing ON the area (tested with on leave and enter area publics), it says im too far away while I am literally on it.


Re: IsInRangeofDynamicArea - NaS - 25.07.2018

IsPointInDynamicArea should do what you are looking for. It checks if a point is in a dynamic area. To get the distance you can simply use Streamer_GetFloatData for X, Y and Z coord and calculate the distance to the point using VectorSize or floatsqroot (only needed if the point is actually in the area).

Furthermore, shouldn't the loop start at index 0 and end at loadedStreets - 1 ? Just asking as you directly access the array which doesn't start at index 1, unless you did this intentionally for some reason.


Re: IsInRangeofDynamicArea - Stefand - 25.07.2018

Done that for a reason yeah.

Anyway the point is not in the area, i want to use this for street adresses for houses to see what street is closest. But it doesnt calculate the distance properly.


Re: IsInRangeofDynamicArea - 0x88 - 25.07.2018

Quote:
Originally Posted by Stefand
Посмотреть сообщение
Done that for a reason yeah.

Anyway the point is not in the area, i want to use this for street adresses for houses to see what street is closest. But it doesnt calculate the distance properly.
i do suggest u to use gangzone functions make the street system thats what im using on current gamemode, its way better and more simple


Re: IsInRangeofDynamicArea - NaS - 25.07.2018

Quote:
Originally Posted by Stefand
Посмотреть сообщение
Done that for a reason yeah.

Anyway the point is not in the area, i want to use this for street adresses for houses to see what street is closest. But it doesnt calculate the distance properly.
Oh okay, I misunderstood.

What distance does it give you? You could compare it by getting the Area's center position (using Streamer_GetFloatData) and calculate it manually. Just to see if the values match.