GetPlayerNearestVehicle - While you in vehicle. prob.
#5

It wont mess the other script usage of "GetPlayerNearestVehicle" ?

For example : /friskcar - Which need to check the car ID. I hope you understand my point.

I was thinking of creating new stock "GetVehicleNearestVehicle".

pawn Код:
stock GetVehicleNearestVehicle(playerid)
{
    new closest = -1;
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(GetDistanceFromVehicleToVehicle(playerid, i) < GetDistanceFromVehicleToVehicle(playerid, closest) && closest != -1 && IsVehicleConnected(i) && GetVehicleVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
        {
            closest = i;
        }
        if(closest == -1 && IsVehicleConnected(i)) closest = i;
    }
    return closest;
}
stock GetDistanceFromVehicleToVehicle(playerid, closestcarid)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    new Float:tmpdis;
    GetPlayerPos(playerid,x1,y1,z1);
    GetVehiclePos(closestcarid,x2,y2,z2);
    tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
    return floatround(tmpdis);
}
Im giving it a test now.

// updating

Wont work it seems like the "wguns" wont go to the nearst vehicle.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)