Need Suggestions With Vehicle Odometer
#21

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

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

what is the interval ?? 1000 ms ??
Reply
#24

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

danke.
Reply
#26

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

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
Reply
#28

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)