Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Criminal Enterprises
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

*DO NOT* SHARE MEDIA OR LINKS TO LEAKED COPYRIGHTED MATERIAL. Discussion is allowed.

[SA] any chronometer or timer script?


Mysterdogg
 Share

Recommended Posts

Hello everyone, I'm looking for a mod that could bring me a chronometer in-game. I'm currently working with some handling data lines and it's a bit inconvenient to use my phone to mark the times. If anyone can help me out finding the mod or even making it I'll be really pleased. 

 

Nothing too fancy, please. I need something basic.

Edited by Mysterdogg
Link to comment
Share on other sites

something like this?

press T and M together to enable chronometer

press G to start timer

press H to stop timer

press Backspace to quit chronometer

 

{$CLEO .cs}
:Chronometer
thread 'TIMERCH'

while true
    wait 0
    if and
        0AB0:   key_pressed 84// 	t key          ENABLE CHRONOMETER
        0AB0:   key_pressed 77// 	m key
    then
        
        repeat
            wait 0
            03F0: enable_text_draw 1
            045A: text_draw_1number  30.0  300.0 'NUMBER' 00    // value
            045A: text_draw_1number  60.0  300.0 'NUMBER' 00    // value         
            045A: text_draw_1number  100.0  300.0 'NUMBER' 0000    // value
            
        until  0AB0:   key_pressed 71// 	g key      START TIMER
         
        0@ = 0
        1@ = 0
        33@ = 0
        
        repeat
            wait 0
            if
                33@ >= 1000
            then
                0@ += 1
                33@ = 0
            end
            if
                0@ >= 60
            then
                1@ += 1
                0@ = 0
            end         
            0085: 3@ = 33@
            03F0: enable_text_draw 1
            045A: text_draw_1number  30.0  300.0 'NUMBER' 1@    // value
            045A: text_draw_1number  60.0  300.0 'NUMBER' 0@    // value         
            045A: text_draw_1number  100.0  300.0 'NUMBER' 33@    // value
         
        until  0AB0:   key_pressed 72// 	h key      STOP TIMER
         
         
         repeat
            wait 0
            03F0: enable_text_draw 1
            045A: text_draw_1number  30.0  300.0 'NUMBER' 1@    // value
            045A: text_draw_1number  60.0  300.0 'NUMBER' 0@    // value         
            045A: text_draw_1number  100.0  300.0 'NUMBER' 3@    // value
         until  0AB0:   key_pressed 8// key = Backspace   QUIT CHRONOMETER
         
                  
     

    end
end

 

Link to comment
Share on other sites

Spoiler
1 hour ago, ZAZ said:

something like this?

press T and M together to enable chronometer

press G to start timer

press H to stop timer

press Backspace to quit chronometer

2
{$CLEO .cs}
:Chronometer
thread 'TIMERCH'

while true
    wait 0
    if and
        0AB0:   key_pressed 84// 	t key          ENABLE CHRONOMETER
        0AB0:   key_pressed 77// 	m key
    then
        
        repeat
            wait 0
            03F0: enable_text_draw 1
            045A: text_draw_1number  30.0  300.0 'NUMBER' 00    // value
            045A: text_draw_1number  60.0  300.0 'NUMBER' 00    // value         
            045A: text_draw_1number  100.0  300.0 'NUMBER' 0000    // value
            
        until  0AB0:   key_pressed 71// 	g key      START TIMER
         
        0@ = 0
        1@ = 0
        33@ = 0
        
        repeat
            wait 0
            if
                33@ >= 1000
            then
                0@ += 1
                33@ = 0
            end
            if
                0@ >= 60
            then
                1@ += 1
                0@ = 0
            end         
            0085: 3@ = 33@
            03F0: enable_text_draw 1
            045A: text_draw_1number  30.0  300.0 'NUMBER' 1@    // value
            045A: text_draw_1number  60.0  300.0 'NUMBER' 0@    // value         
            045A: text_draw_1number  100.0  300.0 'NUMBER' 33@    // value
         
        until  0AB0:   key_pressed 72// 	h key      STOP TIMER
         
         
         repeat
            wait 0
            03F0: enable_text_draw 1
            045A: text_draw_1number  30.0  300.0 'NUMBER' 1@    // value
            045A: text_draw_1number  60.0  300.0 'NUMBER' 0@    // value         
            045A: text_draw_1number  100.0  300.0 'NUMBER' 3@    // value
         until  0AB0:   key_pressed 8// key = Backspace   QUIT CHRONOMETER
         
                  
     

    end
end

 

 

 

Thanks, Zaz! it worked just how I wanted! but could it be possible to set a specific speed as the stopper? for example 60 mp/h (100 km/h).

Edited by Mysterdogg
Link to comment
Share on other sites

5 minutes ago, ZAZ said:

You mean, if car reaches a specific speed, then stop timer? 

That's right, that's just what I said. ;) Could that be possible? I did a (really) quick check of the opcodes but couldn't figure out how to do it. 

Link to comment
Share on other sites

Ok, now Chronometer only works if CJ is driving a vehicle
So get into a vehicle, press T and M together to enable chronometer

press G to start timer

Specified speed stops timer or press H to stop timer

press R to reset timer

press Backspace or leave vehicle to quit chronometer

var [email protected] is speed output of vehicle
this is the current speedcheck to stop timer:

6@ >= 45.0

I don't know if speed output is equal to km/h or miles/h or whatever
So you can use the 2nd speed out put and multiplicate it with your own multiplicator to display a real speed value in 3.row

0085: 8@ = 6@
8@ *= 1.2                    // 2nd speed output by multiplicator
0092: 8@ = float_to_integer 8@// convert 2nd speed output into integer

Also, it needs to convert float from speed output into integer for displaying

The display:
1. row = timer
2. row = speed output
3. row = 2nd speed output by multiplicator

 

{$CLEO .cs}
:Chronometer
thread 'TIMERCH'

while true
    wait 0

    if
        0256:   player $PLAYER_CHAR defined
    then
    
        if and
            00DF:   actor $PLAYER_ACTOR driving
            0AB0:   key_pressed 84// 	t key          ENABLE CHRONOMETER
            0AB0:   key_pressed 77// 	m key
        then    

            0@ = 0
            1@ = 0
            33@ = 0
            4@ = 0            
            03C0: 5@ = actor $PLAYER_ACTOR car 

            while  0256:   player $PLAYER_CHAR defined
                wait 0
                if or
                    80DF: not  actor $PLAYER_ACTOR driving
                    0119:   car 5@ wrecked
                    0AB0:   key_pressed 8// key = Backspace   QUIT CHRONOMETER
                then
                    break
                end
                02E3: 6@ = car 5@ speed // ----------- [email protected] = speed output

                if  and
                    4@ == 0
                    0AB0:   key_pressed 71// 	G key      START TIMER
                then
                    4@ = 1
                end
                if
                    4@ == 1
                then
                    if or
                        6@ >= 45.0             //   -------------------------- SPECIFIED SPEED TO STOP TIMER
                        0AB0:   key_pressed 72// 	H key      STOP TIMER
                    then
                        018C: play_sound  1056  at  0.0 0.0 0.0
                        4@ = 2
                    end
                end
                if and
                    4@ == 2
                    0AB0:   key_pressed 82// 	R key  RESET TIMER
                then
                    0@ = 0
                    1@ = 0
                    33@ = 0
                    4@ = 0
                end
                if
                    4@ == 0
                then
                    03F0: enable_text_draw 1
                    045A: text_draw_1number  30.0  250.0 'NUMBER' 00    // 
                    045A: text_draw_1number  60.0  250.0 'NUMBER' 00    //          
                    045A: text_draw_1number  100.0  250.0 'NUMBER' 0000    // 
                    045A: text_draw_1number  100.0  280.0 'NUMBER' 0    // 
                    045A: text_draw_1number  100.0  290.0 'NUMBER' 0    // 
                end
                if
                    4@ == 1
                then
                    if
                        33@ >= 1000
                    then
                        0@ += 1
                        33@ = 0
                    end
                    if
                        0@ >= 60
                    then
                        1@ += 1
                        0@ = 0
                    end                    
                    0085: 3@ = 33@
                    0092: 7@ = float_to_integer 6@// convert speed output into integer
                    
                    0085: 8@ = 6@
                    8@ *= 1.2                    // 2nd speed output by multiplicator
                    0092: 8@ = float_to_integer 8@// convert 2nd speed output into integer
                    
                    03F0: enable_text_draw 1
                    045A: text_draw_1number  30.0  250.0 'NUMBER' 1@    // minutes
                    045A: text_draw_1number  60.0  250.0 'NUMBER' 0@    // seconds         
                    045A: text_draw_1number  100.0  250.0 'NUMBER' 33@    // milliseconds
                    045A: text_draw_1number  100.0  280.0 'NUMBER' 7@    // speed output
                    045A: text_draw_1number  100.0  290.0 'NUMBER' 8@    // 2nd speed output
                end
                if
                    4@ == 2
                then
                    03F0: enable_text_draw 1
                    045A: text_draw_1number  30.0  250.0 'NUMBER' 1@    // minutes
                    045A: text_draw_1number  60.0  250.0 'NUMBER' 0@    // seconds         
                    045A: text_draw_1number  100.0  250.0 'NUMBER' 3@    // milliseconds
                    045A: text_draw_1number  100.0  280.0 'NUMBER' 7@    // speed output
                    045A: text_draw_1number  100.0  290.0 'NUMBER' 8@    // 2nd speed output
                end
                                


            end

        end
    end

end

 

Link to comment
Share on other sites

1 hour ago, ZAZ said:

 

6@ >= 45.0

I don't know if speed output is equal to km/h or miles/h or whatever
So you can use the 2nd speed output and multiplicate it with your own multiplicator to display a real speed value in 3.row

1

Well, I've checked and tested the script a few times and it seems like it's a multiplier (apparently, an x4 factor), the default number, 45, equals to something close to 160 km/h in-game. I tried to set it as close to 100km/h (60 mp/h) as possible but it's still a bit ambiguous. But don't take me wrong, I'm really glad you're helping me with this. I just want a precise way to calculate the acceleration in order to corroborate my handling data edition.

Link to comment
Share on other sites

Thanks, Zaz! it works better now but I will see if I can improve it in any way, hope you don't mind if I use the script as a base.

Link to comment
Share on other sites

On 10/1/2018 at 3:12 PM, Mysterdogg said:

Well, I've checked and tested the script a few times and it seems like it's a multiplier (apparently, an x4 factor), the default number, 45, equals to something close to 160 km/h in-game. I tried to set it as close to 100km/h (60 mp/h) as possible but it's still a bit ambiguous. But don't take me wrong, I'm really glad you're helping me with this. I just want a precise way to calculate the acceleration in order to corroborate my handling data edition.

My test code from this video

{$cleo}
0000:

while true
    wait 0
    00DF:   actor $player_actor driving
    jf continue
    0@ = actor.CurrentCar($player_actor)
    0AB1: call_scm_func @getspeed 1 0@ -> 1@
    0AD1: show_formatted_text_highpriority "%3.f" time 2000 1@
end

:getspeed
0A97: 1@ = car 0@ struct

// get wheels rotation speed
0A8E: 14@ = 1@ + 0x848
0A8D: 21@ = read_memory 14@ size 4 virtual_protect 0   
14@ += 0x4
0A8D: 22@ = read_memory 14@ size 4 virtual_protect 0    
14@ += 0x4
0A8D: 23@ = read_memory 14@ size 4 virtual_protect 0  
14@ += 0x4
0A8D: 24@ = read_memory 14@ size 4 virtual_protect 0    
 
// mult by wheel size       
0441: 12@ = car 0@ model  
0AA7: call_function 0x00403DA0 num_params 1 pop 1 iId 12@ pclInfo 12@ //get CVehicleModelInfo
12@ += 0x40    
0A8D: 15@ = read_memory 12@ size 4 virtual_protect 0
006B: 21@ *= 15@                                    
006B: 22@ *= 15@
12@ += 0x4
0A8D: 15@ = read_memory 12@ size 4 virtual_protect 0
006B: 23@ *= 15@                                      
006B: 24@ *= 15@

005B: 21@ += 22@ 
005B: 21@ += 23@
005B: 21@ += 24@ 
21@ /= 4.0  

21@ /= 2.45 // tweak based on distance
21@ *= -227.0 // fix km/h (???)
0AB2: ret 1 21@

The "problem" is that it's based on wheel rotation, but I think it will not interfere with your goal, just be careful with the low speeds, because when you accelerate abruptly the wheel turns very fast and will show a high speed (around 30 km/h, it vary)

Link to comment
Share on other sites

I added an easy way to get VehFuncs speed calculation:

{$cleo}

const
    pVehFuncs = [email protected]
    pGetVehicleSpeedRealistic = [email protected]
    
    hVeh = [email protected]
    pVeh = [email protected]
    fSpeed = [email protected]
end

if 0AA2: pVehFuncs = load_library "VehFuncs.asi"
then
    0AA4: pGetVehicleSpeedRealistic = get_proc_address "Ext_GetVehicleSpeedRealistic" library pVehFuncs
    0AA3: free_library pVehFuncs
end

if not pGetVehicleSpeedRealistic > 0
then
    0ACD: show_text_highpriority "~r~Fail to load 'VehFuncs.asi'" time 5000
    0A93: end_custom_thread
end

while true
    wait 0
    00DF:   actor $player_actor driving
    jf continue
    hVeh = actor.CurrentCar($player_actor)
    0A97: pVeh = car hVeh struct
    0AA7: call_function_return pGetVehicleSpeedRealistic num_params 1 pop 1 pVeh -> fSpeed
    0AD1: show_formatted_text_highpriority "Speed: ~y~%.3f" time 2000 fSpeed
end

You need this new version.

Link to comment
Share on other sites

Spoiler
28 minutes ago, Junior_Djjr said:

I added an easy way to get VehFuncs speed calculation:


{$cleo}

const
    pVehFuncs = [email protected]
    pGetVehicleSpeedRealistic = [email protected]
    
    hVeh = [email protected]
    pVeh = [email protected]
    fSpeed = [email protected]
end

if 0AA2: pVehFuncs = load_library "VehFuncs.asi"
then
    0AA4: pGetVehicleSpeedRealistic = get_proc_address "Ext_GetVehicleSpeedRealistic" library pVehFuncs
    0AA3: free_library pVehFuncs
end

if not pGetVehicleSpeedRealistic > 0
then
    0ACD: show_text_highpriority "~r~Fail to load 'VehFuncs.asi'" time 5000
    0A93: end_custom_thread
end

while true
    wait 0
    00DF:   actor $player_actor driving
    jf continue
    hVeh = actor.CurrentCar($player_actor)
    0A97: pVeh = car hVeh struct
    0AA7: call_function_return pGetVehicleSpeedRealistic num_params 1 pop 1 pVeh -> fSpeed
    0AD1: show_formatted_text_highpriority "Speed: ~y~%.3f" time 2000 fSpeed
end

You need this new version.

 

 

I don't know if I'm doing something wrong but seems like the script doesn't work properly or don't even work. I've checked deleting the .asi file and the script didn't generate the error message in-game.

Link to comment
Share on other sites

18 hours ago, Mysterdogg said:
  Reveal hidden contents

 

 

I don't know if I'm doing something wrong but seems like the script doesn't work properly or don't even work. I've checked deleting the .asi file and the script didn't generate the error message in-game.

Impossible, the only explanation is that the script is not even active (see cleo.log)

Link to comment
Share on other sites

8 hours ago, Junior_Djjr said:

Impossible, the only explanation is that the script is not even active (see cleo.log)

I've checked it every time I try to use it but, surprisedly, the script is loaded. I will see if I'm doing everything right but if I'm not wrong, the only thing I must do is to get in a car, right? that's what the script says unless I'm skipping a code line.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.