02.10.2009, 02:04
Hi!
I can't find a working calculus to get my speed-meter working.
I've tried a code that came with a speed-o-meter & one of my own too, but i can't make it work.
Here's the code with what was my old function mixed with someone else's:
And here the part where I draw it on the screen:
I just wanna know why it raises when i accelerate but sometimes i'm going through a straight line and it displays, 70,80, 90, 40, 80, 90, 40 (it goes well below and comes up again to a reasonable number).
I can't find a working calculus to get my speed-meter working.
I've tried a code that came with a speed-o-meter & one of my own too, but i can't make it work.
Here's the code with what was my old function mixed with someone else's:
Код:
public Float:GetVelocity(playerid,Float:X, Float:Y,Float:Z)
{
if(IsPlayerConnected(playerid) && IsPlayerInAnyVehicle(playerid))
{
new Float:Distance;
GetPlayerPos(playerid, X, Y, Z);
Distance = floatsqroot(floatadd(floatadd(floatpower(floatsub(X, OldX[playerid]), 2), floatpower(floatsub(Y, OldY[playerid]), 2)), floatpower(floatsub(Z, OldZ[playerid]), 0)));
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
OldX[playerid] = X; OldY[playerid] = Y; OldZ[playerid] = Z;
new Float:Kilometers = floatround(floatmul(Distance, 2.0), floatround_floor);
return Kilometers;
}
else return 0.0;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
Код:
new Float:result = GetVelocity(playerid, x,y,z); new string[128]; format(string, sizeof(string),"%f", result); SendClientMessage(playerid, 0xff0000ff, string); return 1; }

