SA-MP Forums Archive
Perfect GetPlayerSpeed for MPH? - 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: Perfect GetPlayerSpeed for MPH? (/showthread.php?tid=322504)



Perfect GetPlayerSpeed for MPH? - jameskmonger - 02.03.2012

I've been playing around with GetPlayerSpeed but can't get it realistic in MPH - can someone help? For the record, Infernus should go about 210 MPH

(yay my 900th post)


AW: Perfect GetPlayerSpeed for MPH? - Drebin - 02.03.2012

How could we help you without showing us the code you've made so far?


Re: Perfect GetPlayerSpeed for MPH? - jameskmonger - 02.03.2012

pawn Код:
stock GetPlayerSpeed(playerid)
{
    new Float:velocity[4];
    if(IsPlayerInAnyVehicle(playerid))
    GetVehicleVelocity(GetPlayerVehicleID(playerid),velocity[0],velocity[1],velocity[2]);
    else GetPlayerVelocity(playerid,velocity[0],velocity[1],velocity[2]);
    velocity[3] = floatsqroot(floatpower(floatabs(velocity[0]), 2.0) + floatpower(floatabs(velocity[1]), 2.0) + floatpower(floatabs(velocity[2]), 2.0)) * 97;
    return floatround(velocity[3]);
}



Re: Perfect GetPlayerSpeed for MPH? - Vince - 02.03.2012

For the record, the game's files say that the Infernus' max speed is 240 Km/h, which a little more than 149 MPH.


Re: Perfect GetPlayerSpeed for MPH? - jameskmonger - 02.03.2012

The car is based on this:
http://en.wikipedia.org/wiki/Cizeta-Moroder_V16T
which has a top speed of 204MPH


Re: Perfect GetPlayerSpeed for MPH? - iTorran - 02.03.2012

204 and/or 210mph is way too high for the Infernus's accurate top speed
What Vince said is a more believable speed for it


Re: Perfect GetPlayerSpeed for MPH? - Mike_Peterson - 02.03.2012

So, 210 mph is around 340 km/h
On (most) servers, the infernus' max speed is 221 and the LSPD premier is around 177.
177 is 80 percent of 221.. 80 percent of 340 is 272. So, you want a LSPD car go 270km/h..
and what about a tractor? let's say on other servers the speed is 50km/h, which is 22% of 221.
22% of 340 is around 75, now i wouldn't say a tractor (of that model) goes 75 km/h now does it?


Re: Perfect GetPlayerSpeed for MPH? - jameskmonger - 02.03.2012

Tractors go around 45mph in real life, which is about 70kph


AW: Re: Perfect GetPlayerSpeed for MPH? - Nero_3D - 02.03.2012

Quote:
Originally Posted by jameskmonger
Посмотреть сообщение
Tractors go around 45mph in real life, which is about 70kph
Sure modern tractors go that fast but like mike said
Quote:
Originally Posted by Mike_Peterson
Посмотреть сообщение
of that model
the tractor in gta-sa looks pretty old

pawn Код:
stock GetPlayerSpeed(playerid) {
    new
        Float: vX = Float: GetPlayerVehicleID(playerid),
        Float: vY,
        Float: vZ
    ;
    if(_: vX) {
        GetVehicleVelocity(_: vX, vX, vY, vZ);
    } else {
        GetPlayerVelocity(playerid, vX, vY, vZ);
    }
    vX *= vX, vY *= vY, vZ *= vZ;
    return (floatsqroot(vX + vY + vZ) * 200.0);
}
With the multiplier of 200 you get a realistic kmh (~245 infernus top speed), just divide it through 1.61 to get to mph


Re: AW: Re: Perfect GetPlayerSpeed for MPH? - jameskmonger - 02.03.2012

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
just divide it through 1.61 to get to mph
No, he didn't. 1kph = 0.625mph, so you divide the result to convert it.