GetClosestVehicle(playerid, radius) - 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: GetClosestVehicle(playerid, radius) (
/showthread.php?tid=189371)
GetClosestVehicle(playerid, radius) -
armyoftwo - 11.11.2010
I was searching an stock like this but i couldnt find it, does someone have this? and it should return vehicle id!
Re: GetClosestVehicle(playerid, radius) -
rs.pect - 11.11.2010
http://forum.sa-mp.com/showpost.php?...08&postcount=6
Just modify it.
Re: GetClosestVehicle(playerid, radius) -
armyoftwo - 11.11.2010
Quote:
Originally Posted by rs.pect
|
It's not exactly what i need
Re: GetClosestVehicle(playerid, radius) -
Babul - 11.11.2010
could this be helpful?
http://www.xfire.com/video/38ed30/
Код:
CMD:test(playerid,params[]){
new TimerOld=GetTickCount();
new VehID;
new Dist,DistLower=8500,DistLowerSA;
new Float:X,Float:Y,Float:Z;
new Float:pX,Float:pY,Float:pZ;
new XX,YY,ZZ;
new sXX,sYY,sZZ;
GetPlayerPos(playerid,pX,pY,pZ);
for(new v=0;v<MAX_VEHICLES;v++)
{
if(IsPlayerInVehicle(playerid,v)==1) continue;
GetVehiclePos(v,X,Y,Z);
if(IsPlayerInRangeOfPoint(playerid,DistLower,X,Y,Z))
{
XX=floatround(X-pX,floatround_floor);
YY=floatround(Y-pY,floatround_floor);
ZZ=floatround(Z-pZ,floatround_floor);
sXX=XX*XX;
sYY=YY*YY;
sZZ=ZZ*ZZ;
DistLowerSA=sXX+sYY+sZZ;
DistLower=floatround(floatsqroot(DistLowerSA),floatround_floor);
VehID=v;
}
}
new TimerNew=GetTickCount();
new string[48];
format(string,sizeof(string),"Closest Veh:%d Dist:%d ms:%d",VehID,DistLower,TimerNew-TimerOld);
SendClientMessage(playerid,0x33cc33ff,string);
return VehID;
}
Re: GetClosestVehicle(playerid, radius) -
armyoftwo - 11.11.2010
Thanks, perfect i'll modify it
Re: GetClosestVehicle(playerid, radius) -
The_Moddler - 11.11.2010
pawn Код:
stock GetClosestVehicle(playerid, Float:dis)
{
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;
}