vladvo Posted October 25, 2022 Share Posted October 25, 2022 0D42: load_txd "Scope" from "MODELS\TXD\TELESC.TXD" // IF and SET 0D44: [email protected] = find_texture "scope" in_dictionary "TELESC" // IF and SET 0E1E: draw_texture_plus [email protected] event 'AfterHud' pos 320.0 240.0 size 641.0 481.0 angle 0.0 depth 1 fix_aspect_ratio 0 maskTrisCount 10 maskTrisArray 11 rgba 255 255 255 255 Results in crash. SCRLog shows this: 00000483&1: [0D42] COMMAND_0D42 "Scope" "MODELS\TXD\TELESC.TXD" // TRUE 00000515&1: [0D44] COMMAND_0D44 "scope" "TELESC" -> 0 // FALSE 00000535&0: [038F] LOAD_SPRITE 1 "Scope" 00000546&0: [038F] LOAD_SPRITE 0 "Scope and this in the end: 00000570&0: [0E1E] DRAW_TEXTURE_PLUS 1 1 1 1 1 1 1 1 1 1 [UNKNOWN] [UNKNOWN] 1 [UNKNOWN] 1 I think the problem is that 0D44 returns 0/FALSE instead of id. The texture is there, because it everything perfectly with 0390 and 038D. So, how do I read the texture var/id or whatever with 0D44 ? Are there any undocumented reqirements for .txd file and/or texture in it ? Mine is .png Tried replacing [email protected] in 0E1E to 1 and 0 - crashed again. Link to comment Share on other sites More sharing options...
ZAZ Posted October 26, 2022 Share Posted October 26, 2022 (edited) Please post the script and tell us which game do you mean Edited October 26, 2022 by ZAZ CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
vladvo Posted October 26, 2022 Author Share Posted October 26, 2022 (edited) 1 hour ago, ZAZ said: Please post the script and tell us which game do you mean San Andreas This is an attempt to recreatre telescope mod I've seen in some mod. TTDISA, I think. //by vladvo //using DK22Pac - FOV control {$CLEO .cs} {$USE CLEO+} {$USE newOpcodes} script_name 'use_telescope' 0000: NOP :START wait 0 if Player.Defined($PLAYER_CHAR) jf @START :check_location wait 0 if 00FE: actor $PLAYER_ACTOR sphere 0 in_sphere 1104.7990 -2012.0490 69.0077 radius 15.0 15.0 15.0 //activate red spot jf @check_location :in_spot wait 0 if 00FE: actor $PLAYER_ACTOR sphere 1 in_sphere 1104.7990 -2012.0490 69.0077 radius 1.0 1.0 1.0 //if actor is in red spot jf @in_spot 0ACE: show_formatted_text_box "Press Tab to use telescope for 1$" :decision wait 0 if 0AB0: key_pressed 9 then wait 100 //small delay, without it the game immediately switched view back from telescope jump @LM end if 00FE: actor $PLAYER_ACTOR sphere 0 in_sphere 1104.7990 -2012.0490 69.0077 radius 3.0 3.0 3.0 jf @check_location jump @decision :LM wait 0 if //check is txd file is available 0AAB: does_file_exist "models/txd/telesc.txd" jf @error 0247: load_model 3045 //Smallest model, cigar light. It is created in front of telescope and player is attached to it in turret mode If 0248: model 3045 available jf @LM 00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] [email protected] 0107: [email protected] = create_object 3045 at 1103.0529 -2012.0073 69.0078 04F4: put_actor $PLAYER_ACTOR into_turret_on_object [email protected] offset_from_object_origin 0.0 0.0 0.0 orientation 1 both_side_angle_limit 30.0 lock_weapon 0 0826: enable_hud 0 0A8C: write_memory 0x6FF410 size 1 value 0xC3 virtual_protect 1 //enable fov control 0A8D: [email protected] = read_memory 0x8D5038 size 4 virtual_protect 0 //fov 0ACE: show_formatted_text_box "Press Tab to exit, zoom with arrows or mouse" wait 0 0D42: load_txd "Scope" from "MODELS\TXD\TELESC.TXD" // IF and SET 0D44: [email protected] = find_texture "SCOPE" in_dictionary "telesc" // IF and SET 038F: load_texture "Scope" as [email protected] //0390: load_txd_dictionary "TELESC" //038F: load_texture "Scope" as 1 //03F0: enable_text_draw 1 //03E3: set_texture_to_be_drawn_antialiased 1 :viewing wait 0 //038D: draw_texture 1 position 320.0 240.0 size 641.0 481.0 RGBA 255 255 255 255 0E1E: draw_texture_plus 0 event 'AfterHud' pos 320.0 240.0 size 641.0 481.0 angle 0.0 depth 1 fix_aspect_ratio 0 maskTrisCount 10 maskTrisArray 11 rgba 255 255 255 255 //0AD1: show_formatted_text_highpriority "FOV: %.2f" time 10 [email protected] //uncomment to show FOV/ZOOM level if 0AB0: key_pressed 9 //tab then jump @end end if 0AB0: key_pressed 40 //down arr zoom out then [email protected] += 0.5 0a8c: write_memory 0x8D5038 size 4 value [email protected] virtual_protect 0 //set FOV end if 0AB0: key_pressed 38 //up arr zoom in then [email protected] -= 0.5 0a8c: write_memory 0x8D5038 size 4 value [email protected] virtual_protect 0 end if [email protected] > 70.0 //max zoom out level then [email protected]=70.0 0a8c: write_memory 0x8D5038 size 4 value [email protected] virtual_protect 0 end if [email protected] < 20.0 //max zoom in level then [email protected]=20.0 0a8c: write_memory 0x8D5038 size 4 value [email protected] virtual_protect 0 end //zoom control - mouse - made them separate because zooming with mouse wheel was too slow if 0E11: is_mouse_wheel_down then [email protected] += 1.5 0a8c: write_memory 0x8D5038 size 4 value [email protected] virtual_protect 0 end if 0E10: is_mouse_wheel_up then [email protected] -= 1.5 0a8c: write_memory 0x8D5038 size 4 value [email protected] virtual_protect 0 end jump @viewing :end 0391: release_textures 03F0: enable_text_draw 0 0465: remove_actor $PLAYER_ACTOR from_turret_mode 02CE: [email protected] = ground_z_at [email protected] [email protected] [email protected] //get ground position at player location, so CJ won't fall down when spawning back to telescope 00A1: put_actor $PLAYER_ACTOR at [email protected] [email protected] [email protected] 0108: destroy_object [email protected] //remove cigar light 0249: release_model 3045 0826: enable_hud 1 0A8C: write_memory 0x6FF410 size 1 value 0x8B virtual_protect 1 //disable FOV control mode [email protected] = -1 //turn the number to negative Player.Money($PLAYER_CHAR) += [email protected] //set player money - actually it is money+(-price) thus deducting from player cash :DELAY_RED wait 0 if 00FE: actor $PLAYER_ACTOR sphere 0 in_sphere 1104.7990 -2012.0490 69.0077 radius 3.0 3.0 3.0 //if actor is in red zone, step away to re-enable jf @START jump @DELAY_RED :error 0ACA: show_text_box "Usable telescope mod error: TXD file not found. Mod disabled." 0A93: end_custom_thread The reason why I want to do it via 0E1E is because with 038D it draws texture over the the text box with instructions. As far as I understand - it is possible to 'move' texture back or forward relative to elements on screen with 0E1E. The lines with // before them, related to txd loading - they are working fine. And as a side question - is it possible to get object id with CLEO ? In my case - the telescope model that is placed on map by the game, so that I don't have to create another object to attach player to it. I tried, failed. Edited October 26, 2022 by vladvo Link to comment Share on other sites More sharing options...
ZAZ Posted October 29, 2022 Share Posted October 29, 2022 (edited) opcode 0E1E crashes, i didn't got it working opcode 0D7E: displays texture behind HUD, but with position relativ to user monitor resolution opcode 0D44: defines a texture by name string from txd archiv, defined by custom name string I recommand to run texture codes in a loop, R* did it in that way Simple example {$CLEO .cs} :TEXTURE thread 'TXDTEST' wait 1000 //this script shows a texture on screen by key_pressed Backspace while true wait 0 if 0AB0: is_key_pressed 8// Backspace key then 0390: load_txd_dictionary "LD_CARD"// <--- texture archive name, max. 7 charackters are valid, written as long string (double apostrophe) 038F: load_texture "cd12s" as 1 while 0AB0: is_key_pressed 8// Backspace key wait 0 03F0: enable_text_draw 1 038D: draw_texture 1 position 100.0 150.0 size 128.0 128.0 RGBA 255 255 255 255 end end end The author of newOpcodes gave example scripts he also run the texture code in a loop Spoiler /* NewOpcodes 2.0 Example script: TextureLoad Shows loading texture from dds file and drawing it in a loop. */ {$CLEO} {$I stdc} if 0D7C: t = load_texture_dds_from "plateback1.dds" // IF and SET then while true wait 0 sprite.Draw(t, 100.0, 100.0, 300.0, 300.0, 255, 255, 255, 200, 0.0) end end {$I end} /* NewOpcodes 2.0 Example script: TXD An example of loading txd and using textures from it. */ {$CLEO} {$I stdc} if 0D42: load_txd "myTxd" from "MODELS\\FRONTEN2.TXD" // IF and SET then 0D43: 0@ = txd "myTxd" id while true 0209: 1@ = random_int_in_ranges 2 9 0AD3: 2@v = format "back%d" 1@ if 0D46: 6@ = find_texture 2@v in_dictionary 0@ // IF and SET then 32@ = 0 while 32@ < 3000 wait 0 sprite.Draw(6@, 100.0, 100.0, 600.0, 400.0, 255, 255, 255, 200, 0.0) end else wait 0 end end end I managed to get following working /* NewOpcodes 2.0 opcode 0D42: can only load txd from folder MODELS\TXD opcode 0D42: defines a txd archiv by a custom name string opcode 0D43: defines a txd archiv from a custom name string as local var and opcode 0D46: defines a texture by name string from txd archiv, defined by local var opcode 0D44: defines a texture by name string from txd archiv, defined by custom name string opcode 0D7E: displays texture behind HUD, with position relativ to user monitor resolution (my monitor resolution = 2560x1440) */ {$CLEO} {$USE newOpcodes} //{$I stdc} thread 'NOPTXD' wait 3000 while true wait 0 if 0D42: load_txd "myTxd" from "MODELS\TXD\LD_CARD.TXD" then 0D43: 0@ = txd "myTxd" id if 0D46: 6@ = find_texture "cd12s" in_dictionary 0@ // IF and SET //0D44: 6@ = find_texture "cd12s" in_dictionary "myTxd" // IF and SET then while true wait 0 0D7E: draw_sprite_with_texture 6@ at_cornerA 2000.0 100.0 cornerB 2500.0 600.0 color 255 255 255 255 angle 0.0 end end end end /* NewOpcodes 2.0 Example script: TXD An example of loading txd and using textures from it. opcode 0D42: can only load txd from folder MODELS\TXD */ {$CLEO} {$USE newOpcodes} //{$I stdc} thread 'NOPTXD' wait 3000 while true wait 0 if 0D42: load_txd "myTxd" from "MODELS\TXD\FRONTEN2.TXD" // IF and SET then 0D43: 0@ = txd "myTxd" id while true wait 0 0209: 1@ = random_int_in_ranges 2 9 0AD3: 2@v = format "back%d" 1@ if 0D46: 6@ = find_texture 2@v in_dictionary 0@ // IF and SET then 32@ = 0 while 32@ < 3000 wait 0 0D7E: draw_sprite_with_texture 6@ at_cornerA 100.0 100.0 cornerB 600.0 400.0 color 255 255 255 255 angle 0.0 end else wait 0 end end end end /* NewOpcodes 2.0 opcode 0D64: and 0D7C: load image file, when file is stored in game root folder or in cleo folder giving path to sub folder have no effect opcode 0D7E: displays texture behind HUD, with position relativ to user monitor resolution (my monitor resolution = 2560x1440) */ {$CLEO} {$USE newOpcodes} //{$I stdc} thread 'NOPPNG' wait 3000 while true wait 0 if 0D64: 6@ = load_texture_png_from "Atrilogo.png" // IF and SET //0D7C: 6@ = load_texture_dds_from "f8dc9b62.dds" // IF and SET then while true wait 0 0D7E: draw_sprite_with_texture 6@ at_cornerA 2000.0 100.0 cornerB 2500.0 600.0 color 255 255 255 255 angle 0.0 end end end Edited October 29, 2022 by ZAZ vladvo 1 CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
vladvo Posted October 29, 2022 Author Share Posted October 29, 2022 (edited) Thanks ! It helped. Much appreciated ! The texture I am using is the one to make like you're looking through the telescope. I used this code. Seems to fit right on all resolutions. 0D73: get_screen_width_to [email protected] height_to [email protected] type 1 0D7E: draw_sprite_with_texture [email protected] at_cornerA -1.0 -1.0 cornerB [email protected] [email protected] color 255 255 255 255 angle 0.0 cornerA was set to -1 -1 because there was a one-pixel? lines without the texture. Done. Link to final version: Edited October 29, 2022 by vladvo 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