Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      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

help with a timer


sixace
 Share

Recommended Posts

Hello everyone.

 

I created this mod with a timer that uses 014E, so it uses global variable and gives me the generic number countdown display on screen. It works nicely, though i thought the number countdown display was kinda lame, so i thought it would be cool to use a status bar to show timer progress instead of the numbers.

 

So in my search i found this:

 

 

{$VERSION 3.1.0027}{$CLEO .cs}//-------------MAIN---------------0000: NOP [email protected] = 100.0 :NONAME_12wait 0 if   Player.Defined(0)jf @NONAME_213 if and044B:   actor $PLAYER_ACTOR on_foot   not Actor.Driving($PLAYER_ACTOR)jf @NONAME_213 :NONAME_52wait 0 gosub @NONAME_220 if or80E1: not player 0 pressed_key 900E1:   player 0 pressed_key 8 jf @NONAME_165 if or80E1:   not player 0 pressed_key 8 00E1:   player 0 pressed_key 9 jf @NONAME_117 jump @NONAME_158 :[email protected] += 5.0 if  [email protected] > 750.0 jf @NONAME_158 [email protected] = 749.9 :NONAME_158jump @NONAME_206 :[email protected] -= 5.0 if  5.0 > [email protected] jf @NONAME_206 [email protected] = 5.0 :NONAME_206jump @NONAME_52 :NONAME_213jump @NONAME_12 :NONAME_2200087: [email protected] = [email protected] // (float) [email protected] /= 750.0 [email protected] *= 58.0 0087: [email protected] = [email protected] // (float) [email protected] /= 2.0 [email protected] += 547.6 03F0: enable_text_draw 1 038E: draw_box_position 576.6 400.0 size 62.0 8.0 RGBA 0 0 0 255 038E: draw_box_position 576.6 400.0 size 58.0 5.1 RGBA 255 255 255 255 038E: draw_box_position [email protected] 400.0 size [email protected] 5.0 RGBA 255 0 0 255 return 

 

 

I like how the bar looks and it's position, so i wanted to use it (i don't need the key presses though). My question is, how can i make the bar work with a timer (instead of the key presses ) where the bar decreases as the timer counts down? And if possible, how can i make a variable timer where whether the timer is set for 1 minute or 10 minutes, the bar will display the countdown correctly? I hope someone can point me to the right direction. Still learning my way around cleo. Many thanks in advance.

 

Link to comment
Share on other sites

Ashwin.Star

use this for timer

 

04F7: status_text $8801 0 line 3 'none'

 

Use 2nd perimeter for toggle Bar & digit

Link to comment
Share on other sites

use this for timer

 

04F7: status_text $8801 0 line 3 'none'

 

Use 2nd perimeter for toggle Bar & digit

Using what you gave me as it is (with a "0") gave me a number countdown like i already have.

Toggling the second parameter as you said "0" to "1" does not give me a display at all. Or did i misunderstand? Thanks for the reply btw.

Link to comment
Share on other sites

Ok my bad...i didn't realize my stalker hud mod was messing with the bar display.

 

Anyway, thanks for the tip, i got it working somewhat...

 

I understand that i have to use integers to properly display the bar. My question is how to make the time variable yet still display on the bar correctly?

 

i'll use ZAZ's example:

 

:Status2_1thread 'STATUS2'0004: $time1 =  100  // integer values0004: $time2 = 1000    // integer values04F7: status_text $time1 type 1 line 1 GXT 'fem_ok' // global_variable  // Score04F7: status_text $time2 type 0 line 2 GXT 'fem_on' // global_variable  // Score:Status2_2wait 0$time2 -= 10084: $time1 = $time2$time1 /= 10if$time2 == 0jf @Status2_20151: remove_status_text $time10151: remove_status_text $time200BA: show_text_styled GXT 'fem_off' time 1000 style 10A93: end_custom_thread

 

 

In the above example, if i change the value of $time2 to say 500, then i only get half a bar to start with. How can i make it so regardless of the value of time2, the bar will display it correctly? I can't seem to get my brain wrapped on the computation. suicidal.gif

Edited by sixace
Link to comment
Share on other sites

 

Global variables not defined in CustomVariables.ini are evil, stay away.

 

Use this method instead: http://sannybuilder.com/forums/viewtopic.php?pid=9135#p9135

Thanks for the reply Deji.

 

I appreciate the link, i will try and wrap my head around it. I'm still a novice scripter and that looks pretty advanced for what i already know. Going to that link made me feel like i opened my learning book to chapter 30...i'm still on chapter 5. You know what i mean? biggrin.gif

 

Though i understand what you mean by staying away from global variables, i'm still just in the process of understanding how a basic variable timer can be displayed on a statusbar correctly instead of a number countdown. Global or not, i just want to see how it's put together so i can understand it. Or if it is even possible in the first place, I have yet to see a working example of it though i'm still searching around. I don't really want to divert too far from what i am trying to learn (that's like putting more food on my plate than i can eat at this moment).

 

If someone could give me an example of this using 04F7 that would really help a lot..

 

It just amazes me how easy i can implement a variable 014E timer with a couple lines, though i didn't realize wanting to display the number countdown in a statusbar instead might actually end up being more complicated than the script i am making it for. I'm getting this feeling that my idea is faaaaaar from being simple. sarcasm.gif

Edited by sixace
Link to comment
Share on other sites

04F7 and 014E both only support global variables (R* decided to implement this command in a pretty weird way). The only way to use the built-in timer and counter functions with local variables is through the link I posted.

 

Alternatively, you could just create something that looks like a timer/counter using text draw (some stuff about that here and a long way down here - and of course, the Draw category of the OpcodeDB contains a lot of text draw related opcodes). It requires quite a bit of math to do correctly, though.

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.