CLEO Help vehicle speed

CLEO related
Status
Not open for further replies.

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
Code:
{$CLEO .cs}
0000: ajom's speed informer

:mainloop
wait 0
if 0449: actor $PLAYER_ACTOR in_a_car
jf @mainloop

03C0: 0@ = actor $PLAYER_ACTOR car
02E3: 1@ = car 0@ speed
0AD0: show_formatted_text_lowpriority "~y~My Car Speed: ~g~%f" time 100 1@
jump @mainloop
This script can be furtherly improved if you try coding it yourself.
 
Last edited:

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
hi, i don't know why but this code doesn't work. when I run gta the game hits me and nothing more, it should have been added that I have version 0.3.7
Script Header updated. Try recompiling it again...

Also that script works on both single player and any Samp version
 

_Safa

Well-known member
Joined
Sep 22, 2019
Messages
294
Reaction score
99
Location
UGBASE
C++:
{$CLEO}
0000:

WAIT 10000

WHILE TRUE
WAIT 0

IF 0449: $PLAYER_ACTOR
THEN
            03C0: 0@ = $PLAYER_ACTOR
            02E3: 1@ = 0@
            printf "Speed: %f" 1000 1@
END
END

Try this (untested obviously). Should be printed as a float as its returns the speed. Also not to forget is low-level-syntax pretty ugly to read & write. You better stick to high-level.
 

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
it doesn't fall anymore but the variable doesn't work, only D writes it, not speed
It Seems like you did not configured sanny builder's Encoder properly. Refer to this link and Follow its Instruction on configuring sanny builder settings properly.

C++:
printf "Speed: %f" 1000 1@
Oh my mistake, Script updated.
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,113
Solutions
5
Reaction score
878
Location
Lithuania
Based on some testing .., difference between cleo speed and server are:
4 x cleo speed = server speedometer value
But it could be less than 4 depends on server

PHP:
{$CLEO .cs}

0000:

wait 5000

while true
wait 0

if
Actor.Driving($PLAYER_ACTOR)
then
0@ = Actor.CurrentCar($PLAYER_ACTOR)
02E3: 5@ = car 0@ speed
5@ *= 4.0
0AD1: show_formatted_text_highpriority "Speed: %f" time 2000  5@
end

end



To make code work only when you are in driver seat you can use this snippet.
PHP:
:IsActorInDriverSeat
{
    USE WITH >> IF STATEMENT:
    0AB1: @IsActorInDriverSeat 0
}
if
00DF:   actor $PLAYER_ACTOR in_car
then
    03C0: 0@ = actor $PLAYER_ACTOR car
    046C: 1@ = car 0@ driver
    if
    003B: 1@ == $PLAYER_ACTOR
    then
        0485:  return_true
    else
        059A:  return_false
    end
end
0AB2: ret 0
 
Last edited:

ajom

Well-known member
Joined
Apr 14, 2020
Messages
389
Solutions
2
Reaction score
268
Location
Pluto
Based on some testing .., difference between cleo speed and server are:
4 x cleo speed = server speedometer value
But it could be less than 4 depends on server

Also, cleo speed is also affected by your framerate, FPS higher than 50 will give higher speed reading rather than the right speed,and vice versa... I accurately compute speed using this formula:
Normalized Speed = Sqrt( (Vx*50/FPS)^2 + (Vy*50/FPS)^2 + (Vz*50/FPS)^2 )

In cleo:
Code:
03C0: 0@ = actor $PLAYER_ACTOR car
06A2: get_car 0@ velocity_in_direction_XYZ 1@ 2@ 3@
0A8D: 4@ = readMem 0xB7CB5C size 4 vp 0 // get average frame time, aka average framerate(FPS/50) over the last 60 seconds

0073: 1@ /= 4@ // (float) // normalized Vx
0073: 2@ /= 4@ // (float) // normalized Vy
0073: 3@ /= 4@ // (float) // normalized Vz

    // magnitude of velocities(vector)
006B: 1@ *= 1@ // (float) // Vx^2
006B: 2@ *= 2@ // (float) // Vy^2
006B: 3@ *= 3@ // (float) // Vz^2

005B: 1@ += 2@ // (float)
005B: 1@ += 3@ // (float)
0AEE: 1@ = 1@ exp 0.5 // normalized speed(scalar)
    //

Although this is only necessary if you really want to accurately compute the exact speed of the car.

Although I'm not sure about the server car speed = cleo car speed * 4 thing if this was really a rule... I have'nt considered those on my timer,speed,velocity normalizers...
 

_Safa

Well-known member
Joined
Sep 22, 2019
Messages
294
Reaction score
99
Location
UGBASE
The server speed = engine-speed * 4 doesn't make sense and is not an consistent thing. Every server handles their velocitys divisions differently.
 

Parazitas

God
Joined
Jan 2, 2017
Messages
3,113
Solutions
5
Reaction score
878
Location
Lithuania
The server speed = engine-speed * 4 doesn't make sense and is not an consistent thing. Every server handles their velocitys divisions differently.
Well it worked on my server when i played samp one year before.
Now i just coming visit with my phone to see what going on here xD
 
Last edited:
Status
Not open for further replies.
Top