habinabi
Active member
hi, i need a script to find out the speed of the vehicle.
{$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
Script Header updated. Try recompiling it again...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
{$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
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.it doesn't fall anymore but the variable doesn't work, only D writes it, not speed
Oh my mistake, Script updated.C++:printf "Speed: %f" 1000 1@
{$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
: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
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
Normalized Speed = Sqrt( (Vx*50/FPS)^2 + (Vy*50/FPS)^2 + (Vz*50/FPS)^2 )
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)
//
Well it worked on my server when i played samp one year before.The server speed = engine-speed * 4 doesn't make sense and is not an consistent thing. Every server handles their velocitys divisions differently.