IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

Please post mod releases in the Mod Showroom

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


  Reply to this topicStart new topicStart Poll

 help with a timer

  need help with a timer bar
 
sixace  
Posted: Sunday, Apr 29 2012, 10:49
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Feb 29, 2012

XXXXX



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:

CODE
{$VERSION 3.1.0027}
{$CLEO .cs}

//-------------MAIN---------------
0000: NOP
9@ = 100.0


:NONAME_12
wait 0
if
  Player.Defined(0)
jf @NONAME_213
if and
044B:   actor $PLAYER_ACTOR on_foot
  not Actor.Driving($PLAYER_ACTOR)
jf @NONAME_213

:NONAME_52
wait 0
gosub @NONAME_220

if or
80E1: not player 0 pressed_key 9
00E1:   player 0 pressed_key 8
jf @NONAME_165
if or
80E1:   not player 0 pressed_key 8
00E1:   player 0 pressed_key 9
jf @NONAME_117
jump @NONAME_158

:NONAME_117
9@ += 5.0
if
 9@ > 750.0
jf @NONAME_158
9@ = 749.9

:NONAME_158
jump @NONAME_206

:NONAME_165
9@ -= 5.0
if
 5.0 > 9@
jf @NONAME_206
9@ = 5.0

:NONAME_206
jump @NONAME_52

:NONAME_213
jump @NONAME_12

:NONAME_220
0087: 3@ = 9@ // (float)
3@ /= 750.0
3@ *= 58.0
0087: 10@ = 3@ // (float)
10@ /= 2.0
10@ += 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 10@ 400.0 size 3@ 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.
PM
  Top
 

 
Ashwin the new boy  
Posted: Sunday, Apr 29 2012, 11:00
Quote Post


I am The Most Confused Person
Group Icon
Group: Members
Joined: Nov 14, 2010

ia.gif

XXXXX



use this for timer
CODE
04F7: status_text $8801 0 line 3 'none'

Use 2nd perimeter for toggle Bar & digit
Users WebsitePM
  Top
 

 
sixace  
Posted: Sunday, Apr 29 2012, 12:39
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Feb 29, 2012

XXXXX



QUOTE (Ashwin the new boy @ Sunday, Apr 29 2012, 11:00)
use this for timer
CODE
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.
PM
  Top
 

 
sixace  
Posted: Monday, Apr 30 2012, 05:03
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Feb 29, 2012

XXXXX



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:
CODE
:Status2_1
thread 'STATUS2'
0004: $time1 =  100  // integer values
0004: $time2 = 1000    // integer values
04F7: status_text $time1 type 1 line 1 GXT 'fem_ok' // global_variable  // Score
04F7: status_text $time2 type 0 line 2 GXT 'fem_on' // global_variable  // Score

:Status2_2
wait 0
$time2 -= 1
0084: $time1 = $time2
$time1 /= 10
if
$time2 == 0
jf @Status2_2
0151: remove_status_text $time1
0151: remove_status_text $time2
00BA: show_text_styled GXT 'fem_off' time 1000 style 1
0A93: 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

This post has been edited by sixace on Monday, Apr 30 2012, 05:07
PM
  Top
 

 
Deji  
Posted: Monday, Apr 30 2012, 18:05
Quote Post


Coding like a Rockstar!
Group Icon
Group: Members
Joined: Dec 24, 2007

ja.gif

XXXXX



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

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

 
sixace  
Posted: Monday, Apr 30 2012, 22:35
Quote Post


Player Hater
Group Icon
Group: Members
Joined: Feb 29, 2012

XXXXX



QUOTE (Deji @ Monday, Apr 30 2012, 18:05)
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

This post has been edited by sixace on Monday, Apr 30 2012, 22:50
PM
  Top
 

 
Deji  
Posted: Monday, Apr 30 2012, 23:18
Quote Post


Coding like a Rockstar!
Group Icon
Group: Members
Joined: Dec 24, 2007

ja.gif

XXXXX



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.
Users WebsitePM
  Top
 

 

0 User(s) are reading this topic (0 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG