SA-MP Forums Archive
How to check is car moving? - 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: How to check is car moving? (/showthread.php?tid=543215)



How to check is car moving? - Banditukas - 25.10.2014

Hi,

HOw to check is car moving when there is no players? because with GetVehicleVelocity this is not working...


Re: How to check is car moving? - DavidBilla - 25.10.2014

Use GetVehiclePos in a repeating 1 second timer and compare the positions to check if the vehicle has moved or not.


Re: How to check is car moving? - Steel_ - 25.10.2014

All i found was this
pawn Код:
stock IsVehicleDrivingBackwards(vehicleid)
{
    new Float:Float[3];
    if(GetVehicleVelocity(vehicleid, Float[1], Float[2], Float[0]))
    {
        GetVehicleZAngle(vehicleid, Float[0]);
        if(Float[0] < 90)
        {
            if(Float[1] > 0 && Float[2] < 0) return true;
        }
        else if(Float[0] < 180)
        {
            if(Float[1] > 0 && Float[2] > 0) return true;
        }
        else if(Float[0] < 270)
        {
            if(Float[1] < 0 && Float[2] > 0) return true;
        }
        else if(Float[1] < 0 && Float[2] < 0) return true;
    }
    return false;
}
It only checks if the vehicle is reversing. Perhaps you could change that code to see if the vehicle is moving forwards.


Re: How to check is car moving? - sammp - 25.10.2014

nvm...


Re: How to check is car moving? - Anzipane - 25.10.2014

I think you're referring to this: OnUnoccupiedVehicleUpdate