Ify24 Posted August 14, 2014 Share Posted August 14, 2014 So I have a question, when I get players active interior and store it to a variable [email protected], can I then write the value of a [email protected] in a file somewhere like value.txt ? Link to comment Share on other sites More sharing options...
Ify24 Posted August 15, 2014 Author Share Posted August 15, 2014 (edited) Okay I figured it out but now I have a problem, here is the code: {$CLEO .cs}thread "DRU"0A95: enable_thread_saving0A9A: $hFILE = openfile "CLEO\VARR.ini" mode "rt+" 0AF0: [email protected] = get_int_from_ini_file "CLEO\VARR.ini" section "Varr" key "int":Check_1wait 0 ms077E: get_active_interior_to $ACTIVE_INTERIORif$ACTIVE_INTERIOR == 0jf @Check_1Model.Load(#WMYDRUG)038B: load_requested_models:Check_2wait 0 msifModel.Available(#WMYDRUG)jf @Check_2Actor.Create($DEALER, Dealer, #WMYDRUG, -490.372, 1504.965, 8.688)Actor.Angle($DEALER) = 121.0:Check_3wait 0 msif00F3: actor $PLAYER_ACTOR near_actor $DEALER radius 1.8 1.8 sphere 0 on_footjf @Check_6jump @NEAR_Truee:Check_6wait 0 msif0AB0: key_pressed 0x49jf @Check_30ACE: show_formatted_text_box "You have %d g." [email protected] @Check_3:NEAR_TrueePlayer.CanMove($PLAYER_CHAR, False)0ACE: show_formatted_text_box "Would you like to buy some weed ? (Y or N?)" 0x0ACE:Check_4wait 0 msif0AB0: key_pressed 0x59jf @Check_5jump @BUY:Check_5wait 0 msif0AB0: key_pressed 0x4Ejf @Check_40ACE: show_formatted_text_box "Come back any time if you change your mind." 0x0ACEPlayer.CanMove($PLAYER_CHAR, True)wait 3500 msjump @Check_3:BUYPlayer.CanMove($PLAYER_CHAR, True)0ACE: show_formatted_text_box "This is %.4X opcode" 0x0ACEwait 3500 [email protected] += 10AF1: write_int [email protected] to_ini_file "CLEO\VARR.ini" section "Varr" key "int"jump @Check_3 So everything worked pretty well until I saved my game. Code changed int value in file and read it and gave outpout ingame everything great. Then when I try to load my game it would crash, SA Limit Adjuster: GTA:SA Crashed, Last File Loaded:DRU.cs bla bla (Also I have GTA United 1.1 instaled but I think that doesn't have anything much to do with crashes) So can somebody help me? EDIT: Also, when I start a new game the script works pretty good, but then again if I save the game and then load it it crashes Edited August 15, 2014 by Ify24 Link to comment Share on other sites More sharing options...
Ify24 Posted August 15, 2014 Author Share Posted August 15, 2014 Oh I figured it out I don't need 0a95 opcode becouse I don't need to save variable value becouse it reads it from a file but I thought that idk, nevermind xD Link to comment Share on other sites More sharing options...
Ify24 Posted August 15, 2014 Author Share Posted August 15, 2014 Now I have a problem, I don't need to save my game but game will know how much g's but now I can buy weed, not save my game, then load a game again, my money will return and the weed will stay, can someone help me with this ? Link to comment Share on other sites More sharing options...
Ify24 Posted August 15, 2014 Author Share Posted August 15, 2014 (edited) Sorry guys for5 posts in a row, but It doesn't work, I don't know what the f is going on, here is the script: {$CLEO .cs}thread "DRU":Check_1wait 0 ms077E: get_active_interior_to $ACTIVE_INTERIORif$ACTIVE_INTERIOR == 0thenjump @STARTelsejump @Check_0end:Check_0wait 0 msif0AB0: key_pressed 0x49then0A9A: $hFILE = openfile "CLEO\VARR.ini" mode "rt+"0AF0: [email protected] = get_int_from_ini_file "CLEO\VARR.ini" section "Varr" key "int"0ACE: show_formatted_text_box "You have %d g." [email protected]: closefile $hFILEwait 1000 msendjump @Check_1:STARTModel.Load(#WMYDRUG)038B: load_requested_models:Check_2wait 0 msifModel.Available(#WMYDRUG)jf @Check_2Actor.Create($DEALER, Dealer, #WMYDRUG, -490.372, 1504.965, 8.688)Actor.Angle($DEALER) = 121.0:Check_3wait 0 msif00F3: actor $PLAYER_ACTOR near_actor $DEALER radius 1.8 1.8 sphere 0 on_footjf @Check_6jump @NEAR_Truee:Check_6wait 0 msif0AB0: key_pressed 0x49jf @Check_30A9A: $hFILE = openfile "CLEO\VARR.ini" mode "rt+"0AF0: [email protected] = get_int_from_ini_file "CLEO\VARR.ini" section "Varr" key "int"0ACE: show_formatted_text_box "You have %d g." [email protected]: closefile $hFILEwait 1000 msjump @Check_3:NEAR_TrueePlayer.CanMove($PLAYER_CHAR, False)0ACE: show_formatted_text_box "Would you like to buy some weed, 20$ for a G?(Y or N?)" 0x0ACE:Check_4wait 0 msif0AB0: key_pressed 0x59jf @Check_5jump @BUY:Check_5wait 0 msif0AB0: key_pressed 0x4Ejf @Check_40ACE: show_formatted_text_box "Come back any time if you need the stuff." 0x0ACEPlayer.CanMove($PLAYER_CHAR, True)wait 3500 msjump @Check_3:BUY0ACE: show_formatted_text_box "Would you like some more (Y or N)?" 0x0ACE0109: player $PLAYER_CHAR money += -200A9A: $hFILE = openfile "CLEO\VARR.ini" mode "rt+"[email protected] += 10AF1: write_int [email protected] to_ini_file "CLEO\VARR.ini" section "Varr" key "int"0A9B: closefile $hFILEwait 500 msjump @Check_4 Everything works great but as I said when I save a game after buying some "weed" and then I try to load it game chrashes after loading screen EDIT: Okay I now really figured it out, this script works very good on unmodded GTA:SA (With changed actor coords ofc) I can save my game after playing with script and then load it, tried it a few times all good, no problem. But, for some reason it doesn't work well with GTA United 1.1, well it works but as I said a few times now, it chrashes when I play a game with a script, then save, and then load, the crash happens right after load screen appears and SA Limit Adjuster says that the problem is DRU.cs, but to unmodded GTA:SA, it really isn't, why is that so, I don't know. Hmmmm.... Edited August 15, 2014 by Ify24 Link to comment Share on other sites More sharing options...
J16D Posted August 19, 2014 Share Posted August 19, 2014 uhm test this; {$CLEO}thread "DRU":begin_coderepeat wait 0until 0AB0: key_pressed 0x49while true077E: get_active_interior_to $ACTIVE_INTERIORif $ACTIVE_INTERIOR == 0then break // goto @STARTendif 0AB0: key_pressed 0x49then 0AF0: [email protected] = get_int_from_ini_file "CLEO\VARR.ini" section "Varr" key "int" 0ACE: show_formatted_text_box "You have %d g." [email protected] wait 1000end wait 0end:STARTModel.Load(#WMYDRUG)038B: load_requested_modelsrepeat wait 0until Model.Available(#WMYDRUG)Actor.Create($DEALER, Dealer, #WMYDRUG, -490.372, 1504.965, 8.688)Actor.Angle($DEALER) = 121.0:check_in_spherewhile trueif00F3: actor $PLAYER_ACTOR near_actor $DEALER radius 1.8 1.8 sphere 0 on_footthen break // jump @NEAR_Trueeendif0AB0: key_pressed 0x49then 0AF0: [email protected] = get_int_from_ini_file "CLEO\VARR.ini" section "Varr" key "int" 0ACE: show_formatted_text_box "You have %d g." [email protected] wait 1000end wait 0end:NEAR_TrueePlayer.CanMove($PLAYER_CHAR, False)0ACE: show_formatted_text_box "Would you like to buy some weed, 20$ for a G?(Y or N?)"while trueif0AB0: key_pressed 0x59then break // jump @BUYendif0AB0: key_pressed 0x4Ethen 0ACE: show_formatted_text_box "Come back any time if you need the stuff." Player.CanMove($PLAYER_CHAR, True) wait 3500 goto @check_in_sphereend wait 0end:BUY0109: player $PLAYER_CHAR money += -200AF0: [email protected] = get_int_from_ini_file "CLEO\VARR.ini" section "Varr" key "int" /// get value0AB1: call_scm_func @IncreaseValue 1 actual_valuei [email protected] updated_valuei [email protected]: write_int [email protected] to_ini_file "CLEO\VARR.ini" section "Varr" key "int" /// update valuewhile true0ACE: show_formatted_text_box "Would you like some more (Y or N)?"if 00E1: player 0 pressed_key 11 // conversation - yesthen goto @NEAR_Trueeendif 00E1: player 0 pressed_key 10 // conversation - nothen 0ACE: show_formatted_text_box "Come back any time if you need the stuff." Player.CanMove($PLAYER_CHAR, True) wait 1500 breakend wait 0endgoto @check_in_sphere:[email protected]: [email protected]: [email protected] = [email protected]@ += 1 // Increase value0AB2: ret 1 [email protected]/*functions included;0AB1: call_scm_func @IncreaseValue 1 actual_valuei [email protected] updated_value [email protected]: call_scm_func @DecreaseValue 1 actual_valuei [email protected] updated_value [email protected]:[email protected]: [email protected]: [email protected] = [email protected]@ += 1 // Increase value0AB2: ret 1 [email protected]:[email protected]: [email protected]: [email protected] = [email protected]@ += -1 // Decrease value0AB2: ret 1 [email protected]*/ should work Not tested. 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