gtamoder1234 Posted Monday at 08:39 PM Share Posted Monday at 08:39 PM Hello every one im making a script that upgrades police weapons with wanted level my question is what em i missing here is y code {$CLEO} {$USE ini} wait 500 if and 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "1_Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "1_Star_gun" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "2 Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "2_Star_gun" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "3_Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "3_Star gun" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "4_Star" 0AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "4_Star gun" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "5_Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "5_Star gun" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "6_Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "6_Star gun" then 0ACD: show_text_highpriority "Fail to read 'Change Police Weapons.ini'" time 10000 0A93: end_custom_thread end repeat wait 0 if 010F: player 0 wanted_level > 0 then 0247: load_model [email protected] 038B: load_requested_models 0A8C: 0x5DDCCD 1 [email protected] 1 0A8C: 0x68BBB7 1 [email protected] 1 end if 010F: player 0 wanted_level > 1 then 0247: load_model [email protected] 038B: load_requested_models 0A8C: 0x5DDCCD 1 [email protected] 1 0A8C: 0x68BBB7 1 [email protected] 1 end if 010F: player 0 wanted_level > 2 then 0247: load_model [email protected] 038B: load_requested_models 0A8C: 0x5DDCCD 1 [email protected] 1 0A8C: 0x68BBB7 1 [email protected] 1 end if 010F: player 0 wanted_level > 3 then 0247: load_model [email protected] 038B: load_requested_models 0A8C: 0x5DDCCD 1 [email protected] 1 0A8C: 0x68BBB7 1 [email protected] 1 end if 010F: player 0 wanted_level > 4 then 0247: load_model [email protected] 038B: load_requested_models 0A8C: 0x5DDCCD 1 [email protected] 1 0A8C: 0x68BBB7 1 [email protected] 1 end if 010F: player 0 wanted_level > 5 then 0247: load_model [email protected] 038B: load_requested_models 0A8C: 0x5DDCCD 1 [email protected] 1 0A8C: 0x68BBB7 1 [email protected] 1 end 0A93: end_custom_thread forgot to mention i used Junior_Djjr's Change_police_weapons script as a start point Link to comment Share on other sites More sharing options...
OrionSR Posted Monday at 09:24 PM Share Posted Monday at 09:24 PM The error that stands out is too many conditions for IF AND, which I believe is limited to 8. You'll need to break this block up a little. Link to comment Share on other sites More sharing options...
gtamoder1234 Posted Monday at 09:54 PM Author Share Posted Monday at 09:54 PM (edited) how 15 hours ago, OrionSR said: The error that stands out is too many conditions for IF AND, which I believe is limited to 8. You'll need to break this block up a little. how about that // This file was decompiled using SASCM.ini published on 2021-07-05 {$CLEO .cs} {$USE ini} // INI file script part WAIT 1000 IF and not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "1_STAR" // Weapon number not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "1_STAR_GUN" //Weapon Model ID not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "2 STAR" // Weapon number not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "2_STAR_GUN" //Weapon Model ID not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "3_STAR" // Weapon number not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "3_STAR GUN" //Weapon Model ID GOTO_IF_FALSE @NONAME_389 PRINT_STRING_NOW "FAIL TO READ 'CHANGE POLICE WEAPONS.INI'" time 10000 TERMINATE_THIS_CUSTOM_SCRIPT GOTO @NONAME_767 :NONAME_389 IF and not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "4_STAR" // Weapon number not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "4_STAR GUN" //Weapon Model ID not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "5_STAR" // Weapon number not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "5_STAR GUN" //Weapon Model ID not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "6_STAR" // Weapon number not READ_INT_FROM_INI_FILE [email protected] section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "6_STAR GUN" //Weapon Model ID GOTO_IF_FALSE @NONAME_767 PRINT_STRING_NOW "FAIL TO READ 'CHANGE POLICE WEAPONS.INI'" time 10000 TERMINATE_THIS_CUSTOM_SCRIPT //Weapon Change Script Part :NONAME_767 WAIT 200 IF STORE_WANTED_LEVEL $PLAYER_CHAR store_to [email protected] IF not [email protected] == 1 GOTO_IF_FALSE @NONAME_957 IF not [email protected] == 2 GOTO_IF_FALSE @NONAME_1004 IF not [email protected] == 3 GOTO_IF_FALSE @NONAME_1051 IF not [email protected] == 4 GOTO_IF_FALSE @NONAME_1098 IF not [email protected] == 5 GOTO_IF_FALSE @NONAME_1145 IF not [email protected] == 6 GOTO_IF_FALSE @NONAME_1192 IF [email protected] == 0 GOTO_IF_FALSE @NONAME_910 :NONAME_910 REQUEST_MODEL [email protected] LOAD_ALL_MODELS_NOW WRITE_MEMORY 6151373 size 1 value [email protected] vp 1 WRITE_MEMORY 6863799 size 1 value [email protected] vp 1 WAIT 1000 GOTO @NONAME_767 :NONAME_957 REQUEST_MODEL [email protected] LOAD_ALL_MODELS_NOW WRITE_MEMORY 6151373 size 1 value [email protected] vp 1 WRITE_MEMORY 6863799 size 1 value [email protected] vp 1 WAIT 1000 GOTO @NONAME_767 :NONAME_1004 REQUEST_MODEL [email protected] LOAD_ALL_MODELS_NOW WRITE_MEMORY 6151373 size 1 value [email protected] vp 1 WRITE_MEMORY 6863799 size 1 value [email protected] vp 1 WAIT 1000 GOTO @NONAME_767 :NONAME_1051 REQUEST_MODEL [email protected] LOAD_ALL_MODELS_NOW WRITE_MEMORY 6151373 size 1 value [email protected] vp 1 WRITE_MEMORY 6863799 size 1 value [email protected] vp 1 WAIT 1000 GOTO @NONAME_767 :NONAME_1098 REQUEST_MODEL [email protected] LOAD_ALL_MODELS_NOW WRITE_MEMORY 6151373 size 1 value [email protected] vp 1 WRITE_MEMORY 6863799 size 1 value [email protected] vp 1 WAIT 1000 GOTO @NONAME_767 :NONAME_1145 REQUEST_MODEL [email protected] LOAD_ALL_MODELS_NOW WRITE_MEMORY 6151373 size 1 value [email protected] vp 1 WRITE_MEMORY 6863799 size 1 value [email protected] vp 1 WAIT 1000 GOTO @NONAME_767 :NONAME_1192 REQUEST_MODEL [email protected] LOAD_ALL_MODELS_NOW WRITE_MEMORY 6151373 size 1 value [email protected] vp 1 WRITE_MEMORY 6863799 size 1 value [email protected] vp 1 WAIT 1000 GOTO @NONAME_767 Edited Tuesday at 12:28 PM by gtamoder1234 Link to comment Share on other sites More sharing options...
gtamoder1234 Posted Monday at 10:00 PM Author Share Posted Monday at 10:00 PM (edited) my goal is to make script like that https://libertycity.net/files/gta-vice-city/84004-police-weapons-upgrade.html but with ini file and for san andreas Edited Monday at 10:13 PM by gtamoder1234 Link to comment Share on other sites More sharing options...
OrionSR Posted Monday at 10:23 PM Share Posted Monday at 10:23 PM (edited) 29 minutes ago, gtamoder1234 said: my goal is to make script like... I'm not evaluating what the script is doing, just the logic error with the IF AND statement. I was expecting something more like this: if and 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "1_Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "1_Star_gun" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "2 Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "2_Star_gun" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "3_Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "3_Star gun" then 0ACD: show_text_highpriority "Fail to read 'Change Police Weapons.ini'" time 10000 0A93: end_custom_thread else if and 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "4_Star" 0AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "4_Star gun" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "5_Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "5_Star gun" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "6_Star" 8AF0: [email protected] = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "6_Star gun" then 0ACD: show_text_highpriority "Fail to read 'Change Police Weapons.ini'" time 10000 0A93: end_custom_thread end end Note the use of code tags (<> in the edit menu). Next time, please post modding questions in the modding forum. Added: Actually, that doesn't look right either; the logic seems backwards. I'm expecting the script to end if any value can't be read, so this seems backwards. However, I don't have time to investigate further. (Oh wait, not opcode used but not included in the statement, very confusing.) Update: [email protected] doesn't have the NOT opcode. Edited Monday at 10:29 PM by OrionSR Link to comment Share on other sites More sharing options...
OrionSR Posted yesterday at 09:52 AM Share Posted yesterday at 09:52 AM I think I made a major error with my suggestion. IF OR should be used in this case; if any line fails to read then throw the error and terminate. However, the logic still seems awkward. I might try again tomorrow if you don't work it out sooner. I'm concerned about the single quotes corrupting your text string. Consider doing without until the script is working properly. I much preferred the high-level format used in your original script. SCR mode is fine; consider adding a comment in the header. Ctrl+H (default hotkey) can be used to convert your addresses back to the preferred hex format. The linked file you posted to the VC script in the other topic was rejected as dangerous. The link here was good though, and it looks like you changed the addresses to SA. If you rewrite the script to avoid the ini data, does it work properly? 0AF0/8AF0 I'm pretty sure that this opcode is "// IF and SET" but the opcodes don't include these notes anymore. It would be wise to verify that this opcode actually works as expected in a simpler test script, or existing scripts if you've got them. It's good practice to name any script that will loop in memory. The script name is the handle used to terminate or find the script's location, etc. "cleo\Change Police Weapons.ini" I doubt this is a problem as used, but if you're still getting odd errors, try limiting this string to 15 characters and/or avoiding spaces. Please post your ini file. Link to comment Share on other sites More sharing options...
gtamoder1234 Posted 21 hours ago Author Share Posted 21 hours ago 3 hours ago, OrionSR said: I think I made a major error with my suggestion. IF OR should be used in this case; if any line fails to read then throw the error and terminate. However, the logic still seems awkward. I might try again tomorrow if you don't work it out sooner. I'm concerned about the single quotes corrupting your text string. Consider doing without until the script is working properly. I much preferred the high-level format used in your original script. SCR mode is fine; consider adding a comment in the header. Ctrl+H (default hotkey) can be used to convert your addresses back to the preferred hex format. The linked file you posted to the VC script in the other topic was rejected as dangerous. The link here was good though, and it looks like you changed the addresses to SA. If you rewrite the script to avoid the ini data, does it work properly? 0AF0/8AF0 I'm pretty sure that this opcode is "// IF and SET" but the opcodes don't include these notes anymore. It would be wise to verify that this opcode actually works as expected in a simpler test script, or existing scripts if you've got them. It's good practice to name any script that will loop in memory. The script name is the handle used to terminate or find the script's location, etc. "cleo\Change Police Weapons.ini" I doubt this is a problem as used, but if you're still getting odd errors, try limiting this string to 15 characters and/or avoiding spaces. Please post your ini file. i got rid of INI prat and i works like a charm Link to comment Share on other sites More sharing options...
OrionSR Posted 2 hours ago Share Posted 2 hours ago (edited) Any luck teasing out the problems with the ini segment? It seemed like you were really close. 0x68BBB7 Please describe this address or provide additional reference if possible. Best as I can tell, it has something to do with where the weapon for patrol car cops is set to pistol instead of shotgun. Is this required to set weapon 2 active instead of the nightstick (weapon 1)? Maybe... CarCops? 0x68BBB7 colt45 0x68BBAC chromegun (untested) I found some addition reference for similar addresses: (See also: memory topic; includes accuracy addresses) Cops: 0x5DDCBF - weapon 1 (nitestick) 0x5DDCCD - weapon 2 (colt45) FBI: 0x5DDDE1 and 0x5DDDEA - weapon (mp5; change both) Army: 0x5DDE21 and 0x5DDE2A - weapon (m4; change both) Swat: 0x5DDDA1 and 0x5DDDAA - weapon (mac10; change both) Please post your INI file. I don't have enough data to complete a script. 20 hours ago, gtamoder1234 said: i got rid of INI prat and i works like a charm Please post the variable assignments segment. I want to use it when the INI file isn't found. Would you prefer the standard Show Opcodes format or SA SCR? Edited 40 minutes ago by OrionSR Link to comment Share on other sites More sharing options...
gtamoder1234 Posted 39 minutes ago Author Share Posted 39 minutes ago (edited) 1 hour ago, OrionSR said: Any luck teasing out the problems with the ini segment? It seemed like you were really close. 0x68BBB7 Please describe this address or provide additional reference if possible. Best as I can tell, it has something to do with where the weapon for patrol car cops is set to pistol instead of shotgun. Is this required to set weapon 2 active instead of the nightstick (weapon 1)? Maybe... CarCops? 0x68BBB7 colt45 0x68BBAC chromegun (untested) I found some addition reference for similar addresses: Cops: 0x5DDCBF - weapon 1 (nitestick) 0x5DDCCD - weapon 2 (colt45) FBI: 0x5DDDE1 and 0x5DDDEA - weapon (mp5; change both) Army: 0x5DDE21 and 0x5DDE2A - weapon (m4; change both) Swat: 0x5DDDA1 and 0x5DDDAA - weapon (mac10; change both) Please post your INI file. I don't have enough data to complete a script. Please post the variable assignments segment. I want to use it when the INI file isn't found. Would you prefer the standard Show Opcodes format or SA SCR? oh i didnt do that here is current script [b] // This file was decompiled using SASCM.ini published on 2021-07-05 {$CLEO .cs} SCRIPT_NAME 'WANTED_GUNS' :WANTED_GUNS_19 WAIT 0 IF STORE_WANTED_LEVEL $PLAYER_CHAR store_to [email protected] IF not [email protected] == 1 GOTO_IF_FALSE @WANTED_GUNS_198 IF not [email protected] == 2 GOTO_IF_FALSE @WANTED_GUNS_235 IF not [email protected] == 3 GOTO_IF_FALSE @WANTED_GUNS_272 IF not [email protected] == 4 GOTO_IF_FALSE @WANTED_GUNS_309 IF not [email protected] == 5 GOTO_IF_FALSE @WANTED_GUNS_346 IF not [email protected] == 6 GOTO_IF_FALSE @WANTED_GUNS_383 IF [email protected] == 0 GOTO_IF_FALSE @WANTED_GUNS_161 :WANTED_GUNS_161 //Wanted level 0 WRITE_MEMORY 6151373 size 1 value 22 vp 1 WRITE_MEMORY 6863799 size 1 value 22 vp 1 WAIT 10 GOTO @WANTED_GUNS_19 :WANTED_GUNS_198 //Wanted level 1 WRITE_MEMORY 6151373 size 1 value 22 vp 1 WRITE_MEMORY 6863799 size 1 value 22 vp 1 WAIT 10 GOTO @WANTED_GUNS_19 :WANTED_GUNS_235 //Wanted level 2 WRITE_MEMORY 6151373 size 1 value 22 vp 1 WRITE_MEMORY 6863799 size 1 value 22 vp 1 WAIT 10 GOTO @WANTED_GUNS_19 :WANTED_GUNS_272 //Wanted level 3 WRITE_MEMORY 6151373 size 1 value 27 vp 1 WRITE_MEMORY 6863799 size 1 value 27 vp 1 WAIT 0 GOTO @WANTED_GUNS_19 :WANTED_GUNS_309 //Wanted level 4 WRITE_MEMORY 6151373 size 1 value 29 vp 1 WRITE_MEMORY 6863799 size 1 value 29 vp 1 WAIT 0 GOTO @WANTED_GUNS_19 :WANTED_GUNS_346 //Wanted level 5 WRITE_MEMORY 6151373 size 1 value 33 vp 1 WRITE_MEMORY 6863799 size 1 value 33 vp 1 WAIT 0 GOTO @WANTED_GUNS_19 :WANTED_GUNS_383 //Wanted level 6 WRITE_MEMORY 6151373 size 1 value 31 vp 1 WRITE_MEMORY 6863799 size 1 value 31 vp 1 WAIT 0 GOTO @WANTED_GUNS_19 [/b] Edited 32 minutes ago by gtamoder1234 Link to comment Share on other sites More sharing options...