[Pawn] Center of GangZoneCreate() - Printable Version + open.mp forum (https://forum.open.mp) -- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3) --- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10) --- Thread: [Pawn] Center of GangZoneCreate() (/showthread.php?tid=2474) |
Center of GangZoneCreate() - JR_Junior - 2023-10-22 Hello! Could anyone help me get the exact coordinates of the center of a Gang Zone automatically? PHP Code: new Float:minx = 1248.011; RE: Center of GangZoneCreate() - denNorske - 2023-10-23 In order to get the center coordinates, you need to know what you already have. You have the two edges in both X and Y direction (Min and Max values). The center will just be the following: PHP Code: new Float:centerx = (minx + maxx) / 2.0; That will result as PHP Code: centerx = 1343.679 RE: Center of GangZoneCreate() - JR_Junior - 2023-10-23 (2023-10-23, 05:44 AM)denNorske Wrote: In order to get the center coordinates, you need to know what you already have. You have the two edges in both X and Y direction (Min and Max values). Worked perfectly! Thanks! PHP Code: stock GetZoneCenterPos(Float:minx,Float:miny,Float:maxx,Float:maxy,&Float:centerx,&Float:centery) RE: Center of GangZoneCreate() - denNorske - 2023-10-26 Glad to hear! A neat approach would be to perhaps store the data into a ZoneData enum, and instead of using GangZoneCreate, you use a new function called CreateZone; PHP Code: #define MAX_GANG_ZONES 100 //adjust as necessary Then you can create the zones without having to worry about getting the zone coordinates every time you want to get the center of it. Instead you can do something like: PHP Code: forward GetZoneCenterXY(zoneid, &Float:center_x, &Float:center_y) And then you can use it like this (for example) PHP Code: new Float:x, Float:y; |