SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 10/12/2018, 06:49 AM   #1
Altus
Little Clucker
 
Join Date: Oct 2017
Posts: 5
Reputation: 0
Default Polygonal Boundaries

Description
This include allows you to create polygonal boundaries on your server. They work just like the default boundaries (which are set with SetPlayerWorldBounds), but their shape can be an arbitrary polygon. It can be pretty useful to make custom restricted maps.

How to use
You should follow these simple steps to start using the polygonal boundaries:
  1. Include the file to your gamemode/filterscript;
  2. Open the include and change two macroconstants located at the third and the fourth line:
    • B_MAXLENGTH is the maximum number of vertices in your polygonal boundaries;
    • B_NUMBER is the maximum amount of different polygonal boundaries which can be used in your script;
  3. Call InitBoundaries() in the OnFilterScriptInit/OrGameModeInit callback:
    Code:
    public OnFilterScriptInit() {
    	InitBoundaries();
    	...
    }
  4. Call ProcessBoundaries(playerid) in the OnPlayerUpdate(playerid) callback:
    Code:
    public OnPlayerUpdate(playerid) {
    	ProcessBoundaries(playerid);
    	...
    }
  5. Create your boundaries using CreateBoundaries(Float: array[], points).
    The first argument, array, is an array of vertices of your polygon. It should be filled according to the following format: { x1, y1, x2, y2, ..., xn, yn }.
    The second argument, points, is the number of the vertices (n).
    The function returns the ID of the polygonal boundaries which should be used later with the AssignBoundaries function or B_NONE if you tried to create more than B_NUMBER boundaries.
    Example. Say, you want to make El Quebrados the only accessible location and you saved the coordinates of the vertices (image).

    So, CreateBoundaries should be called this way:
    Code:
    new Float: ElQuebradosBoundaries[12] = { -1550.0, 2672.0, -1549.0, 2551.0, -1496.0, 2549.0, -1490.0, 2595.0, -1416.0, 2597.0, -1420.0, 2669.0 };
    new ElQuebradosBoundariesID = CreateBoundaries(ElQuebradosBoundaries, 12);
    (those coordinates are rough, please, don't use them in your scripts )
  6. Set the boundaries for players with AssignBoundaries(playerid, boundaries_id). playerid is the ID of a player, boundaries_id is the value returned by CreateBoundaries. To set a player free from the boundaries, use RemoveBoundaries(playerid).

Notes
  • Keep it mind that the boundaries work in all the interiors and virtual worlds
  • The bugs which can be used to bypass the default boundaries, do not work with these ones
  • Hasn't been properly tested with self-intersecting or too small polygons
  • The planes do not normally stall after hitting the boundaries, but are reflected without losing momentum with the same angle they hit the boundaries (which can lead to stalling in some cases, though)

Afterword
All credits go to yours truly Altus, as known as Altus_Demens. I will be glad if someone finds this code useful.

Source code
Download

Last edited by Altus; 10/12/2018 at 04:44 PM.
Altus is offline   Reply With Quote
Old 10/12/2018, 04:46 PM   #2
Altus
Little Clucker
 
Join Date: Oct 2017
Posts: 5
Reputation: 0
Default Re: Polygonal Boundaries

******, thank you!
You are right, it is my mistake. I use the polygonal boundaries as a separate filterscript, but I decided to assemble it as an include to post it here. Corrected.
Altus is offline   Reply With Quote
Old 10/12/2018, 05:00 PM   #3
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,750
Reputation: 836
Default Re: Polygonal Boundaries

Why not hook OnPlayerUpdate?

https://forum.sa-mp.com/showthread.php?t=574534
__________________

Follow me on Github: Follow me on Spotify: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 10/12/2018, 10:28 PM   #4
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,855
Reputation: 1291
Default Re: Polygonal Boundaries

How about adding streamer support? Then you don't need timers.
Pottus is offline   Reply With Quote
Old 10/12/2018, 10:37 PM   #5
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,750
Reputation: 836
Default Re: Polygonal Boundaries

Quote:
Originally Posted by Pottus View Post
How about adding streamer support? Then you don't need timers.
Streamer already have "CreateDynamicPolygon", so what would be left for him to do, all his include will be, showing and hiding textdraw under streamer's OnPlayerEnter/LeaveDynamicArea callback.
__________________

Follow me on Github: Follow me on Spotify: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 10/12/2018, 10:49 PM   #6
Pottus
High-roller
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 4,855
Reputation: 1291
Default Re: Polygonal Boundaries

Quote:
Originally Posted by Gammix View Post
Streamer already have "CreateDynamicPolygon", so what would be left for him to do, all his include will be, showing and hiding textdraw under streamer's OnPlayerEnter/LeaveDynamicArea callback.
Pretty much, unless you don't want to use the streamer but who these days does not the streamer? It's pretty standard.
Pottus is offline   Reply With Quote
Old 11/12/2018, 05:20 AM   #7
Dudoso
Little Clucker
 
Join Date: Apr 2010
Posts: 3
Reputation: 0
Cool Re: Polygonal Boundaries

Thanks dude, awesome.

EPS value?



Dudoso is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stay within' Boundaries! CameronThomaz Server Support 3 25/12/2014 05:21 AM
SA-MP map boundaries? Yasahiro General 2 04/06/2013 12:25 AM
[FilterScript] Polygonal area Seregamil1 Filterscripts 2 13/05/2013 10:42 AM
Help with world boundaries LiamM Help Archive 3 30/01/2011 04:25 PM
Boundaries bug Pooh7 Bug Reports 10 20/01/2011 02:21 PM


All times are GMT. The time now is 12:23 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.