Odometer / Mileage System
#1

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.
Reply
#2

from FullServer
PHP код:
enum e_Vectors {
    
Float:X,
    
Float:Y,
    
Float:Z,
    
Float:A
}

stock GetVehicleSpeed(vehicleid){
    new 
vVector[e_Vectors];
    
GetVehicleVelocity(vehicleidvVector[X], vVector[Y], vVector[Z]);
    return 
floatround(floatmul(VectorSize(vVector[X], vVector[Y], vVector[Z]), 190.0));

Reply
#3

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(vehicleidvVector[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.
Reply
#4

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.
Reply
#5

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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)