04.12.2015, 12:57
Hi,
I want to make odometer / mileage system.
I've search these systems on ******. I found one, but it's not working.
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.
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));
}