GetClosestVehicle(playerid, radius)
#1

I was searching an stock like this but i couldnt find it, does someone have this? and it should return vehicle id!
Reply
#2

http://forum.sa-mp.com/showpost.php?...08&postcount=6

Just modify it.
Reply
#3

Quote:
Originally Posted by rs.pect
Посмотреть сообщение
It's not exactly what i need
Reply
#4

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;
}
Reply
#5

Thanks, perfect i'll modify it
Reply
#6

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)