[Ayuda]Obtener el punto mбs cercano.
#1

ЎHola!, tengo una duda respecto a esto, estuve observando los spawns de GrandLacerny y encontrй estos puntos y me gustarнa saber їcуmo obtener la coordenada mбs cercana a algъn punto?, como ejemplo, el jugador.

PHP код:
new Float:gRandomSpawns_LosSantos[][4] = {
{
1751.1097,-2106.4529,13.5469,183.1979}, // El-Corona - Outside random house
{2652.6418,-1989.9175,13.9988,182.7107}, // Random house in willowfield - near playa de seville and stadium
{2489.5225,-1957.9258,13.5881,2.3440}, // Hotel in willowfield - near cluckin bell
{2689.5203,-1695.9354,10.0517,39.5312}, // Outside stadium - lots of cars
{2770.5393,-1628.3069,12.1775,4.9637}, // South in east beach - north of stadium - carparks nearby
{2807.9282,-1176.8883,25.3805,173.6018}, // North in east beach - near apartments
{2552.5417,-958.0850,82.6345,280.2542}, // Random house north of Las Colinas
{2232.1309,-1159.5679,25.8906,103.2939}, // Jefferson motel
{2388.1003,-1279.8933,25.1291,94.3321}, // House south of pig pen
{2481.1885,-1536.7186,24.1467,273.4944}, // East LS - near clucking bell and car wash
{2495.0720,-1687.5278,13.5150,359.6696}, // Outside CJ's house - lots of cars nearby
{2306.8252,-1675.4340,13.9221,2.6271}, // House in ganton - lots of cars nearby
{2191.8403,-1455.8251,25.5391,267.9925}, // House in south jefferson - lots of cars nearby
{1830.1359,-1092.1849,23.8656,94.0113}, // Mulholland intersection carpark
{2015.3630,-1717.2535,13.5547,93.3655}, // Idlewood house
{1654.7091,-1656.8516,22.5156,177.9729}, // Right next to PD
{1219.0851,-1812.8058,16.5938,190.0045}, // Conference Center
{1508.6849,-1059.0846,25.0625,1.8058}, // Across the street of BANK - lots of cars in intersection carpark
{1421.0819,-885.3383,50.6531,3.6516}, // Outside house in vinewood
{1133.8237,-1272.1558,13.5469,192.4113}, // Near hospital
{1235.2196,-1608.6111,13.5469,181.2655}, // Backalley west of mainstreet
{590.4648,-1252.2269,18.2116,25.0473}, // Outside "BAnk of San Andreas"
{842.5260,-1007.7679,28.4185,213.9953}, // North of Graveyard
{911.9332,-1232.6490,16.9766,5.2999}, // LS Film Studio
{477.6021,-1496.6207,20.4345,266.9252}, // Rodeo Place
{255.4621,-1366.3256,53.1094,312.0852}, // Outside propery in richman
{281.5446,-1261.4562,73.9319,305.0017}, // Another richman property
{790.1918,-839.8533,60.6328,191.9514}, // Mulholland house
{1299.1859,-801.4249,84.1406,269.5274}, // Maddoggs
{1240.3170,-2036.6886,59.9575,276.4659}, 
{
2215.5181,-2627.8174,13.5469,273.7786},
{
2509.4346,-2637.6543,13.6453,358.3565
}; 
їCуmo podrнa encontrar la coordenada mбs cercana a XYZ punto?
Reply
#2

https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
Reply
#3

Quote:
Originally Posted by OTACON
Посмотреть сообщение
Va, no sй si me expliquй, conocнa de eso pero no sй como utilizarlo para ir coordenada por coordenada de las de gRandomSpawns_LosSantos, esa era la duda.
Reply
#4

Код:
new Float:distancia = 10.0;

for(new index=0, idx=sizeof(gRandomSpawns_LosSantos); index<=idx; index++)
{
    if ( IsPlayerInRangeOfPoint(playerid, distancia, gRandomSpawns_LosSantos[index][0], gRandomSpawns_LosSantos[index][1], gRandomSpawns_LosSantos[index][2] ) )
    {
    	SendClientMessage(playerid,-1,"encontrado!");
    	break;
    }
}
Reply
#5

Quote:
Originally Posted by OTACON
Посмотреть сообщение
Код:
new Float:distancia = 10.0;

for(new index=0, idx=sizeof(gRandomSpawns_LosSantos); index<=idx; index++)
{
    if ( IsPlayerInRangeOfPoint(playerid, distancia, gRandomSpawns_LosSantos[index][0], gRandomSpawns_LosSantos[index][1], gRandomSpawns_LosSantos[index][2] ) )
    {
    	SendClientMessage(playerid,-1,"encontrado!");
    	break;
    }
}
No funciona del todo bien, aumentй la distancia y no detecta ningъn punto y me parece que solo detectarб la primer coordenada y no la mбs cercana.. їcуmo soluciono esto?
Reply
#6

pawn Код:
SpawnMasCercanoDe(x,y,z) {
    new Float:dis = 1000000.00;
    new id;
    for(new i=0,d; i<sizeof gRandomSpawns_LosSantos; i++) {
        d = GetDistance(x,y,z,gRandomSpawns_LosSantos[0],gRandomSpawns_LosSantos[1],gRandomSpawns_LosSantos[2]);
        if(d < dis) {
            dis= d;
            id = i;
        }
    }
    return id;
}

//------------------------------------------------------------------------------
forward Float:GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2);
public  Float:GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) {
    return VectorSize(floatabs(floatsub(x2,x1)),floatabs(floatsub(y2,y1)),floatabs(floatsub(z2,z1)));
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)