Odometer / Mileage System -
finelaq - 04.12.2015
Hi,
I want to make odometer / mileage system.
I've search these systems on ******. I found one, but it's not working.
pawn Код:
public SpeedVehicle(playerid)
{
new farestring[128];
GetPlayerPos(playerid,NewX[playerid],NewY[playerid],NewZ[playerid]);
new Float:totdistance = GetDistanceBetweenPoints(OldX[playerid],OldY[playerid],OldZ[playerid], NewX[playerid],NewY[playerid],NewZ[playerid]);
format(farestring,sizeof(farestring),"Odometer: %dkm",totdistance);
PlayerTextDrawSetString(playerid, OdometerTD[playerid],farestring);
GetPlayerPos(playerid,Float:OldX[playerid],Float:OldY[playerid],Float:OldZ[playerid]);
return 1;
}
forward Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2);
stock Float:GetDistanceBetweenPoints(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2)
{
x1 -= x2;
y1 -= y2;
z1 -= z2;
return floatsqroot((x1 * x1) + (y1 * y1) + (z1 * z1));
}
When i am driving then it's just alot of numbers and when i stop then it's 0. It's not counting how many kilometers i've driven.
Re: Odometer / Mileage System -
AbyssMorgan - 04.12.2015
from FullServer
PHP код:
enum e_Vectors {
Float:X,
Float:Y,
Float:Z,
Float:A
}
stock GetVehicleSpeed(vehicleid){
new vVector[e_Vectors];
GetVehicleVelocity(vehicleid, vVector[X], vVector[Y], vVector[Z]);
return floatround(floatmul(VectorSize(vVector[X], vVector[Y], vVector[Z]), 190.0));
}
Re: Odometer / Mileage System -
finelaq - 04.12.2015
Quote:
Originally Posted by AbyssMorgan
from FullServer
PHP код:
enum e_Vectors {
Float:X,
Float:Y,
Float:Z,
Float:A
}
stock GetVehicleSpeed(vehicleid){
new vVector[e_Vectors];
GetVehicleVelocity(vehicleid, vVector[X], vVector[Y], vVector[Z]);
return floatround(floatmul(VectorSize(vVector[X], vVector[Y], vVector[Z]), 190.0));
}
|
I don't need vehicle speed, i need mileage system.
Re: Odometer / Mileage System -
Vince - 04.12.2015
Distance = speed / time.
Clearly that last factor is absent. You need to set a timer to calculate the distance between the current position and the last known position, which then gets added to a global total.
Re: Odometer / Mileage System -
DRIFT_HUNTER - 04.12.2015
Try making new Float:totdistance as global variable, and instead of
new Float:totdistance = GetDistanceBetweenPoints....
totdistance += GetDistanceBetweenPoints
and you need some timer (i would use half a second or second)