GetClosestCar ID - 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: GetClosestCar ID (
/showthread.php?tid=73740)
GetClosestCar ID -
Robbin237 - 17.04.2009
<Not solved> Look at my last reply
Re: GetClosestCar ID -
Robbin237 - 17.04.2009
bump
Re: GetClosestCar ID -
OmeRinG - 17.04.2009
if(GetVehicleID(carid) == 522)
Re: GetClosestCar ID -
Sandra18[NL] - 17.04.2009
Код:
public GetClosestCarWithModel(playerid, model)
{
if (!IsPlayerConnected(playerid))
{
return -1;
}
new Float:prevdist = 100000.000;
new prevcar;
for (new carid = 0; carid < MAX_VEHICLES; carid++)
{
if(GetVehicleModel(carid) == model)
{
new Float:dist = GetDistanceToCar(playerid,carid);
if ((dist < prevdist))
{
prevdist = dist;
prevcar = carid;
}
}
}
return prevcar;
}
Re: GetClosestCar ID -
Robbin237 - 18.04.2009
Is it possible to check using the IsPlayerInVehicle Function if there is any player in that vehicle, and if so, take the next closest?
Thnx
Re: GetClosestCar ID -
Robbin237 - 18.04.2009
bumpzors
Re: GetClosestCar ID -
Backwardsman97 - 18.04.2009
pawn Код:
public GetClosestCarWithModel(playerid, model)
{
if (!IsPlayerConnected(playerid))
{
return -1;
}
new Float:prevdist = 100000.000;
new prevcar;
for (new carid = 0; carid < MAX_VEHICLES; carid++)
{
if(!IsAnyPlayerInVehicle(carid))
{
if(GetVehicleModel(carid) == model)
{
new Float:dist = GetDistanceToCar(playerid,carid);
if ((dist < prevdist))
{
prevdist = dist;
prevcar = carid;
}
}
}
}
return prevcar;
}
stock IsAnyPlayerInVehicle(vehicleid)
{
for(new i=0; i<MAX_PLAYERS; i++)
if(IsPlayerInVehicle(i,vehicleid)) return 1;
return 0;
}