PDA

View Full Version : need help with place name


titanak
21/11/2011, 02:00 PM
Hello i need help with getting Place name from coords..


i got the list and some funcs




new zones[][zoneinfo] = {
{ "'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},
// etc.... didn't add all places..


but it only gets that zone where player is exactly




stock IsPlayerInZone(playerid, zoneid) {
if(zoneid == -1) return false;
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(x >= zones[zoneid][zone_minx] && x < zones[zoneid][zone_maxx] && y >= zones[zoneid][zone_miny] && y < zones[zoneid][zone_maxy] && z >= zones[zoneid][zone_minz] && z < zones[zoneid][zone_maxz] && z < 900.0) return true;
return false;
}

stock ReturnPlayerZone(playerid)
{
new playerzone[256] = "~r~Cannot Find";
for(new j; j < sizeof(zones); j++) {
if(IsPlayerInZone(playerid,j))
{
memcpy(playerzone, zones[j][zone_name], 0, 108);
break;
}
}
return playerzone;
}



i need like:

stock ReturnPlayerZone(Float:X,Float:Y,Float:Z)

or something ,, but i cannot understand how to do that.

can someone be so good and help me to fix this code.? repping too who helps :)

Pharrel
21/11/2011, 02:09 PM
stock IsPlayerInZone(Float:x, Float:y, Float:z, zoneid)
{
if(zoneid == -1) return false;
if(x >= zones[zoneid][zone_minx] && x < zones[zoneid][zone_maxx] && y >= zones[zoneid][zone_miny] && y < zones[zoneid][zone_maxy] && z >= zones[zoneid][zone_minz] && z < zones[zoneid][zone_maxz] && z < 900.0) return true;
return false;
}

stock ReturnPlayerZone(Float:x, Float:y, Float:z)
{
new playerzone[50] = "~r~Cannot Find";
for(new j; j < sizeof(zones); j++)
{
if(IsPlayerInZone(x,y,z,j))
{
memcpy(playerzone, zones[j][zone_name], 0, 108);
break;
}
}
return playerzone;
}

titanak
25/11/2011, 03:36 PM
like u see ReturnPlayerZone(Float:X,Float:Y,Float:Z)

i want it to it gets the zone name FROM A Place , Z , Y ,Z By coord system , not that where player currently is.

anyone else help ?

Pharrel
25/11/2011, 03:43 PM
The first function do that...but anyway i did another way now.
stock ReturnZoneName(Float:x, Float:y, Float:z)
{
new zonename[50] = "~r~Cannot Find";
for(new zoneid; zoneid < sizeof(zones); zoneid++)
{
if(x >= zones[zoneid][zone_minx] && x < zones[zoneid][zone_maxx]
&& y >= zones[zoneid][zone_miny] && y < zones[zoneid][zone_maxy]
&& z >= zones[zoneid][zone_minz] && z < zones[zoneid][zone_maxz]
&& z < 900.0)
{
memcpy(playerzone, zones[j][zone_name], 0, 108);
break;
}
}
return zonename;
}

titanak
25/11/2011, 03:53 PM
The first function do that...but anyway i did another way now.
stock ReturnZoneName(Float:x, Float:y, Float:z)
{
new zonename[50] = "~r~Cannot Find";
for(new zoneid; zoneid < sizeof(zones); zoneid++)
{
if(x >= zones[zoneid][zone_minx] && x < zones[zoneid][zone_maxx]
&& y >= zones[zoneid][zone_miny] && y < zones[zoneid][zone_maxy]
&& z >= zones[zoneid][zone_minz] && z < zones[zoneid][zone_maxz]
&& z < 900.0)
{
memcpy(playerzone, zones[j][zone_name], 0, 108);
break;
}
}
return zonename;
}


Very nice thank you very much it works :P

titanak
25/11/2011, 04:01 PM
my bad it works now thanks ! :P

Pharrel
25/11/2011, 04:07 PM
you're welcome :)