firedihm Posted October 2, 2021 Share Posted October 2, 2021 What title says. Like int() function in C Link to comment Share on other sites More sharing options...
firedihm Posted October 2, 2021 Author Share Posted October 2, 2021 (edited) 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 October 2, 2021 by firedihm Link to comment Share on other sites More sharing options...
Jack Posted October 2, 2021 Share Posted October 2, 2021 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); firedihm 1 Tank Fire [SA] New Police Helicopter [VC & III] My YouTube Channel Link to comment Share on other sites More sharing options...
firedihm Posted October 2, 2021 Author Share Posted October 2, 2021 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 More sharing options...
firedihm Posted October 3, 2021 Author Share Posted October 3, 2021 @Jack Sorry for the ping, but this opcode returns zero for me. Are there any other conditions I should be aware of? Link to comment Share on other sites More sharing options...
ZAZ Posted October 3, 2021 Share Posted October 3, 2021 (edited) 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 October 3, 2021 by ZAZ CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
firedihm Posted October 3, 2021 Author Share Posted October 3, 2021 (edited) 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 October 3, 2021 by firedihm Link to comment Share on other sites More sharing options...
XMDS Posted October 3, 2021 Share Posted October 3, 2021 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 firedihm 1 Link to comment Share on other sites More sharing options...
firedihm Posted October 3, 2021 Author Share Posted October 3, 2021 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 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