Jump to content

Draw text with number?


NikkoNinetyFive

Recommended Posts

NikkoNinetyFive

How do I draw text with a number, like let's say "Points: 0"

 

 

0@ = 0045A: draw_text_1number 10.0 10.0 GXT 'POINTS' number 0@

 

 

I try something like that but the game crashes. Do I have to set something in the FXT file?

??? sad.gif

Link to comment
Share on other sites

aStiffSausage

Create .fxt-file, then add there following info:

 

 

ENTRY Text

 

 

ENTRY means the entry that's used by text_draw-opcode and entry can be maximum of 7 charachters. And Text... Just add there what you want, if you want to display numbers, for example the one you said: "Points: 0", then add this: "Points: ~1~". ~1~ is used for game-engine to recognize the place of the number.

 

In this case your .fxt-file should look like this:

 

 

POINTS Points: ~1~

 

 

And before drawing text, remember to enable text_draw with opcode 03F0.

 

Hope this helps you smile.gif

Link to comment
Share on other sites

NikkoNinetyFive

It worked. biggrin.gif

 

I have 1 more question: how do I make the text stay? I'm drawing the text when I press a key, and it just shows and then immediately disappears.

Link to comment
Share on other sites

aStiffSausage

I'm not sure yet, can you show the script, so I can mess around with it? smile.gif

Link to comment
Share on other sites

NikkoNinetyFive

Well, it's going to be a drift counter script, so this is what I've got so far.

 

 

// This file was decompiled using sascm.ini published by Seemann (http://sannybuilder.com/files/SASCM.rar) on 13.10.2007{$VERSION 3.1.0027}{$CLEO .cs}//-------------MAIN---------------03A4: name_thread 'DRIFTCT' :DRIFTCT_110001: wait 0 ms 00D6: if 0256:   player $PLAYER_ACTOR defined 03C0: 0@ = actor $PLAYER_ACTOR car 004D: jump_if_false @DRIFTCT_11 0001: wait 0 ms 0002: jump @DRIFTCT_50 :DRIFTCT_500001: wait 0 ms 00D6: if 0AB0:   key_pressed 85 004D: jump_if_false @DRIFTCT_104 1@ = 1003F0: enable_draw_text 1 01E3: show_text_1number_styled GXT 'DRIFTCT' number 1@ time 5000 style 7 :DRIFTCT_1040001: wait 0 ms0002: jump @DRIFTCT_11

 

 

It's pretty incomplete, as you can see. I just want to know how to make the text stay, the rest I will try to do myself, that's how I learn everything else I know. smile.gif

Edited by NikkoNinetyFive
Link to comment
Share on other sites

aStiffSausage

Add this after opcode 01E3:

 

 

if 0AB0:   key_pressed 85 else_jump @DRIFTCT_55jump @DRIFTCT_104

 

 

You might need to add some wait-commands, otherwise you need to click U faster than you think... biggrin.gif

 

Here's my little script I made, has some notifications about useless waits etc.

 

 

// This file was decompiled using sascm.ini published by Seemann (http://sannybuilder.com/files/SASCM.rar) on 13.10.2007{$VERSION 3.1.0027}{$CLEO .cs}//-------------MAIN---------------03A4: name_thread 'DRIFTCT' :DRIFTCT_110001: wait 0 ms 00D6: if 0256:   player $PLAYER_ACTOR defined00DF:   actor $PLAYER_ACTOR driving // Needed check!  004D: jump_if_false @DRIFTCT_11 03C0: 0@ = actor $PLAYER_ACTOR car // Isn't  a check, moved0001: wait 0 ms // No need for wait0002: jump @DRIFTCT_50 :DRIFTCT_500001: wait 0 ms 00D6: if 0AB0:   key_pressed 85 004D: jump_if_false @DRIFTCT_104 1@ = 1003F0: enable_draw_text 1jump @DRIFTCT_55:DRIFTCT_55wait 0 ms 01E3: show_text_1number_styled GXT 'DRIFTCT' number 1@ time 5 style 7 if 0AB0:   key_pressed 85 else_jump @DRIFTCT_55jump @DRIFTCT_104:DRIFTCT_1040001: wait 0 ms // Wait only needed when loop is made03F0: enable_draw_text 00002: jump @DRIFTCT_11

 

 

Fast tap of U and "Points: 10" is visible smile.gif

Link to comment
Share on other sites

NikkoNinetyFive

Hmm.. got an idea, will be testing it out, I'll post it when I'm done. colgate.gif

 

Edit: Oh god.. so confused blush.gif

 

How about a variable holding a bool that represents if the drift counter is on or off.

When the key U is pressed, set this variable to 1.

When on, do a loop and keep drawing the text every 50ms.

When the key U is pressed again, stop drawing and set the variable to 0.

 

I'm trying to do something like that but.. suicidal.gif !!!

 

 

Ehh isn't it Car.Angle(1@) as that being the car object?

Edited by NikkoNinetyFive
Link to comment
Share on other sites

aStiffSausage
Hmm.. got an idea, will be testing it out, I'll post it when I'm done. colgate.gif

Drift-points-counter sounds really cool, I've thought of making one but I didn't know how to get the angle... Hopefully you'll succeed, good luck smile.gif

Link to comment
Share on other sites

NikkoNinetyFive

I give up. I don't think there's a way to determine it's angle, related to itself and not the map, unless you use some more advanced functions. I've got showing the text there, but not removing so once your press the U key it will show but to remove it close the game.

 

I was going to calculate the points by the car_angle * car_speed, and then crescent that to the total points.. but just too much confusion for me, mostly cause CLEO is very different from other languages that I know. It takes time to get used to, but eh.

 

This is what I've got so far.

 

{$CLEO .cs}03A4: name_thread 'DRIFTCT':DRIFTCT_10001: wait 0 ms$DRIFTCT_STATUS = 000D6: if0256:   player $PLAYER_ACTOR defined00DF:   actor $PLAYER_ACTOR driving004D: jump_if_false @DRIFTCT_10811: 1@ = actor $PLAYER_ACTOR car0001: wait 0 ms0002: jump @DRIFTCT_2:DRIFTCT_20001: wait 0 ms00D6: if0AB0:   key_pressed 85004D: jump_if_false @DRIFTCT_20001: wait 0 ms0002: jump @DRIFTCT_3:DRIFTCT_30001: wait 0 ms2@ = Car.Angle(1@)0092: 3@ = float 3@ to_integer02E3: 4@ = car 1@ speed0092: 5@ = float 4@ to_integer006A: 5@ *= 3@03F0: enabled_text_draw 101E3: show_text_1number_styled GXT 'DRIFTCT' number 5@ time 200 style 70001: wait 200 ms0002: jump @DRIFTCT_3

 

 

The DriftCounter.FXT:

 

 

DRIFTCT Drift Points: ~1~

 

Link to comment
Share on other sites

Just use this.

 

 

0@ = 0045A: draw_text_1number 10.0 10.0 GXT 'NUMBER' number 0@

 

Link to comment
Share on other sites

aStiffSausage

I thought that I would give drift-points-counter a shot, as I think how it should be done...

 

Get angle between the cars angle and the "angle" the car is moving at, North=0 degrees etc, if angle is too low or too high, no points, and too slow speed also won't give you points, and if you hit your car (Lose any health) you'll lose your points. But, how I can get the car-moving-angle?

Link to comment
Share on other sites

Maybe you first should record the car's angle first and then wait for a couple seconds and then find the new one and compare them and if the difference is significant and the speed of the car is great then increase the counter.

Link to comment
Share on other sites

aStiffSausage
Maybe you first should record the car's angle first and then wait for a couple seconds and then find the new one and compare them and if the difference is significant and the speed of the car is great then increase the counter.

True, going to try something like that when I get some free time smile.gif

Link to comment
Share on other sites

 

{$CLEO}0000:var   $PLAYER_ACTOR : Actorend0006:  5@ = 0while true   wait 0   if      $PLAYER_ACTOR.Driving   then        03C0: 0@ = actor $PLAYER_ACTOR car          1@ = Car.Angle(0@)       32@ = 0       while   not 32@ > 700           wait 0           03F0: enable_text_draw 1            045A: draw_text_1number 10.0 10.0 GXT 'NUMBER' number 5@       end       2@ = Car.Angle(0@)        02E3: 3@ = car 0@ speed       0096: make 1@ absolute_float        0096: make 2@ absolute_float        1@ += 10.0       if          0025:  2@ > 1@        then           0013: 3@ *= 0.25           0092: 3@ = float 3@ to_integer            000B: 5@ += 3@       end       03F0: enable_text_draw 1        045A: draw_text_1number 10.0 10.0 GXT 'NUMBER' number 5@   endend

 

Same code I posted on the other thread.

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
  • 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.