mileage in meters
#1

How to calculate the mileage in meters. I mean how to get the amount of meters the player drove in a car
Reply
#2

Every time you update your speedometer, get the player's position. Then compare it with the last known position to calculate the distance between the two points (or disregard it in case the distance is too great). Add the result to a global player variable.
Reply
#3

Would something like this work?
Quote:

new Float[3][MAX_PLAYERS],FloatNow[MAX_PLAYERS],Float:aNow[MAX_PLAYERS],Float:actualDistance[MAX_PLAYERS],Float:newDistance[3][MAX_PLAYERS];

Quote:

public OnPlayerUpdate(playerid)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(newDistance[0||1||2][playerid] == 0)
{
GetPlayerPos(playerid, newDistance[0][playerid], newDistance[1][playerid], newDistance[2][playerid]);
}
else
{
GetPlayerPos(playerid, p[0][playerid], p[1][playerid], p[2][playerid]);
pNow[playerid] = p[0][playerid]+=p[1][playerid]+=p[2][playerid];
aNow[playerid] = newDistance[0][playerid]+=newDistance[1][playerid]+=newDistance[2][playerid];
actualDistance[playerid] = pNow[playerid]-=aNow[playerid];
newDistance[0&&1&&2][playerid]=0;
p[0&&1&&2][playerid]=0;
}
}
return 1;
}

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)