• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Center of GangZoneCreate()
#4
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

enum gangZoneProperties
{
    Float:center_x,
    Float:center_y,
    Float:min_x,
    Float:min_y,
    Float:max_x,
    Float:max_y,
    Float:min_z,
    Float:max_z,
    name[35]
};

new 
zoneData[MAX_GANG_ZONES][gangZoneProperties];

forward GetZoneName(zoneid);
forward CreateZone(Float:minxFloat:minyFloat:maxxFloat:maxyFloat:minz 0.0Float:maxz 0.0);

public 
CreateZone(const name[], Float:minxFloat:minyFloat:maxxFloat:maxyFloat:minz 0.0Float:maxz 0.0)
{
    new zoneid GangZoneCreate(minxminymaxxmaxy);
    
    
if (zoneid != INVALID_GANG_ZONE && zoneid MAX_GANG_ZONES)
    {
        zoneData[zoneid][center_x] = (minx maxx) / 2.0;
        zoneData[zoneid][center_y] = (miny maxy) / 2.0;
        zoneData[zoneid][min_x] = minx;
        zoneData[zoneid][min_y] = miny;
        zoneData[zoneid][max_x] = maxx;
        zoneData[zoneid][max_y] = maxy;
        zoneData[zoneid][min_z] = minz;
        zoneData[zoneid][max_z] = maxz;
        format(zoneData[zoneid][name], 35"%s"name);
    }
    
    
return zoneid;
}

public 
GetZoneName(zoneid)
{
    if (zoneid >= && zoneid MAX_GANG_ZONES)
    {
        return zoneData[zoneid][name];
    }
    return "";


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)
public 
GetZoneCenterXY(zoneid, &Float:center_x, &Float:center_y)
{
    if (zoneid >= && zoneid MAX_GANG_ZONES)
    {
        center_x zoneData[zoneid][center_x];
        center_y zoneData[zoneid][center_y];
    }


And then you can use it like this (for example)

PHP Code:
new Float:xFloat:y;
GetZoneCenter(the_zone_idxy); 
Away
  Reply


Messages In This Thread
Center of GangZoneCreate() - by JR_Junior - 2023-10-22, 05:56 PM
RE: Center of GangZoneCreate() - by denNorske - 2023-10-23, 05:44 AM
RE: Center of GangZoneCreate() - by JR_Junior - 2023-10-23, 08:53 PM
RE: Center of GangZoneCreate() - by denNorske - 2023-10-26, 09:29 AM

Forum Jump: