25.01.2014, 06:26
Hello,
I have downloaded a list of zones.inc from https://sampforum.blast.hk/showthread.php?tid=24664, but the download link for the actaul script is down. So I need to make some functions to loop through the arrays and compare the coordinates to return the name of the zone the player is in.
I'm not sure how to check if a 3D coordinate is within a 3D area.
The coordinates look like this
I imagine it will be something like this:
but i'm not sure how to do it EXACTLY.
Alternatively, if someone can recommend a good script designed for this purpose that would be great too.
Thanks.
I have downloaded a list of zones.inc from https://sampforum.blast.hk/showthread.php?tid=24664, but the download link for the actaul script is down. So I need to make some functions to loop through the arrays and compare the coordinates to return the name of the zone the player is in.
I'm not sure how to check if a 3D coordinate is within a 3D area.
The coordinates look like this
Код:
struct zoneinfo { char zone_name[27]; float zone_minx; float miny; float zone_minz; float zone_maxx; float zone_maxy; float zone_maxz; }; zoneinfo zones[] = { { "'The Big Ear'", -410.00, 1403.30, -3.00, -137.90, 1681.20, 200.00 }, { "Aldea Malvada", -1372.10, 2498.50, 0.00, -1277.50, 2615.30, 200.00 }, { "Angel Pine", -2324.90, -2584.20, -6.10, -1964.20, -2212.10, 200.00 }, { "Arco del Oeste", -901.10, 2221.80, 0.00, -592.00, 2571.90, 200.00 }, { "Avispa Country Club", -2646.40, -355.40, 0.00, -2270.00, -222.50, 200.00 }, { "Avispa Country Club", -2831.80, -430.20, -6.10, -2646.40, -222.50, 200.00 }, { "Avispa Country Club", -2361.50, -417.10, 0.00, -2270.00, -355.40, 200.00 }, ... }; struct zareainfo { char zarea_name[27]; float zarea_minx; float zarea_miny; float zarea_minz; float zarea_maxx; float zarea_maxy; float zarea_maxz; }; zareainfo zarea[] = { // Main zarea { "Los Santos", 44.60, -2892.90, -242.90, 2997.00, -768.00, 900.00 }, { "Las Venturas", 869.40, 596.30, -242.90, 2997.00, 2994.00, 900.00 }, { "Bone County", -479.00, 596.50, -242.90, 869.00, 2993.00, 900.00 }, { "Tierra Robada", -2997.40, 1659.60, -242.90, -481.50, 2992.00, 900.00 }, { "Tierra Robada", -1213.90, 596.30, -242.90, -481.50, 1659.60, 900.00 }, { "San Fierro", -2997.40, -1115.50, -242.90, -1213.90, 1659.60, 900.00 }, { "Red County", -1213.90, -768.00, -242.90, 2997.00, 596.30, 900.00 }, { "Flint County", -1213.90, -2892.90, -242.90, 44.60, -768.00, 900.00 }, { "Whetstone", -2997.40, -2892.90, -242.90, -1213.90, -1115.50, 900.00 } };
Код:
float fPos[3]; GetPlayerPos(playerid, &fPos[0], &fPos[1], &fPos[2]); for(int i = 0; i < ArraySize(zones); i++) { if(zones[i].minx >= fPos[0] && zones[i].miny <= fPos[1]) return zones[i].name; }
Alternatively, if someone can recommend a good script designed for this purpose that would be great too.
Thanks.