xToK3x Posted March 21, 2015 Share Posted March 21, 2015 I'm making this menu in game. It's a panel, I need to be able to click an option in the panel and have it read 2 things at one time. It needs to run a script throughout the game when clicking the menu option for it and at the same time jump back to the start of the menu script to keep using it while the other script is still running. Link to comment Share on other sites More sharing options...
xToK3x Posted March 22, 2015 Author Share Posted March 22, 2015 I just tried to write 1 to an .ini file from the menu and read it from a different .cs script to run both at the same time, but no go for some reason. it seemed full proof. can anyone help running 2 things at one time weather its in one .cs file or two Link to comment Share on other sites More sharing options...
hgboy2 Posted March 22, 2015 Share Posted March 22, 2015 I have same problem like xtok Link to comment Share on other sites More sharing options...
dkluin Posted March 22, 2015 Share Posted March 22, 2015 No double posting. Also, I don't understand. Do you mean, when an option is selected, the script must execute multiple opcodes? Or you want to add the ability to re-use the menu? (Jumping back to the beginning after finish) If so, that's not a big issue. I'm making this menu in game. It's a panel, I need to be able to click an option in the panel and have it read 2 things at one time. It needs to run a script throughout the game when clicking the menu option for it and at the same time jump back to the start of the menu script to keep using it while the other script is still running. Also, you could try to: if $choice_var == 0thenjump @EXAMPLEend And at the end of the option, the script jumps back to the first label. blahblahjump @START //Add the first label used in the thread This way, you are able to hit the menu button multiple times. NOTE: Maybe you should release any used models, to free some memory first if needed. You don't need to load a secondairy CS file just to re-use the menu. Link to comment Share on other sites More sharing options...
xToK3x Posted March 22, 2015 Author Share Posted March 22, 2015 You said it! I'm trying to execute multiple opcodes! how would I do that. Oh and I'm sorry about everything I'm new. i couldn't figure out how to tell you my problem. Link to comment Share on other sites More sharing options...
dkluin Posted March 22, 2015 Share Posted March 22, 2015 You said it! I'm trying to execute multiple opcodes! how would I do that. Oh and I'm sorry about everything I'm new. i couldn't figure out how to tell you my problem. That's done easily: if $CHOICE == 1then//opcode 1//opcode 2end Link to comment Share on other sites More sharing options...
ZAZ Posted March 22, 2015 Share Posted March 22, 2015 (edited) I'm making this menu in game. It's a panel, I need to be able to click an option in the panel and have it read 2 things at one time. It needs to run a script throughout the game when clicking the menu option for it and at the same time jump back to the start of the menu script to keep using it while the other script is still running. Basicly do you need 0A92: create_custom_thread, to start(run, create) another thread/script But i assume, that you don't need to do it, because there's another easier way. So post please your script and explain more detailed why you need to start an additional thread. Then back to 0A92: create_custom_thread 0A92: create_custom_thread "sub.s" Usually to start another cleoscript with *.s extension, because a *.cs script will automaticly started by cleo programm Type {$CLEO .s} instead {$CLEO .cs} as directive, to create a *.s file,(decompiling needs renaming in *.cs) In this case the Cleo script will only run if it was started with 0A92: create_custom_thread from another Cleo script. Running multiple instances or threads, script blocks inside of same current cleoscript file as this for initialzing, is also possible 0A92: create_custom_thread "MultiThread.cs" opcode 0A92: create_custom_thread can transfer more information to the script which should be started This opcode can be extended with up to 30 values or variables as parameters example: 0A92: create_custom_thread "MultiThread.cs" 1 2 0 [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] The started thread recieves these parameter values by following rule [email protected] get value of 1.parameter [email protected] get value of 2.parameter [email protected] get value of 3.parameter [email protected] get value of 4.parameter [email protected] get value of 5.parameter etc... The method: The script beginns with a conditional check for [email protected] (or any other local var) All local varibles are zero by default ([email protected] = 0), unless if you start the script by opcode 0A92 that declares [email protected] as 1 (or 2 or anything else) [email protected] == 0else_jump @MultiThread_20//this conditional check will be passed,//if it was started automaticly by cleo programm,//because all local varibles are zero by default ([email protected] = 0)//the code will do an else_jump to the label MultiThread_20,//if [email protected] isn't equal to 0 Start the same current script again and send 1 by 1. parameter [email protected] get value of 1.parameter 0A92: create_custom_thread "MultiThread.cs" 1 IMPORTANT: Cleo script and entry of 0A92: must have same name Test the script below, save and copmile it as MultiThread.cs, it shows numbers on the screen the first thread shows value of [email protected] of the first thread and the second thread shows the values of [email protected], [email protected], [email protected], [email protected] of second thread {$CLEO .cs}:[email protected] == 0else_jump @MultiThread_20thread 'MULTHRD'0A92: create_custom_thread "MultiThread.cs" 1 2 3 4 while true wait 0 03F0: enable_text_draw 1 045A: draw_text_1number 100.0 100.0 GXT 'NUMBER' number [email protected] end:MultiThread_20// second [email protected] == 1then 03A4: name_thread 'SECONDT' while true wait 0 03F0: enable_text_draw 1 045A: draw_text_1number 150.0 120.0 GXT 'NUMBER' number [email protected] 045A: draw_text_1number 160.0 120.0 GXT 'NUMBER' number [email protected] 045A: draw_text_1number 170.0 120.0 GXT 'NUMBER' number [email protected] 045A: draw_text_1number 180.0 120.0 GXT 'NUMBER' number [email protected] endend0A93: end_custom_thread Edited March 24, 2015 by ZAZ CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
Seemann Posted March 22, 2015 Share Posted March 22, 2015 Type {$CLEO .s} instead {$CLEO .cs} as directive, to create a *.s file,(decompiling needs renaming in *.cs)Hit the F5 button in Sanny to run the decompiling feature, choose All files (*.*), then you're able to decompile a file with any extension, no need to rename it. Sanny Builder 3 • SA Memory Handling • OpenIV • gtamodding.com CLEO.li - The CLEO Library - Official site Link to comment Share on other sites More sharing options...
ZAZ Posted March 22, 2015 Share Posted March 22, 2015 Type {$CLEO .s} instead {$CLEO .cs} as directive, to create a *.s file,(decompiling needs renaming in *.cs) Hit the F5 button in Sanny to run the decompiling feature, choose All files (*.*), then you're able to decompile a file with any extension, no need to rename it. yes, if i have a hook at debug option "skip_scm_header" CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
xToK3x Posted March 23, 2015 Author Share Posted March 23, 2015 (edited) Im trying to run multiple loops at the same time. here's a test code of what im doing. it creates a menu with a button called Continue. I need to be able to press the button continue and have it start doing 2 loops. the first will open the test gxt text and close it over and over. the second will jump back and get the key presses of the panel again. it goes straight to the infinite loop of creating a text box, but i need it to do that and get the menu keys again for another action. {$CLEO .cs}//-------------MAIN---------------thread 'TEST':TEST_1wait 00ADF: add_dynamic_GXT_entry "MAIN_T" text "MAIN MENU" 0ADF: add_dynamic_GXT_entry "MAIN_H" text "MOD MENU" 0ADF: add_dynamic_GXT_entry "MAIN_1" text "Continue" :TEST_2wait 0 if Player.Defined($PLAYER_CHAR)jf @TEST_2 if 0AB0: key_pressed 8 jf @TEST_1jump @TEST_3:TEST_3wait 0 Camera.SetBehindPlayerCamera.Restore_WithJumpCutPlayer.CanMove($PLAYER_CHAR) = False03BF: set_player $PLAYER_CHAR ignored_by_everyone 1 0826: enable_hud 0 0581: enable_radar 0 08D4: [email protected] = create_panel_with_title 'MAIN_T' position 340.0 120.0 width 240.0 columns 1 interactive 1 background 1 alignment 0 08DB: set_panel [email protected] column 0 header 'MAIN_H' data 'MAIN_1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 090E: set_panel [email protected] active_row 0 jump @TEST_4:TEST_4wait 0 if00E1: player 0 pressed_key 15 else_jump @TEST_5jump @TEST_8 :TEST_5wait 0if 00E1: player 0 pressed_key 16 else_jump @TEST_4 08D7: [email protected] = panel [email protected] active_row [email protected] += 1 jump @TEST_6 :TEST_6wait 0if [email protected] == 1jf @TEST_4 0ADF: add_dynamic_GXT_entry "TEST_1" text "TEST" 00BA: show_text_styled GXT 'TEST_1' time 100 style 2 jump @TEST_7 :TEST_7wait 1000 0AE0: remove_dynamic_GXT_entry "TEST_1" wait 1000 jump @TEST_6 :TEST_8wait 008DA: remove_panel [email protected] 03E6: remove_text_box Camera.SetBehindPlayerCamera.Restore_WithJumpCutPlayer.CanMove($PLAYER_CHAR) = TRUE03BF: set_player $PLAYER_CHAR ignored_by_everyone 0 0826: enable_hud 1 0581: enable_radar 1jump @TEST_2 Edited March 23, 2015 by xToK3x Link to comment Share on other sites More sharing options...
ZAZ Posted March 23, 2015 Share Posted March 23, 2015 One loop is enough, try the script below {$CLEO .cs}thread 'TEST' :TEST_1wait 0 if Player.Defined($PLAYER_CHAR) jf @TEST_5if [email protected] == 1jf @TEST_2 gosub @TEST_sequence:TEST_2 if [email protected] == 0 jf @TEST_3 if 0AB0: key_pressed 8 jf @TEST_1 gosub @TEST_Menue :TEST_3if 00E1: player 0 pressed_key 16 jf @TEST_4 gosub @TEST_Selection :TEST_4if 00E1: player 0 pressed_key 15 jf @TEST_1 gosub @TEST_CloseMenue :TEST_5if [email protected] == 1 jf @TEST_1 gosub @TEST_CloseMenue jump @TEST_1 :TEST_MenueCamera.SetBehindPlayerCamera.Restore_WithJumpCutPlayer.CanMove($PLAYER_CHAR) = False03BF: set_player $PLAYER_CHAR ignored_by_everyone 1 0826: enable_hud 0 0581: enable_radar 00ADF: add_dynamic_GXT_entry "MAIN_T" text "MAIN MENU" 0ADF: add_dynamic_GXT_entry "MAIN_H" text "MOD MENU" 0ADF: add_dynamic_GXT_entry "MAIN_1" text "Continue"08D4: [email protected] = create_panel_with_title 'MAIN_T' position 340.0 120.0 width 240.0 columns 1 interactive 1 background 1 alignment 0 08DB: set_panel [email protected] column 0 header 'MAIN_H' data 'MAIN_1' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 090E: set_panel [email protected] active_row [email protected] = 1return :TEST_CloseMenue08DA: remove_panel [email protected] 0006: [email protected] = 0Camera.SetBehindPlayerCamera.Restore_WithJumpCutPlayer.CanMove($PLAYER_CHAR) = true03BF: set_player $PLAYER_CHAR ignored_by_everyone 0 0826: enable_hud 1 0581: enable_radar 1 return :TEST_Selection08D7: [email protected] = panel [email protected] active_row if [email protected] == 0jf @TEST_exitif [email protected] == 0jf @TEST_Sel_2 [email protected] = 1 [email protected] = 0 jump @TEST_exit:TEST_Sel_2if [email protected] == 1jf @TEST_exit [email protected] = 0 [email protected] = 0 jump @TEST_exit:TEST_exitreturn:[email protected] == 0jf @TEST_seq10ADF: add_dynamic_GXT_entry "TEST_1" text "TEST" 00BA: show_text_styled GXT 'TEST_1' time 5000 style [email protected] = [email protected] = 0:TEST_seq1if [email protected] > [email protected] == 1jf @TEST_seq203D6: remove_styled_text "TEST_1"[email protected] = [email protected] = 0:TEST_seq2if [email protected] > [email protected] == 2jf @[email protected] = 0:TEST_seq3return CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
Seemann Posted March 23, 2015 Share Posted March 23, 2015 Type {$CLEO .s} instead {$CLEO .cs} as directive, to create a *.s file,(decompiling needs renaming in *.cs) Hit the F5 button in Sanny to run the decompiling feature, choose All files (*.*), then you're able to decompile a file with any extension, no need to rename it. yes, if i have a hook at debug option "skip_scm_header" OR the script was compiled with the option 'Add extra info to SCM', so Sanny knows it's headerless Sanny Builder 3 • SA Memory Handling • OpenIV • gtamodding.com CLEO.li - The CLEO Library - Official site Link to comment Share on other sites More sharing options...
ZAZ Posted March 24, 2015 Share Posted March 24, 2015 Type {$CLEO .s} instead {$CLEO .cs} as directive, to create a *.s file,(decompiling needs renaming in *.cs) Hit the F5 button in Sanny to run the decompiling feature, choose All files (*.*), then you're able to decompile a file with any extension, no need to rename it. yes, if i have a hook at debug option "skip_scm_header" OR the script was compiled with the option 'Add extra info to SCM', so Sanny knows it's headerless No, i have it always unchecked, since it was a theme in your forum. I need to select skip_scm_header, otherwise sanny says "incorrect jump instruction 50346243 found at 12" (testet with the MultiThread script above) CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
xToK3x Posted March 26, 2015 Author Share Posted March 26, 2015 (edited) I tried your way zaz but it's not exactly what I'm going for I don't think. Is their a way to make a menu with one .cs file and use it to control a second file either .cs or .s using anything. This is one way I thought would work using in read and write but isn't working either, but this will show you what I'm working for. I need to run 2 things at one time but connect with each other. One of my theories below, another was with a global variable ? idk i need to add multiple scripts that can run simultaneously with the menu script. Menu.cs {$CLEO .cs}thread 'MENU':MENU_1wait 00ADF: add_dynamic_GXT_entry "MENU" text "MENU" 0ADF: add_dynamic_GXT_entry "MAINON" text "TEST FILE ON" 0ADF: add_dynamic_GXT_entry "MAINOFF" text "TEST FILE OFF" :MENU_2wait 0 if Player.Defined($PLAYER_CHAR)else_jump @MENU_2 if 0AB0: key_pressed 8 else_jump @MENU_2jump @MENU_3:MENU_3wait 0 Camera.SetBehindPlayerCamera.Restore_WithJumpCutPlayer.CanMove($PLAYER_CHAR) = False03BF: set_player $PLAYER_CHAR ignored_by_everyone 1 0826: enable_hud 0 0581: enable_radar 0 08D4: [email protected] = create_panel_with_title 'MENU' position 340.0 120.0 width 240.0 columns 1 interactive 1 background 1 alignment 0 08DB: set_panel [email protected] column 0 header 'MENU' data 'MAINON' 'MAINOFF' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 090E: set_panel [email protected] active_row 0 jump @MENU_4:MENU_KEYS_1wait 0 if00E1: player 0 pressed_key 15 else_jump @MENU_KEYS_2jump @MENU_CLOSE :MENU_KEYS_2wait 0if 00E1: player 0 pressed_key 16 else_jump @MENU_KEYS_108D7: [email protected] = panel [email protected] active_row [email protected] += 1 jump @MENU_INPUT_1:[email protected] == 1else_jump @[email protected] = 10AF1: write_int [email protected] to_ini_file "Cleo\Test.ini" section "Section" key "Key"jump @MENU_CLOSE:[email protected] == 2else_jump @[email protected] = 00AF1: write_int [email protected] to_ini_file "Cleo\Test.ini" section "Section" key "Key"jump @MENU_CLOSE:MENU_CLOSEwait 008DA: remove_panel [email protected] 03E6: remove_text_box Camera.SetBehindPlayerCamera.Restore_WithJumpCutPlayer.CanMove($PLAYER_CHAR) = TRUE03BF: set_player $PLAYER_CHAR ignored_by_everyone 0 0826: enable_hud 1 0581: enable_radar 1jump @MENU_2 Msg.cs {$CLEO .cs}thread 'MSG' :MSG_1wait 50AF4: [email protected] = read_string_from_ini_file "cleo\Test.ini" section "Section" key "Key"[email protected] == 1else_jump @MSG_1jump @MSG_2:MSG_2wait [email protected] == 1else_jump @MSG_30ADF: add_dynamic_GXT_entry "MSGON" text "Turned ON!"0217: show_text_styled GXT "MSGON" time 1000 style 1jump @MSG_3:MSG_3wait [email protected] == 1else_jump @MSG_3jump @MSG_4:MSG_40AE0: remove_dynamic_GXT_entry "MSGON"0ADF: add_dynamic_GXT_entry "MSGOFF" text "Turned OFF!"0217: show_text_styled GXT "MSGOFF" time 1000 style 10AE0: remove_dynamic_GXT_entry "MSGON"jump @MSG_1 Edited March 26, 2015 by xToK3x Link to comment Share on other sites More sharing options...
ZAZ Posted March 26, 2015 Share Posted March 26, 2015 (edited) I already wrote about 0A92: create_custom_thread in my first post. Then use opcode 0AB3: and 0AB4: to communicate between cleo scripts The expression var together with a number, <var><space><number> builds the "Special Global Cleo Variable" 0AB3: var 0 = 10or0006: [email protected] = 10 // integer values0AB3: var 0 = [email protected]: [email protected] = var 0var 0 up to var 999 will be stored, in example var 0 is stored with 10 to get then the stored value into your script needs to allocate the content into a local var: 0AB4: [email protected] = var 44if 0039: [email protected] == 1 // integer valuesthen //do somethingend Edited March 26, 2015 by ZAZ CLEO MODS CLEO Script Tutorial Link to comment Share on other sites More sharing options...
xToK3x Posted March 27, 2015 Author Share Posted March 27, 2015 (edited) I did finally understand it somewhat and have it working to my purpose. 1. I was wondering when you add lets say [email protected] after 0A92: Create_Custom_Thread, does that transfer the variable [email protected] to the new thread? And can you show me a small example of it actually in use. pretty much the retrieving it part I don't understand. 2. I was wondering if there is a way to check if the thread is running or not after using 0A92: Create_Custom_Thread. EDIT. 3. And I don't completely understand the part about using 0A92: Create_Custom_Thread to run simultaneously in the same file. I've been trying just for the sake of knowledge, can you show a simpler example using jumps instead? idk Edited March 28, 2015 by xToK3x Link to comment Share on other sites More sharing options...
dkluin Posted March 28, 2015 Share Posted March 28, 2015 I did finally understand it somewhat and have it working to my purpose. 1. I was wondering when you add lets say [email protected] after 0A92: Create_Custom_Thread, does that transfer the variable [email protected] to the new thread? And can you show me a small example of it actually in use. pretty much the retrieving it part I don't understand. 2. I was wondering if there is a way to check if the thread is running or not after using 0A92: Create_Custom_Thread. EDIT. 3. And I don't completely understand the part about using 0A92: Create_Custom_Thread to run simultaneously in the same file. I've been trying just for the sake of knowledge, can you show a simpler example using jumps instead? idk As far as I know, adding a variable only works for labels. Why? Labels are only metadata. 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