sixace Posted April 29, 2012 Share Posted April 29, 2012 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 More sharing options...
Ashwin.Star Posted April 29, 2012 Share Posted April 29, 2012 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 More sharing options...
sixace Posted April 29, 2012 Author Share Posted April 29, 2012 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 More sharing options...
sixace Posted April 30, 2012 Author Share Posted April 30, 2012 (edited) 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. Edited April 30, 2012 by sixace Link to comment Share on other sites More sharing options...
Deji Posted April 30, 2012 Share Posted April 30, 2012 Global variables not defined in CustomVariables.ini are evil, stay away. Use this method instead: http://sannybuilder.com/forums/viewtopic.php?pid=9135#p9135 Link to comment Share on other sites More sharing options...
sixace Posted April 30, 2012 Author Share Posted April 30, 2012 (edited) 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? 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. Edited April 30, 2012 by sixace Link to comment Share on other sites More sharing options...
Deji Posted April 30, 2012 Share Posted April 30, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now