SA-MP Forums Archive
Target car - 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: Target car (/showthread.php?tid=334557)



Target car - Jstylezzz - 15.04.2012

Hi,

Is it possible to /repair a car when you are in front of it??
I saw it somewhere in a server, but when i try things it always goes wrong

I think i have to use sscanf, does someone know a function like this??

Thanks


Re: Target car - Hoss - 15.04.2012

pawn Код:
stock GetNearestVehicle(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;
}

CMD:repairveh(playerid,params[])
{
new nearest = GetNearestVehicle(playerid, 10.0);
RepairVehicle(nearest);
SendClientMessage(playerid,-1,"Vehicle Repaired");
}



Re: Target car - Jstylezzz - 15.04.2012

Thanks man!

EDIT: nVm solved