IsPlayerInRangeOfCar ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: IsPlayerInRangeOfCar ? (
/showthread.php?tid=258901)
IsPlayerInRangeOfCar ? -
Ricop522 - 02.06.2011
Anyone have this stock ?
IsPlayerInRangeOfVehicle(playerid, vehicleid, 15.0)
Something like this or
GetVehicleNearPlayer(vehicleid, playerid, distance)
Re: IsPlayerInRangeOfCar ? -
CyNiC - 02.06.2011
pawn Код:
stock IsPlayerInRangeOfVehicle(playerid, vehicleid, Float:Range)
{
new Float:Pos[3];
GetVehiclePos(vehicleid, Pos[0], Pos[1], Pos[2]);
return IsPlayerInRangeOfPoint(playerid, Range, Pos[0], Pos[1], Pos[2]);
}
Re: IsPlayerInRangeOfCar ? -
Backwardsman97 - 02.06.2011
I think vehicles are synced by a player being in them. So it may not work if nobody is in the vehicle.
Re: IsPlayerInRangeOfCar ? -
Ricop522 - 02.06.2011
hmmm this is tru
but thanks for the help
Re: IsPlayerInRangeOfCar ? -
Mike Garber - 02.06.2011
Quote:
Originally Posted by Backwardsman97
I think vehicles are synced by a player being in them. So it may not work if nobody is in the vehicle.
|
This changed with 0.3, so vehicles are now synced at all times.
Damn you don't play SA:MP anymore? XD
pawn Код:
stock GetClosestVehicle(playerid, &Float:dis = (Float:0x7F800000))
{
dis = (Float:0x7F800000);
new Float:X, Float:Y, Float:Z;
if(GetPlayerPos(playerid, X, Y, Z)) {
new vehicleid = INVALID_VEHICLE_ID;
for(new v, Float:temp, Float:VX, Float:VY, Float:VZ; v != MAX_VEHICLES; v++) {
if(GetVehiclePos(v, VX, VY, VZ)) {
VX -= X, VY -= Y, VZ -= Z;
temp = VX * VX + VY * VY + VZ * VZ;
if(temp < dis) dis = temp, vehicleid = v;
}
}
dis = floatpower(dis, 0.5);
return vehicleid;
}
return INVALID_VEHICLE_ID;
}
I did not create this