Need Suggestions With Vehicle Odometer
#1

anny suggestions / ideas / scripts ? :P repping too
Reply
#2

By getting vehicle speed (with speedometer FS or make it by your own) you can calculate it (But not accurate I think).
Reply
#3

im using that classic style
pawn Code:
GetVehicleSpeed(vehicleid);
but i need little bit more explain :P

i have thinked about that style but my brainz are still dumped lol
Reply
#4

Can you post that function? It probably just returns the speed in a float value.
Reply
#5

ya i use that way

pawn Code:
Float:GetVehicleSpeed(vehicleid)
{
  new
    Float:vX,
    Float:vY,
    Float:vZ;
  GetVehicleVelocity(vehicleid, vX, vY, vZ);
  return floatsqroot(vX*vX + vY*vY + vZ*vZ);
}
and sometimes this way xD

pawn Code:
stock SpeedVehicle(playerid)
{
    new Float:ST[4];
    if(IsPlayerInAnyVehicle(playerid))
    GetVehicleVelocity(GetPlayerVehicleID(playerid),ST[0],ST[1],ST[2]);
    else GetPlayerVelocity(playerid,ST[0],ST[1],ST[2]);
    ST[3] = floatsqroot(floatpower(floatabs(ST[0]), 2.0) + floatpower(floatabs(ST[1]), 2.0) + floatpower(floatabs(ST[2]), 2.0)) * 180.3;
    return floatround(ST[3]);
}
i think the second one is easier or what ?
Reply
#6

Quote:
Originally Posted by [HiC]TheKiller
View Post
Can you post that function? It probably just returns the speed in a float value.
can you help me then :P?
Reply
#7

pawn Code:
OnPlayerUpdate(playerid)
{
    if(IsPlayerInAnyVehicle(playerid)) {
        if(GetPlayerVehicleSeat(playerid) == 0) {
            new Float:veh_pos[3], vehid = GetPlayerVehicleID(playerid);
            static Float:old_veh_pos[MAX_VEHICLES + 1][3], Float:vehicle_odometers[MAX_VEHICLES + 1];
            GetVehiclePos( vehid, veh_pos[0], veh_pos[1], veh_pos[2]);
            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]);
            old_veh_pos[vehid][0] = veh_pos[0];
            old_veh_pos[vehid][1] = veh_pos[1];
            old_veh_pos[vehid][2] = veh_pos[2];
        }
    }
    return 1;
}
Untested, i coded it in the input box.
Reply
#8

it seems a hard code one but thanks
Reply
#9

does that DISTANCE() Func misses ?? or what ?
Reply
#10

okay fixed code a little bit , can some one help me to forward :P?
Reply
#11

Easiest solution:
https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint
Reply
#12

Quote:
Originally Posted by Shetch
View Post
but this function wasn't found..

Code:
C:\**.pwn(2085) : error 017: undefined symbol "GetPlayerDistanceFromPoint"
Reply
#13

It's R5 function. Upgrade your samp server.

EIDTebug your veriable
pawn Code:
printf("%f",vehicle_odometers[vehid]);
Make sure you set that variable Float
pawn Code:
new Float:vehicle_odometers[MAX_VEHICLES];
Reply
#14

The most effective way is to run a frequent timer (Every .5-1 second) and calculate the distance between the vehicles last point and it's point now.

But it's extremely intensive, especially on a server with hundreds if not thousands of vehicles.
Reply
#15

okay. already got it
Reply
#16

https://sampforum.blast.hk/showthread.php?tid=271586
Reply
#17

still zero. result:
when i use GetPlayerDistance then i have to use Player cordinates too ??
Reply
#18

i just have replaced the GetVehiclePos With GetPlayerPos and the result is impressive:
and the amound increases when i stand in one place.
Reply
#19

Player current coordinate and player old coordinate.
Reply
#20

pawn Code:
new Float:a

a += GetPlayerDistanceFromPoint(playerid,playerx[playerid],playery[playerid],playerz[playerid]);
GetPlayerPos(playerid,playerx[playerid],playery[playerid],playerz[playerid]);
Ups, didn't mean to double post.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)