arielnmz Posted January 19, 2012 Share Posted January 19, 2012 Okay, I've managed to save the state of a normal thread (When I load the game again, it works normally), but that thread creates another custom threads (0A92: create_custom_thread "ShowTextBox.s"), but the states of that threads are not saved like the main thread... what is it wrong here...??? It is supposed that the main script creates an object, then creates a custom script that handles and does things with that object, "0A95: enable_thread_saving" is present in both scripts, but when I close the game and open it again, the objects are still there, ok, but they don't do anything anymore, like if the script was ended... they are compiled with a .cm extension... does that matter???... I hope you can help me, please!!... Thanks!!! Link to comment Share on other sites More sharing options...
Node Posted January 20, 2012 Share Posted January 20, 2012 What do you mean? You add: 0A95: enable_thread_saving To your CLEO script and when the game is saved so is your script, when the game is loaded so is your script, what's so hard about that? Link to comment Share on other sites More sharing options...
arielnmz Posted January 22, 2012 Author Share Posted January 22, 2012 (edited) The thing is that the script doesn't work when loading the game again... but the object is still there Edited January 22, 2012 by arielnmz Link to comment Share on other sites More sharing options...
arielnmz Posted January 22, 2012 Author Share Posted January 22, 2012 I've got another problem: 1.- An script that creates an object has "thread_saving" enabled 2.- I open San Andreas and start playing, I create an object 3.- I save the game 4.- Close and open San Andreas and the object is still there, this is OK 5.- I destroy such object 6.- I save the game, and close San Andreas 7.- When I open San Andreas again, the object is not there, this is OK 8.- Then I close San Andreas 9.- I delete EVERYTHING inside CLEO_SAVES 10.- I delete the "enable_thread_saving" opcode and compile the code 11.- I open San Andreas and start playing, the script starts 12.- An object is created (under the script thread, now "thread_saving" isn't present, right?) 13.- I save the game 14.- I close San Andreas and open it again 15.- The object is still there!!!! Why is it there if the script doesn't even has "thread_saving" enabled??? I've tried deleting ALL that's inside the CLEO_SAVES folder but the object is still there... Please help, this is annoying :s Link to comment Share on other sites More sharing options...
Node Posted January 22, 2012 Share Posted January 22, 2012 Firstly use the EDIT button, Now in your script it creates the object, Even if you disable thread saving the game still runs your script, So the object is still getting created weather it be with or without thread saving Link to comment Share on other sites More sharing options...
arielnmz Posted January 22, 2012 Author Share Posted January 22, 2012 I used Edit with my second post... well, now how I get rid of it?? how do I stop that script?? Link to comment Share on other sites More sharing options...
Node Posted January 22, 2012 Share Posted January 22, 2012 Delete the script. Link to comment Share on other sites More sharing options...
arielnmz Posted January 22, 2012 Author Share Posted January 22, 2012 What if I want to continue using my script?? Changing its name didn't work though Link to comment Share on other sites More sharing options...
fastman92 Posted January 22, 2012 Share Posted January 22, 2012 Let's explain what is enable_thread_saving for: It simply tries to load variable values from CLEO_SAVES according to number of loaded save when you load the game. Won't load variables ([email protected] - [email protected]) if new game is started. enable_thread_saving is flag for CLEO running script to save variables from this thread in file created in CLEO_SAVES. That file with thread state (variables) will be created when you save the game, only informations of threads with enabled saving will be written. This is simply for simple reason: do something with script save game load game all variables are back But there's no relation between saving objects, markers and so like i explained. They are saved always and will stay in save game in GTA San andreas user files. Therefore objects should are created only once upon the script in main.scm, if more times then they are removed somewhere. Though one instance of object is created . Link to comment Share on other sites More sharing options...
arielnmz Posted January 22, 2012 Author Share Posted January 22, 2012 Then explain me why before I added "enable_thread_saving" all created objects were lost when I load a new game, but after I added it, saved, removed it and reloaded the game, they will no longer dissappear??? Link to comment Share on other sites More sharing options...
Link2012 Posted January 22, 2012 Share Posted January 22, 2012 When you load a NEW game you are not loading any objects from a save, when you load a saved game you're loading objects from a save... Link to comment Share on other sites More sharing options...
arielnmz Posted January 22, 2012 Author Share Posted January 22, 2012 Sorry, my bad... I was always loading a previously saved game... Link to comment Share on other sites More sharing options...
fastman92 Posted January 22, 2012 Share Posted January 22, 2012 I don't know why that happens. I must try it out myself tommorow. I supposed objects never disappear when saved, no matter of enable_thread_saving Link to comment Share on other sites More sharing options...
Link2012 Posted January 22, 2012 Share Posted January 22, 2012 {$CLEO}0000://0A95: enable_thread_savingrepeat wait 0until 0AB0: key_pressed 0x58 // Press X to create a object04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 3.0 3.0 3.00107: [email protected] = create_object 16773 at [email protected] [email protected] [email protected] wait 1000 // Wait a little bit for you stop to press Xrepeat wait 0until 0AB0: key_pressed 0x58 // Press X again to show the save screen 03D8: show_save_screen0A93: end_custom_thread Look for that simple test... Start a new game, press x, look where the object was created (above the player), press x again, save in a irrelevant slot, load that slot, look for where the object was created, it is there. Now, uncomment enable thread saving. Do the test again, the same result. BUT you can't press X anymore, the script state was saved, and when you load it goes direct to the end_custom_thread. Link to comment Share on other sites More sharing options...
arielnmz Posted January 22, 2012 Author Share Posted January 22, 2012 (edited) Sorry guys my bad... you are right objects don't dissappear once created... but I now have a couple more questions: 1.- Is there a way to check if the game is going to halt (when selecting a new savegame, or when you exit the game)... or something that deletes the objects again if they werent properly destroyed because you left the game or something when you load another game... 2.- If the above thing doesn't have solution then why if I enable thread saving, the "threads" don't seem to continue working after loading the game again /... I'll explain what my script does: 1.- It creates an object from a main thread, creates a secondary thread and passes the handle of that object 2.- It passes a var offset so the newly created thread may know the state of the first one (to know when it was deactivated) 3.- The new thread checks if there is a ped near it and creates a m4 shoot to it, only that. it doesnt need anything else... Both the main and the secondary script have thread_saving enabled... If I close the game and open it again, both scripts are stopped, they don't response to anything... why??? Edited January 22, 2012 by arielnmz Link to comment Share on other sites More sharing options...
OrionSR Posted January 23, 2012 Share Posted January 23, 2012 When you "destroy" the object, does the script destroy the object (usually opcode 0108), or is it destroyed by weapon fire or other damage? If it is destroyed by damage then the object probably isn't really destroyed. If I recall correctly, an object destroyed by damage will still exist in the save but won't be displayed. If you continue to create more objects then you'll rapidly run into problems with too many objects. Either way, the script that is responsible for creating the object will need a method to check if the object exists, and if so then destroy it before creating a new one for the current event. Link to comment Share on other sites More sharing options...
arielnmz Posted January 23, 2012 Author Share Posted January 23, 2012 Yes, the object is destroyed via "destroy_object" opcode, but I dont have a way to know if the object exists after loading the game again... as the scripts remain 'stopped'... Link to comment Share on other sites More sharing options...
Wesser Posted January 23, 2012 Share Posted January 23, 2012 Let me clarify some aspects. 0A95 saves the whole CScriptThread structure into CLEO/CLEO_SAVES/*.sav, so that when a game is loaded all the content of saved cleo scripts are restored, just like original main.scm threads. Indeed, this won't happen with .cm (Custom Mission) scripts as mission local variables are stored at 0xA48960, whose data is lost throughout the mission. They are compiled with a .cm extension. Does that matter? 012 345 678 9A BCD EFG HIJK LMN OPQR STUV WX YZ Link to comment Share on other sites More sharing options...
arielnmz Posted January 23, 2012 Author Share Posted January 23, 2012 (edited) Okay... they are not .cm scripts no more, everything is now in the same .cs script, so to access a different part of the code I create itself again (create_custom_thread and create it again) but with a certain parameter that determines where to jump to start... Something like this: 1.- Load a savegame, thread .cs is created 2.- At the beginning there is a jump table that, depending on the value of [email protected], jumps to certain parts of the code... as [email protected] is not initially defined (returning a high value, other than 0, 1, 2 , 3 or 4.), it jumps to the default label, the script's "main" thread... and this is how it starts... var [email protected] is cleared and used as an other normal var in the main thread... 3.- At some part of the "main" thread it creates an object and passes: [a integer number] [var [email protected] offset] [var [email protected] offset] and the [handle] of that object to a new thread (create_custom_thread)... 3.- As the "new" thread is in the same .cs script, it begins again with the jump table, but this time [email protected] (first param) is defined, i.e. 1, and jumps to the label defined for the value of 1. 4.- Then it does its work... It works pretty well without any problems... except that the thread state isn't saved, I have to say that "enable_thread_saving" is present right infront of every "name_thread" opcode... but why doesn't it continue working??? It just remains stopped... You can download my script from here and test it by yourselves: http://anmzgtasamods.blogspot.com/2012/01/mod-bunker.html The one I uploaded doesn't have thread_saving enabled, but you can add it by yourselves and save the game and you'll see what I'm talking about... Thanks for your responses!!! Edited January 23, 2012 by arielnmz Link to comment Share on other sites More sharing options...
arielnmz Posted January 23, 2012 Author Share Posted January 23, 2012 Hey... you might like to take a look at this: {$CLEO .cs}//-------------MAIN---------------03A4: name_thread 'DEBUGTHRSAV'0A95: enable_thread_saving :10001: wait 0 ms 00D6: if and0256: player $PLAYER_CHAR defined 056D: actor $PLAYER_ACTOR defined 004D: jump_if_false @1:scriptif0ADC: test_cheat "DEBUGTHREADSAV"jf @fin0aca: "Thread Saving Activado"04C4: store_coords_to [email protected] [email protected] [email protected] from_actor $PLAYER_ACTOR with_offset 0.0 3.0 0.00107: [email protected] = create_object 2918 at [email protected] [email protected] [email protected] 1000:loopwait 0if and0256: player $PLAYER_CHAR defined 056D: actor $PLAYER_ACTOR definedjf @loop01BB: store_object [email protected] position_to [email protected] [email protected] [email protected]: create_smoke_at [email protected] [email protected] [email protected] velocity 0.0 0.0 0.0 RGBA 0.0 0.0 1.0 1.0 size 0.2 last_factor 0.010ACC: show_text_lowpriority "Debug Thread Saving Activo" time 100if0ADC: test_cheat "DEBUGTHREADSAV"jf @loop0aca: "Thread Saving Desctivado"0108: destroy_object [email protected]: chdir 0 0A92: create_custom_thread "debug_ThreadSaving.cs" 0A93: end_custom_thread:fin0001: wait 0 ms 00D6: if or8256: not player $PLAYER_CHAR defined 856D: not actor $PLAYER_ACTOR defined 004D: jump_if_false @Scriptjump @1 It creates a thread, and enables thread saving... its supposed to save the state of the thread right?? well it doesn't... check it by yourselves... I'm currently using CLEO 4... Link to comment Share on other sites More sharing options...
Link2012 Posted January 24, 2012 Share Posted January 24, 2012 The enable_thread_saving can't save two of the same .cs file, it only saved the state of the main script (that start with the game) as [email protected] is not initially defined (returning a high value It always start with the value of 0 (unless you pass params to the script) Link to comment Share on other sites More sharing options...
arielnmz Posted January 24, 2012 Author Share Posted January 24, 2012 Thanks bro... (I said so because some time ago I did an example where a var was not defined at the start and it returned some strange high value)... And another thing: ok you say that it only saves the state of the main thread right?? then why it doesn't even work after reloading the game??? Did you test the example I posted before??? Link to comment Share on other sites More sharing options...
Link2012 Posted January 24, 2012 Share Posted January 24, 2012 Thanks bro... (I said so because some time ago I did an example where a var was not defined at the start and it returned some strange high value)... And another thing: ok you say that it only saves the state of the main thread right?? then why it doesn't even work after reloading the game??? Did you test the example I posted before??? I did, Here goes my log: 1. Typed DEBUGTHREADSAV 2. A object with smoke and a text appears (the text always shows) 3. Ok, Saved the game 4. Loaded that game, The text continues (and obviously the object with smoke is there) 5. Typed DEBUGTHREADSAV again to go out of the loop. 6. Ok, a custom script was created, Typed DEBUGTHREADSAV again 7. [same as 2.] 8. [same as 3.] 9. Right, no text and no smoke in the object, typed DEBUGTHREADSAV and nothing happens, right behaviour - the main script was ended before with end_custom_thread. Link to comment Share on other sites More sharing options...
arielnmz Posted January 24, 2012 Author Share Posted January 24, 2012 (edited) Then I think it's an issue in my cleo installation... when I load the game again, the script doesn't work anymore... thanks bro I'm gonna check it right now... btw what version of cleo do you have??? EDIT: 5. Typed DEBUGTHREADSAV again to go out of the loop.6. Ok, a custom script was created, Typed DEBUGTHREADSAV again7. [same as 2.]8. [same as 3.]9. Right, no text and no smoke in the object, typed DEBUGTHREADSAV and nothing happens, right behaviour - the main script was ended before with end_custom_thread. It's supposed to continue working even after it was ended: the script creates itself again, thus allowing you to re-activate it typing DEBUGTHREADSAV again... it works as many times I activate-deactivate it... but after saving and then loading the game it doesn't work again... thats the problem... Edited January 24, 2012 by arielnmz Link to comment Share on other sites More sharing options...
Link2012 Posted January 24, 2012 Share Posted January 24, 2012 Then I think it's an issue in my cleo installation... when I load the game again, the script doesn't work anymore... thanks bro I'm gonna check it right now... btw what version of cleo do you have??? 4.1.1.30f It's supposed to continue working even after it was ended: the script creates itself again, thus allowing you to re-activate it typing DEBUGTHREADSAV again... it works as many times I activate-deactivate it... but after saving and then loading the game it doesn't work again... thats the problem... Maybe only for the test, but if thats in your problematic script why just don't use a loop to the start? Link to comment Share on other sites More sharing options...
arielnmz Posted January 24, 2012 Author Share Posted January 24, 2012 (edited) hey.. I tried reinstalling the cleo library and everything worked fine... thanks for the responses guys I'll now continue with my cleos... EDIT: I've put everything into separated CLEOS .cs and enabled thread saving but they don't seem to work either... ... I think this is the only solution: Is there a way to know if the game was saved??? or if the savefile was modified?? Edited January 24, 2012 by arielnmz Link to comment Share on other sites More sharing options...
Namaloom Posted June 30, 2018 Share Posted June 30, 2018 This is my code i have two problems 1. It works fine creates object. but when i save game and load it again it creates another object over the preveiously added object so 1 gate moves and the other one dont so the way is still blocked. 2. i want to make the barrier rotation using below code instead of moving gate from right to left... how do i use rorate_object around its axis? {$CLEO .CS} thread 'GATEO' 0A95: enable_thread_saving // required to make sure the object won't appear over and over again when starting the game Object.Create([email protected], 971, 1937.14, 2216.51, 9.0) object.Angle([email protected]) = 270.447 :begin wait 100 if Player.Defined($PLAYER_CHAR) // he shouldn't be wasted or busted jf @begin else_jump if Player.Controllable($PLAYER_CHAR) // he shouldn't be uncontrollable jf @begin if 0474: actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 5.0 5.0 4.0 flag 0 jf @begin // Move gate back to open position repeat wait 10 until 034E: move_object [email protected] to 1937.14 2207.51 13.6343 speed 0.1 0.1 0.1 flag 0 // Wait for the player to leave the area of the gate repeat wait 100 until 8474: not actor $PLAYER_ACTOR near_object_in_cube [email protected] radius 5.0 5.0 5.0 flag 0 // Move gate back to original position repeat wait 10 until 034E: move_object [email protected] to 1937.14 2216.51 13.6343 speed 0.1 0.1 0.1 flag 0 jump @begin 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