CLEO Help Getting Car Speed

CLEO related
Status
Not open for further replies.

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
So I've been trying to get the car's speed in order to make a limiter, if that makes sense, although it doesn't work and i dont really find the mistake.. Can someone help please?
Code:
0AF0: 5@ = get_int_from_ini_file "cleo\ServerCMD.ini" section "AntiTicket" key "states"
    0AF0: 7@ = get_int_from_ini_file "cleo\ServerCMD.ini" section "AntiTicket" key "state"
    if 7@ == 2
           then
           if and
           5@ == 1
           00DF:   actor $PLAYER_ACTOR driving
           then
                if 00D9: 0@ = actor $PLAYER_ACTOR car
                then
                    02E3: 15@ = car 0@ speed
                    if 15@ > 100.0
                    then
                        chatmsg "100" -1
                    else
                        if and
                        5@ == 2
                        00DF:   actor $PLAYER_ACTOR driving
                        then
                            if 00D9: 0@ = actor $PLAYER_ACTOR car
                            then
                                02E3: 15@ = car 0@ speed
                                if 15@ > 150.0
                                then
                                    chatmsg "150" -1
                                else
                                    if and
                                    5@ == 0
                                    00DF:   actor $PLAYER_ACTOR driving
                                    then
                                        chatmsg "{e3336d}[AntiTicket]: {ff0000}(!) Warning (!)" -1
                                        chatmsg "{e3336d}[AntiTicket]: {ff0000}Speed limit has not been set." -1
                                        wait 1000
                                        chatmsg "{e3336d}[AntiTicket]: {a1a1a1}Use /speed <1 - 2> to set the speed limit." -1
                                        chatmsg "{e3336d}[AntiTicket]: {a1a1a1}1 = 100km/h || 2 = 150km/h" -1
                                    end
                                end
                            end
                        end
                    end
                end
            end
        end
 

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
02E3: returns you a strange value, I don't really know how it was made ... but if you have 100 km/h, 02E3: will return you a value like 50.0 and if you have 200 KM/h, it will return you 55.0, so what's the point of this shitty opcode?

Just print your current car speed and you will see how strange it reacts.

What can you do is to check the value which opcode gives you when you achieve the wanted speed limit ... and compore with that value instead of 100.0 / 150.0
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Cleo code never get same car speed like your server... , you must do some test to check which speed is same like your server.
Use logger
PHP:
if
00DF:   actor $PLAYER_ACTOR driving
then
    03C0: 0@ = actor $PLAYER_ACTOR car
    02E3: 1@ = car 0@ speed
    0AD1: "%f" 1337 1@
end
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Cleo code never get same car speed like your server... , you must do some test to check which speed is same like your server.
Use logger
PHP:
if
00DF:   actor $PLAYER_ACTOR driving
then
    03C0: 0@ = actor $PLAYER_ACTOR car
    02E3: 1@ = car 0@ speed
    0AD1: "%f" 1337 1@
end

Can you exaplain a bit more what this "logger" does? Just so I know because from 02E3: 1@ = car 0@ speed I am getting a bit confused. What is opcode 0AD1, what does it do, what is %f and what is the 1337 for? I get the 1@ is the car speed, but the rest?
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
Can you exaplain a bit more what this "logger" does? Just so I know because from 02E3: 1@ = car 0@ speed I am getting a bit confused. What is opcode 0AD1, what does it do, what is %f and what is the 1337 for? I get the 1@ is the car speed, but the rest?
Logger - is what you get when use it for testing .
0AD1: - is hight formated text opcode which show your text.
1337 is timer how long you wanna see that text .
Have more questions?
 

KamikazeSripterul

Well-known member
Joined
Jun 30, 2019
Messages
353
Reaction score
23
Yeah.. If i'd use that "logger" in my script. How will it help and how do I need to use it. I'm sorry but I don't quite get it... If I put that script it will check the speed of my car on the server?
 

Parazitas

God
Staff member
Joined
Jan 2, 2017
Messages
3,315
Solutions
7
Reaction score
935
Location
Lithuania
This is how it looks.
Server show my speed - 182
But cleo code show - 45
PHP:
{$CLEO .cs}

0000: NOP

wait 10000

while true
wait 0

if
00DF:   actor $PLAYER_ACTOR driving
then
    03C0: 0@ = actor $PLAYER_ACTOR car
    02E3: 1@ = car 0@ speed
    0AD1: "%f" 1337 1@
end

end

When you know car speed you should use like:
PHP:
{$CLEO .cs}

0000: NOP

wait 10000

while true
wait 0

if
00DF:   actor $PLAYER_ACTOR driving
then
    03C0: 0@ = actor $PLAYER_ACTOR car
    02E3: 1@ = car 0@ speed
    if
    1@ >= 20.0
    then
        0AD1: "My speed more than 20 by cleo" 1337 
    end
end

end
 

Attachments

  • sa-mp-000.png
    sa-mp-000.png
    627.1 KB · Views: 17
Status
Not open for further replies.
Top