IsInRangeofDynamicArea
#1

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

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

IsPlayerInDynamicArea function.
Reply
#3

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)