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.

Any way to get float's whole part in CLEO?


firedihm
 Share

Recommended Posts

looks like I can write float to file with 0AF3: and then read it as int from same file with 0AF0:. Maybe there is a better solution? Creating a file just to read one float feels redundant

Edited by firedihm
Link to comment
Share on other sites

If you just want to convert float to int use this method:
scm:

[email protected] = 0.0;   //  float
008C: [email protected] = float_to_integer [email protected]  //  [email protected] is int

c++:

float var0 = 0.0f;
int var1 = static_cast<int>(var0);   

 

Link to comment
Share on other sites

31 minutes ago, Jack said:

If you just want to convert float to int use this method:
scm:

[email protected] = 0.0;   //  float
008C: [email protected] = float_to_integer [email protected]  //  [email protected] is int

c++:

float var0 = 0.0f;
int var1 = static_cast<int>(var0);   

 

Wow, I swear I checked through opcodes .ini several times. How could I miss this one lol? Thanks a lot!

Link to comment
Share on other sites

use 0092:

0092: [email protected] = float_to_integer [email protected]


008C: works for globals only

008C: $HJ_TWOWHEELS_DISTANCE_METERS_INT = float $HJ_TWOWHEELS_DISTANCE_FLOAT to_integer

 

 

 

008C=2,%1d% = float_to_integer %2d% ; global, global
008D=2,%1d% = integer_to_float %2d% ; global, global
008E=2,%1d% = float_to_integer %2d% ; local, global
008F=2,%1d% = integer_to_float %2d% ; local, global
0090=2,%1d% = float_to_integer %2d% ; global, local
0091=2,%1d% = integer_to_float %2d% ; global, local
0092=2,%1d% = float_to_integer %2d% ; local, local
0093=2,%1d% = integer_to_float %2d% ; local, local

 

 

 

Edited by ZAZ
Link to comment
Share on other sites

47 minutes ago, ZAZ said:

use 0092:

0092: [email protected] = float_to_integer [email protected]


008C: works for globals only

008C: $HJ_TWOWHEELS_DISTANCE_METERS_INT = float $HJ_TWOWHEELS_DISTANCE_FLOAT to_integer

 

 

 

008C=2,%1d% = float_to_integer %2d% ; global, global
008D=2,%1d% = integer_to_float %2d% ; global, global
008E=2,%1d% = float_to_integer %2d% ; local, global
008F=2,%1d% = integer_to_float %2d% ; local, global
0090=2,%1d% = float_to_integer %2d% ; global, local
0091=2,%1d% = integer_to_float %2d% ; global, local
0092=2,%1d% = float_to_integer %2d% ; local, local
0093=2,%1d% = integer_to_float %2d% ; local, local

 

 

 

Still zero. I'll post my code just in case someone will ask for it:

 

05EF: [email protected] = random_actor_near_point [email protected] [email protected] [email protected] in_radius 0.5 find_next 0 pass_deads 0
0226: [email protected] = actor [email protected] health
0092: [email protected] = float_to_integer [email protected]
01E5: text_1number_highpriorit 'REWARD' [email protected] 1 ms 6  // REWARD $~1~

[email protected] always displays correct HP values, but [email protected] is always zero. I've tried writing converted int to another var ([email protected]), but result is same.

Game is GTA3, if that makes any difference

Edited by firedihm
Link to comment
Share on other sites

3 hours ago, firedihm said:

Still zero. I'll post my code just in case someone will ask for it:

 

05EF: [email protected] = random_actor_near_point [email protected] [email protected] [email protected] in_radius 0.5 find_next 0 pass_deads 0
0226: [email protected] = actor [email protected] health
0092: [email protected] = float_to_integer [email protected]
01E5: text_1number_highpriorit 'REWARD' [email protected] 1 ms 6  // REWARD $~1~

[email protected] always displays correct HP values, but [email protected] is always zero. I've tried writing converted int to another var ([email protected]), but result is same.

Game is GTA3, if that makes any difference

You should pay attention to 2 issues with your code.
Search for pedestrian command 05EF/0AE1 (GET_RANDOM_CHAR_IN_SPHERE_NO_SAVE_RECURSIVE), if the acquisition fails, it will return -1 (CLEO library version 2.0.0.5).
It will get the wrong character handle, then
0226 (GET_CHAR_HEALTH) may obtain zero health. You need to first determine the obtained character handle [email protected] ≠ -1 to detect the successful acquisition of the character handle.

2. Secondly, 0226 (GET_CHAR_HEALTH) gets the character's life value itself is an int integer, not a float, no conversion is required.

 

For:

https://library.sannybuilder.com/#/gta3/default/0226

https://library.sannybuilder.com/#/gta3/CLEO/05EF

 

Link to comment
Share on other sites

Thank you very much! As for failsafe checks – I do have them, I just omitted them from this snippet for compactness' sake

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.