ayuda... 'IsVehicleUnderVehicle' - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (
https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: ayuda... 'IsVehicleUnderVehicle' (
/showthread.php?tid=499668)
ayuda... 'IsVehicleUnderVehicle' -
OTACON - 09.03.2014
buenas a todos, alguien me podria decir como podria hacer para detectar si hay algun vehiculo debajo del vehiculo que este el jugador?.
pero justamente debajo.
hice esto pero no funciono
.
pawn Код:
stock IsVehicleUnderVehicle(vehicleid,Float:dist, Float:x, Float:y, Float:z){
for(new vehid; vehid < MAX_VEHICLES; vehid++){
if(!IsValidVehicle(vehid)||vehid==vehicleid)continue;
if(IsVehicleInRangeOfPoint(vehicleid,dist,x,y,z-dist))return true;
}return false;}
desde ya muchas gracias.
PD: el vehiculo el que estara el jugador obviamente es aereo. ¬¬ ._.
Re: ayuda... 'IsVehicleUnderVehicle' -
notanoob - 10.03.2014
Prueba asi:
pawn Код:
stock IsVehicleUnderVehicle(vehicleid,Float:dist, Float:x, Float:y, Float:z){
for(new vehid; vehid < MAX_VEHICLES; vehid++)
{
if(!IsValidVehicle(vehid)||vehid==vehicleid)continue;
if(IsVehicleInRangeOfPoint(vehicleid,dist,x,y,z+dist))
return true;
}
return false;
}
Respuesta: ayuda... 'IsVehicleUnderVehicle' -
MugiwaraNoLuffy - 10.03.2014
Lo que podes hacer es chequear la distancia 2D, o sea, entre las coordenadas X Y y luego ver si la coordenada z es menor a la del otro vehiculo.:
pawn Код:
stock bool:IsVehicleUnderVehicle(vehicleid, uppervehicleid)
{
new Float:data[7];
GetVehiclePos(vehicleid, data[0], data[1], data[2]);
GetVehiclePos(uppervehicleid, data[3], data[4], data[5]);
data[6] = Floatsqroot(Floatpower(data[0]-data[3], 2)+Floatpower(data[1]+data[4],2)) //distancia 2d
if(data[6] <= 2.0 && data[2] < data[5]) return true; //si la distancia de las coordenadas x y es menos de 2.0 unidades y el vehiculo de arriba (uppervehicleid) tiene mayor coordenada z, devuelve true
return false;
}