SA-MP Forums Archive
Need Suggestions With Vehicle Odometer - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need Suggestions With Vehicle Odometer (/showthread.php?tid=284576)

Pages: 1 2


Re: Need Suggestions With Vehicle Odometer - titanak - 20.09.2011

the code is so messed up now and it does not show me the odo..


Re: Need Suggestions With Vehicle Odometer - =WoR=Varth - 20.09.2011

pawn Code:
new Float:a[MAX_VEHICLES],
playerx[MAX_PLAYERS],playery[MAX_PLAYERS],playerz[MAX_PLAYERS];//Global

//onplayerstatechange
if(IsPlayerInAnyVehicle(playerid))
{
   GetPlayerPos(playerid,playerx[playerid],playery[playerid],playerz[playerid]);
   //Timer to call the public
}

forward OdoCounter(playerid);
public OdoCounter(playerid)
{
   a += GetPlayerDistanceFromPoint(playerid,playerx[playerid],playery[playerid],playerz[playerid]);
   GetPlayerPos(playerid,playerx[playerid],playery[playerid],playerz[playerid]);
   //Odo is a
}
EDITED.


Re: Need Suggestions With Vehicle Odometer - titanak - 20.09.2011

what is the interval ?? 1000 ms ??


Re: Need Suggestions With Vehicle Odometer - =WoR=Varth - 20.09.2011

Quote:
Originally Posted by titanak
View Post
what is the interval ?? 1000 ms ??
Up2u, lower the interval that will more accurate.


Re: Need Suggestions With Vehicle Odometer - titanak - 20.09.2011

danke.


Re: Need Suggestions With Vehicle Odometer - =WoR=Varth - 20.09.2011

Quote:
Originally Posted by titanak
View Post
atleast got it to work btw does the result is meters or what ?
now only have to fix the tele bug lol . gives like +5000 if teleporting

and thanks for wasting your time to me
Actually I just noticed that there's GetVehicleDistanceFromPoint but I guess it have no different.
SAMP unit (?). I think you can call it meters.


Re: Need Suggestions With Vehicle Odometer - dowster - 20.09.2011

Quote:
Originally Posted by titanak
View Post
nicely done, but there is something wrong with this lin

pawn Code:
vehicle_odometers[vehid] += DISTANCE( veh_pos[0], veh_pos[1], veh_pos[2], old_veh_pos[vehid][0], old_veh_pos[vehid][1], old_veh_pos[vehid][2]);
Code:
C:\**.pwn(2060) : error 029: invalid expression, assumed zero
C:\**.pwn(2060) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
does that DISTANCE() Func misses ?? or what ?
It's a custom define i have, forgot to add it, however i tweaked the code a bit so ill post it up soon


Re: Need Suggestions With Vehicle Odometer - dowster - 20.09.2011

pawn Code:
public OnVehicleSpawn(vehicleid)
{
    GetVehiclePos(vehicleid, old_veh_pos[vehicleid][0], old_veh_pos[vehicleid][1], old_veh_pos[vehicleid][2]);
    return 1;
}
-----------------------------------------------------------------------------------------------------------
pawn Code:
new Float:old_veh_pos[MAX_VEHICLES + 1][3], Float:vehicle_odometers[MAX_VEHICLES + 1];
public OnPlayerUpdate(playerid)
{
    // I guess it's not a good idea to add a debug option here as it will be spammed every 30ms or something - Famalam
    if(IsPlayerInAnyVehicle(playerid)) {
        if(GetPlayerVehicleSeat(playerid) == 0) {
            new vehid = GetPlayerVehicleID(playerid);
            vehicle_odometers[vehid] += GetPlayerDistanceFromPoint(playerid, old_veh_pos[0], old_veh_pos[1], old_veh_pos[2]);
            GetVehiclePos( vehid, old_veh_pos[0], old_veh_pos[1], old_veh_pos[2]); }}
    return 1;
}
Should work

Edit: i coded this into the AndreasEverything so thats why famalam's comment is in there