GetClosestVehicleID - 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)
+--- Thread: GetClosestVehicleID (
/showthread.php?tid=328396)
GetClosestVehicleID -
The__ - 24.03.2012
pawn Код:
stock GetClosestVehicle(playerid, Float: fRadius) // by RyDeR`
{
new
iClosestID = INVALID_VEHICLE_ID,
Float: fFinalDistance,
Float: fDistance,
Float: fX,
Float: fY,
Float: fZ;
GetPlayerPos(playerid, fX, fY, fZ);
fFinalDistance = fRadius;
for(new i; i != MAX_VEHICLES; i++)
{
if((fDistance = GetVehicleDistanceFromPoint(i, fX, fY, fZ)) < fFinalDistance)
{
fFinalDistance = fDistance;
iClosestID = i;
}
}
return iClosestID;
}
I have that command by RyDeR`, but how can I get the closest ID ?
Re: GetClosestVehicleID -
chrism11 - 24.03.2012
For Example:
Код:
new string[256];
format(string,sizeof(string),"Vehicleid: %d",GetClosestVehicle(playerid, 5))
SendClientMessage(playerid,1,string);
Re: GetClosestVehicleID -
The__ - 24.03.2012
I have this :
pawn Код:
new engine,lights,alarm,doors,bonnet,boot,objective;
new veh = GetClosestVehicle(playerid, 3);
GetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,boot,objective);
if(boot == VEHICLE_PARAMS_ON)
{
SendClientMessage(playerid, COLOR_GREY, "The trunk is opened already.");
return 1;
}
GetPlayerNameEx(playerid);
SetVehicleParamsEx(veh,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective);
PlayerActionMessage(playerid,15.0,"clicks a button and opens the trunk.");
But it doesn't work, the trunk doesn't open.
Re: GetClosestVehicleID -
The DeLuca - 25.03.2012
Код:
stock GetClosestVehicle(playerid)
{
new Float:x, Float:y, Float:z;
new Float:dist, Float:closedist=9999, closeveh;
for(new i=1; i < MAX_VEHICLES; i++)
{
if(GetVehiclePos(i, x, y, z))
{
dist = GetPlayerDistanceFromPoint(playerid, x, y, z);
if(dist < closedist)
{
closedist = dist;
closeveh = i;
}
}
}
return closeveh;
}