17.04.2014, 21:12

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

mileage in meters

17.04.2014, 21:12

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

17.04.2014, 21:52

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.

17.04.2014, 22:30

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; } |

Users browsing this thread: 1 Guest(s)