Vehicle's speed quick question
#1

I'm doubt if that's correct. That's about getVehicleSpeed in KM/H

pawn Код:
new Float:x, Float:y, Float:z;
    if(IsPlayerInAnyVehicle(playerid))
    {
        GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
        return (floatsqroot(x * x + y * y + z * z) * 180.00);
    }
Otherwise, if anyone knows any other way...
Reply
#2

There is no right or wrong, just take some value, if you are bored read that topic
http://forum.sa-mp.com/showthread.ph...ighlight=speed

Try to use the native VectorSize (since 0.3z) for pythagoras
pawn Код:
stock Float: GetVehicleSpeed(vehicleid) {
    new
        Float: vX,
        Float: vY,
        Float: vZ
    ;
    if(GetVehicleVelocity(vehicleid, vX, vY, vZ)) {
        return VectorSize(vX, vY, vZ) * 180.0;
    }
    return 0.0;
}
Reply
#3

Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)