how to get the speed?
#1

:P I know speed is = distance/time but how do i manage to get that on samp

I read a couple of speedometers script and I cant fully understand it
Reply
#2

this is how i do it seems to work sweet
pawn Код:
stock GetPlayerSpeed(playerid){ //retuns speed in kmph (for mph use 125)
    new Float:xx,Float:yy,Float:zz,Float:pSpeed;
    if(IsPlayerInAnyVehicle(playerid))GetVehicleVelocity(GetPlayerVehicleID(playerid),xx,yy,zz);
    else GetPlayerVelocity(playerid,xx,yy,zz);
    pSpeed = floatmul(floatsqroot(floatpower(xx,2)+floatpower(yy,2)+floatpower(zz,2)),200);
    return floatround(pSpeed);
}
change 200 to 125 in the 2nd to last line for mph
enjoy
Reply
#3

worked thx and it's wayyyyyyyyyyyyy cleaner than other scripts i've seen :P
Reply
#4

sorry, instead of making another topic.

Using that GetPlayerSpeed Code, how could you do something like this

pawn Код:
if(GetPlayerSpeed(playerid) < 0 ) FuelLevel[vehicleid] --/2;
that code is under a fuel system, as you see if the player is not using speed, the fuel level keeps decreasin, but isntead of the normal decrease i would like to divide that by 2 or 4. im not sure if you put the --/2; or something else.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)