CreateDynamicPolygon (Streamer Function)
#1

Hey guys,

I've been having this problem for a little while and I've tried to understand it, but it just confuses me. I know I should be good with all these shape things seeing as we did a huge section of them in maths the whole year last year, but I can't seem to figure out the function CreateDynamicPolygon from Incognito's streamer plugin. I am just having trouble with the coordinates bit. So here's what I have so far:

As you can see, the green part is what I am currently using as an area under OnPlayerEnterDynamicArea, which is of course being created as CreateDynamicRectangle. However, I would like to add the red part into the equation, and I know the only way to do that, is by using CreateDynamicPolygon (AFAIK). Now what I would LIKE it to be, is something like this:


As you can see, there are 5 points, and I want each of them to form to become one shape, a polygon in this instance. The coordinates of each point are as follows, they are numbered in the image to help you understand. (There is no need for a Z coordinate in the function CreateDynamicPolygon, because I have already set that.)

Point 1 = 2305.5264, 1783.7133
Point 2 = 2305.5264, 1882.6989
Point 3 = 2167.5994, 1882.6989
Point 4 = 2167.5994, 1859.0988
Point 5 = 2128.2075, 1783.7133

If anyone has any examples that I might be able to follow, it would be greatly appreciated. The red dots mark the points/vertices etc. that I would like to be used in the CreateDynamicPolygon function. It just confuses me a little, because I'm not sure how to create the polygon at all of these points. If anyone has any alternative suggestions that might make it a bit easier for me, it would also be appreciated. It's not very accurate when detecting whether a player has entered the area or not, because I haven't included that small triangular area. Players can enter the area a fair bit, before they are teleported out, because they are entering through that small area. If anyone knows how to use CreateDynamicPolygon, please help me

I've searched for tutorials for ages, the explanation in the streamer thread explains some of it too me, but I feel like it's not enough.

Code:
native CreateDynamicPolygon(Float:points[], Float:minz = -FLOAT_INFINITY, Float:maxz = FLOAT_INFINITY, maxpoints = sizeof points, worldid = -1, interiorid = -1, playerid = -1);
Quote:
Originally Posted by Incognito
For CreateDynamicPolygon and CreateDynamicPolygonEx, the points need to be specified as a sequence of ordered pairs (x1, y1, x2, y2, ..., xn, yn). The number of elements in the array must be divisible by two for this reason. The first point must also be equal to the last point to form a closed path.
Thanks again,
BenzoAMG.
Reply
#2

Sorry for the late reply, but my power got shut off from a storm for 2 days about 2 minutes after posting this. Within that time, I did manage to actually solve this problem before I could reply to this topic again. I did a bit more reading of my topic and did discover I had actually ignored this part...
Quote:
Originally Posted by Incognito
...ordered pairs (x1, y1, x2, y2, ..., xn, yn)...
So in fact, the solution to my problem was in fact:
pawn Code:
new Float:Points[12] =
    {2305.5264, 1783.7133, 2305.5264, 1882.6989, 2167.5994, 1882.6989, 2167.5994, 1859.0988, 2128.2075, 1783.7133, 2305.5264, 1783.7133};
    AdminHQArea = CreateDynamicPolygon(Points, 5.0, 15.0, sizeof(Points));
Thanks anyway guys

and 500th Post!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)