Weird speed readings...
#1

Okay, watch the speed in the video (aka. look at the TDs).

[ame]http://www.youtube.com/watch?v=mpUcxMGwQ8M[/ame]

Notice how the speed is jumping? What could be causing that? Here's the code:

pawn Код:
timer vehicleDashboard[500](playerid, vehicleid)
{
    // some other functions here
 
    new szString[23];
    format(szString, sizeof(szString), "%d MP/H    %d KM/H", GetVehicleSpeed(vehicleid, true), GetVehicleSpeed(vehicleid, false));
    TextDrawSetString(vehicleSpeedTD[playerid], szString);
}

stock GetVehicleSpeed(vehicleid, bool:MPH = true)
{
    new Float:x, Float:y, Float:z, vel;
    GetVehicleVelocity( vehicleid, x, y, z );
   
    if(MPH == true) vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 / 1.609344 ); // MPH
    else  vel = floatround( floatsqroot( x*x + y*y + z*z ) * 180 ); // KPH
    return vel;
}
Reply
#2

180? try 200 and it's better to use the functions instead of the operators.

pawn Код:
stock GetPlayerSpeed(playerid, bool:kmh)
{
    new Float:Speed, Float:x, Float:y, Float:z;
    if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid), x, y, z);
    else GetPlayerVelocity(playerid, x, y, z);
    Speed = floatmul(floatsqroot(floatadd(floatadd(floatpower(x, 2), floatpower(y, 2)),  floatpower(z, 2))), 200.0); //100.0
    return kmh == true ? floatround(Speed, floatround_floor) : floatround(floatdiv(Speed, 1.609344), floatround_floor);
}
Reply
#3

ask the other player to stop for some time, then i bet it will "jump " to 0 speed constantly (before your textdraw gets written). its most prolly some timer[] bug, idk how i should interpret timer[500], maybe these are mixing up with playerid?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)