/fixveh command messed up
#9

It turns out you can RepairVehicle() without a driver, here is a thing that works. Its a little clumsy and unoptimized, but you can probably compare it with your script to get a solution to your problem.
pawn Код:
#include <a_samp>
#include <zcmd>

CMD:fixtest(playerid,params[])
{
    new veh = GetPlayerVehicleID(playerid);
    if(veh)
    {
        RepairVehicle(veh);
        printf("inveh %d",veh);
        return 1;
    }
    veh = GetClosestVehicleID(playerid);
    if(veh)
    {
        RepairVehicle(veh);
        printf("nearveh %d",veh);
        return 1;
    }
    return 1;
}

GetClosestVehicleID(playerid)
{
    new Float:min_dist = 100.0;
    new Float:dist;
    new Float:vehx,Float:vehy,Float:vehz;
    new Float:px,Float:py,Float:pz;
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,px,py,pz);
    new close_vehid;
    for(new i = 1; i < MAX_VEHICLES;i++)
    {
        if(GetVehicleModel(i) > 0)
        {
            GetVehiclePos(i,vehx,vehy,vehz);
            x = px - vehx;
            y = py - vehy;
            z = pz - vehz;
            dist = floatsqroot((x * x) + (y * y) + (z * z));
            if(dist < min_dist)
            {
                min_dist = dist;
                close_vehid = i;
            }
        }
    }
    return close_vehid;
}
I left the printf commands that I used for testing in there, you can remove them if you like.
feel free to add your own messages for success / failure and whatnot.
Reply


Messages In This Thread
/fixveh command messed up - by jurtes - 16.10.2010, 12:27
Re: /fixveh command messed up - by Cameltoe - 16.10.2010, 12:38
Re: /fixveh command messed up - by boelie - 16.10.2010, 12:42
Re: /fixveh command messed up - by jurtes - 16.10.2010, 14:15
Re: /fixveh command messed up - by Rachael - 16.10.2010, 14:49
Re: /fixveh command messed up - by Scenario - 16.10.2010, 15:33
Re: /fixveh command messed up - by [NoV]LaZ - 16.10.2010, 15:41
Re: /fixveh command messed up - by Scenario - 16.10.2010, 15:49
Re: /fixveh command messed up - by Rachael - 16.10.2010, 16:18
Re: /fixveh command messed up - by jurtes - 17.10.2010, 09:12

Forum Jump:


Users browsing this thread: 1 Guest(s)