Quote:
Originally Posted by Roko_foko
It's easier to make a function that counts driving distance then "10 metres you drive" and it is more useful( if you want 10 counter just divide it with 10).
pawn Code:
new Float:Distance[MAX_PLAYERS],Float:lx[MAX_PLAYERS],Float:ly[MAX_PLAYERS],Float:lz[MAX_PLAYERS]; new DDTimer[MAX_PLAYERS]; #define DRIVING_DISTANCE_CHECKER 3000
forward public DrivingDistanceTimer(playerid); public DrivingDistanceTimer(playerid) { new id=GetPlayerVehicleID(playerid); new Float:x,Float:y,Float:z; GetVehiclePos(id,x,y,z); Distance[playerid]+=floatsqroot(floatpower(x-lx[playerid],2)+floatpower(y-ly[playerid],2)+floatpower(y-ly[playerid],2)); lx[playerid]=x;ly[playerid]=y;lz[playerid]=z; } StartCountingDrivingDistance(playerid) { if(IsPlayerInAnyVehicle(playerid)) { Distance[playerid]=0; new id=GetPlayerVehicleID(playerid); GetVehiclePos(id,lx[playerid],ly[playerid],lz[playerid]); DDTimer[playerid]=SetTimerEx("DrivingDistanceTimer",DRIVING_DISTANCE_CHECKER,true,"d",playerid); } } Float:StopCountingDrivingDistance(playerid)// OnPlayerExitVehicle,OnPlayerDisconnect, When player ejected from vehicle( put in jail, teleported to an event, etc.) { new Float:value=Distance[playerid]; Distance[playerid]=0; KillTimer(DDTimer[playerid]); return value; } //StopCountingDrivingDistance returns the distance
Didn't test if it works good.
|
This type of function, was exactly what i was looking for..
Thanks alot!