Jump to content

Police weapons


gtamoder1234

Recommended Posts

gtamoder1234

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: 10@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "1_Star" 
8AF0: 11@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "1_Star_gun"
8AF0: 12@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "2 Star" 
8AF0: 13@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "2_Star_gun"
8AF0: 14@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "3_Star" 
8AF0: 15@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "3_Star gun"
8AF0: 16@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "4_Star" 
0AF0: 17@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "4_Star gun"
8AF0: 18@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "5_Star" 
8AF0: 19@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "5_Star gun"
8AF0: 20@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "6_Star" 
8AF0: 21@ = 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 11@       
       038B: load_requested_models
       0A8C: 0x5DDCCD 1 10@ 1
       0A8C: 0x68BBB7 1 10@ 1
    end
    if
     010F:   player 0 wanted_level > 1
    then   
       0247: load_model 13@       
       038B: load_requested_models
       0A8C: 0x5DDCCD 1 12@ 1
       0A8C: 0x68BBB7 1 12@ 1
    end
    if
     010F:   player 0 wanted_level > 2
    then   
       0247: load_model 15@       
       038B: load_requested_models
       0A8C: 0x5DDCCD 1 14@ 1
       0A8C: 0x68BBB7 1 14@ 1
    end
   if
    010F:   player 0 wanted_level > 3
   then
       0247: load_model 17@       
       038B: load_requested_models
       0A8C: 0x5DDCCD 1 16@ 1
       0A8C: 0x68BBB7 1 16@ 1
    end
    if
     010F:   player 0 wanted_level > 4
    then   
       0247: load_model 19@       
       038B: load_requested_models
       0A8C: 0x5DDCCD 1 18@ 1
       0A8C: 0x68BBB7 1 18@ 1
    end
    if
     010F:   player 0 wanted_level > 5
    then
       0247: load_model 21@       
       038B: load_requested_models
       0A8C: 0x5DDCCD 1 20@ 1
       0A8C: 0x68BBB7 1 20@ 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

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

gtamoder1234

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 10@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "1_STAR"   // Weapon number
  not READ_INT_FROM_INI_FILE 11@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "1_STAR_GUN"  //Weapon Model ID
  not READ_INT_FROM_INI_FILE 12@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "2 STAR"   // Weapon number
  not READ_INT_FROM_INI_FILE 13@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "2_STAR_GUN"  //Weapon Model ID
  not READ_INT_FROM_INI_FILE 14@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "3_STAR"   // Weapon number
  not READ_INT_FROM_INI_FILE 15@ 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 16@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "4_STAR"   // Weapon number
  not READ_INT_FROM_INI_FILE 17@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "4_STAR GUN"  //Weapon Model ID
  not READ_INT_FROM_INI_FILE 18@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "5_STAR"   // Weapon number
  not READ_INT_FROM_INI_FILE 19@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "5_STAR GUN"  //Weapon Model ID
  not READ_INT_FROM_INI_FILE 20@ section "CLEO\CHANGE POLICE WEAPONS.INI" key "FOOT" store_to "6_STAR"   // Weapon number
  not READ_INT_FROM_INI_FILE 21@ 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 0@ 
IF 
  not 0@ == 1 
GOTO_IF_FALSE @NONAME_957 
IF 
  not 0@ == 2 
GOTO_IF_FALSE @NONAME_1004 
IF 
  not 0@ == 3 
GOTO_IF_FALSE @NONAME_1051 
IF 
  not 0@ == 4 
GOTO_IF_FALSE @NONAME_1098 
IF 
  not 0@ == 5 
GOTO_IF_FALSE @NONAME_1145 
IF 
  not 0@ == 6 
GOTO_IF_FALSE @NONAME_1192 
IF 
  0@ == 0 
GOTO_IF_FALSE @NONAME_910 

:NONAME_910
REQUEST_MODEL 11@ 
LOAD_ALL_MODELS_NOW 
WRITE_MEMORY 6151373 size 1 value 10@ vp 1 
WRITE_MEMORY 6863799 size 1 value 10@ vp 1 
WAIT 1000 
GOTO @NONAME_767 

:NONAME_957
REQUEST_MODEL 13@ 
LOAD_ALL_MODELS_NOW 
WRITE_MEMORY 6151373 size 1 value 12@ vp 1 
WRITE_MEMORY 6863799 size 1 value 12@ vp 1 
WAIT 1000 
GOTO @NONAME_767 

:NONAME_1004
REQUEST_MODEL 15@ 
LOAD_ALL_MODELS_NOW 
WRITE_MEMORY 6151373 size 1 value 14@ vp 1 
WRITE_MEMORY 6863799 size 1 value 14@ vp 1 
WAIT 1000 
GOTO @NONAME_767 

:NONAME_1051
REQUEST_MODEL 17@ 
LOAD_ALL_MODELS_NOW 
WRITE_MEMORY 6151373 size 1 value 16@ vp 1 
WRITE_MEMORY 6863799 size 1 value 16@ vp 1 
WAIT 1000 
GOTO @NONAME_767 

:NONAME_1098
REQUEST_MODEL 19@ 
LOAD_ALL_MODELS_NOW 
WRITE_MEMORY 6151373 size 1 value 18@ vp 1 
WRITE_MEMORY 6863799 size 1 value 18@ vp 1 
WAIT 1000 
GOTO @NONAME_767 

:NONAME_1145
REQUEST_MODEL 21@ 
LOAD_ALL_MODELS_NOW 
WRITE_MEMORY 6151373 size 1 value 20@ vp 1 
WRITE_MEMORY 6863799 size 1 value 20@ vp 1 
WAIT 1000 
GOTO @NONAME_767 

:NONAME_1192
REQUEST_MODEL 11@ 
LOAD_ALL_MODELS_NOW 
WRITE_MEMORY 6151373 size 1 value 10@ vp 1 
WRITE_MEMORY 6863799 size 1 value 10@ vp 1 
WAIT 1000 
GOTO @NONAME_767 

 

 

 

Edited by gtamoder1234
Link to comment
Share on other sites

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: 10@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "1_Star" 
    8AF0: 11@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "1_Star_gun"
    8AF0: 12@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "2 Star" 
    8AF0: 13@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "2_Star_gun"
    8AF0: 14@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "3_Star" 
    8AF0: 15@ = 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: 16@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "4_Star" 
        0AF0: 17@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "4_Star gun"
        8AF0: 18@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "5_Star" 
        8AF0: 19@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "5_Star gun"
        8AF0: 20@ = get_int_from_ini_file "cleo\Change Police Weapons.ini" section "Foot" key "6_Star" 
        8AF0: 21@ = 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: 17@ doesn't have the NOT opcode.

Edited by OrionSR
Link to comment
Share on other sites

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

gtamoder1234
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

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 by OrionSR
Link to comment
Share on other sites

gtamoder1234
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 0@ 
IF 
  not 0@ == 1 
GOTO_IF_FALSE @WANTED_GUNS_198 
IF 
  not 0@ == 2 
GOTO_IF_FALSE @WANTED_GUNS_235 
IF 
  not 0@ == 3 
GOTO_IF_FALSE @WANTED_GUNS_272 
IF 
  not 0@ == 4 
GOTO_IF_FALSE @WANTED_GUNS_309 
IF 
  not 0@ == 5 
GOTO_IF_FALSE @WANTED_GUNS_346 
IF 
  not 0@ == 6 
GOTO_IF_FALSE @WANTED_GUNS_383 
IF 
  0@ == 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 by gtamoder1234
Link to comment
Share on other sites

Sorry for the delay. It's been a tough week.

 

This script seems to be working properly - it's showing the correct messages, creating the right file and isn't crashing, but I haven't checked to see if it's actually swapping the weapons. I figured I'd leave the play testing to you.

 

Be sure to set the SA SCR edit mode before compiling.

The script will create a default INI file if none is found, and display a help message.

The script will use default settings if an error occurs while reading the INI data, and display a help message.

 

{$CLEO .cs}
{GunStar.txt}
{EditMode=SA_SCR}
{$USE ini}

const
  ini_file="cleo\GunStar.ini"
                                                     
  NightStick=3                       
  Pistol=22                          
  PistolSilenced=23                  
  DesertEagle=24                     
  Shotgun=25                         
  Sawnoff=26                         
  Spas12=27                          
  MicroUzi=28                        
  Mp5=29                             
  Ak47=30                            
  M4=31                              
  Tec9=32                            
  Rifle=33                           
  Sniper=34                          
  RocketLauncher=35                  
  RocketLauncherHs=36                
  Flamethrower=37                    
  Minigun=38                         

  footcop_gun1=0x5DDCBF // NightStick
  footcop_gun2=0x5DDCCD // Pistol    
  carcops_gun1=0x68BBAC // Shotgun   
  carcops_gun2=0x68BBB7 // Pistol    
  swat_gun1=0x5DDDA1 // MicroUzi     
  swat_gun2=0x5DDDAA // MicroUzi     
  fbi_gun1=0x5DDDE1 // Mp5           
  fbi_gun2=0x5DDDEA // Mp5           
  army_gun1=0x5DDE21 // M4           
  army_gun2=0x5DDE2A // M4           

  wanted_level=6@                    
  footcop_array=10@                  
end

SCRIPT_NAME 'GUNSTAR'
WAIT 5000

if
  DOES_FILE_EXIST ini_file
then
  GOSUB @Read_INI_File
else
  PRINT_HELP_FORMATTED "GunStar:~n~INI file not found. Creating new file."
  GOSUB @Init_Footcop_Array
  GOSUB @Create_INI_File
end

while true
  WAIT 50
  if
    IS_PLAYER_PLAYING $PLAYER_CHAR
  then
    STORE_WANTED_LEVEL $PLAYER_CHAR wanted_level
    WRITE_MEMORY footcop_gun2 size 1 val footcop_array(wanted_level,7i) vp 1
    WRITE_MEMORY carcops_gun2 size 1 val footcop_array(wanted_level,7i) vp 1
  end
end
TERMINATE_THIS_CUSTOM_SCRIPT


:Read_INI_File
if or
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "0_STAR" store_to footcop_array[0]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "1_STAR" store_to footcop_array[1]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "2_STAR" store_to footcop_array[2]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "3_STAR" store_to footcop_array[3]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "4_STAR" store_to footcop_array[4]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "5_STAR" store_to footcop_array[5]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "6_STAR" store_to footcop_array[6]
then
  PRINT_HELP_FORMATTED "GunStar:~n~Error reading INI file. Using default values."
  GOSUB @Init_Footcop_Array
end
RETURN

:Init_Footcop_Array
SET_LVAR_INT_TO_CONSTANT footcop_array[0] Pistol
SET_LVAR_INT_TO_CONSTANT footcop_array[1] Pistol
SET_LVAR_INT_TO_CONSTANT footcop_array[2] Pistol
SET_LVAR_INT_TO_CONSTANT footcop_array[3] Spas12
SET_LVAR_INT_TO_CONSTANT footcop_array[4] Mp5
SET_LVAR_INT_TO_CONSTANT footcop_array[5] Rifle
SET_LVAR_INT_TO_CONSTANT footcop_array[6] M4
RETURN

:Create_INI_File
WRITE_INT_TO_INI_FILE footcop_array[0] path ini_file section "FOOTCOP" key "0_STAR"
WRITE_INT_TO_INI_FILE footcop_array[1] path ini_file section "FOOTCOP" key "1_STAR"
WRITE_INT_TO_INI_FILE footcop_array[2] path ini_file section "FOOTCOP" key "2_STAR"
WRITE_INT_TO_INI_FILE footcop_array[3] path ini_file section "FOOTCOP" key "3_STAR"
WRITE_INT_TO_INI_FILE footcop_array[4] path ini_file section "FOOTCOP" key "4_STAR"
WRITE_INT_TO_INI_FILE footcop_array[5] path ini_file section "FOOTCOP" key "5_STAR"
WRITE_INT_TO_INI_FILE footcop_array[6] path ini_file section "FOOTCOP" key "6_STAR"
RETURN

 

Edited by OrionSR
Link to comment
Share on other sites

gtamoder1234
1 hour ago, OrionSR said:

Sorry for the delay. It's been a tough week.

 

This script seems to be working properly - it's showing the correct messages, creating the right file and isn't crashing, but I haven't checked to see if it's actually swapping the weapons. I figured I'd leave the play testing to you.

 

Be sure to set the SA SCR edit mode before compiling.

The script will create a default INI file if none is found, and display a help message.

The script will use default settings if an error occurs while reading the INI data, and display a help message.

 

{$CLEO .cs}
{GunStar.txt}
{EditMode=SA_SCR}
{$USE ini}

const
  ini_file="cleo\GunStar.ini"
                                                     
  NightStick=3                       
  Pistol=22                          
  PistolSilenced=23                  
  DesertEagle=24                     
  Shotgun=25                         
  Sawnoff=26                         
  Spas12=27                          
  MicroUzi=28                        
  Mp5=29                             
  Ak47=30                            
  M4=31                              
  Tec9=32                            
  Rifle=33                           
  Sniper=34                          
  RocketLauncher=35                  
  RocketLauncherHs=36                
  Flamethrower=37                    
  Minigun=38                         

  footcop_gun1=0x5DDCBF // NightStick
  footcop_gun2=0x5DDCCD // Pistol    
  carcops_gun1=0x68BBAC // Shotgun   
  carcops_gun2=0x68BBB7 // Pistol    
  swat_gun1=0x5DDDA1 // MicroUzi     
  swat_gun2=0x5DDDAA // MicroUzi     
  fbi_gun1=0x5DDDE1 // Mp5           
  fbi_gun2=0x5DDDEA // Mp5           
  army_gun1=0x5DDE21 // M4           
  army_gun2=0x5DDE2A // M4           

  wanted_level=6@                    
  footcop_array=10@                  
end

SCRIPT_NAME 'GUNSTAR'
WAIT 5000

if
  DOES_FILE_EXIST ini_file
then
  GOSUB @Read_INI_File
else
  PRINT_HELP_FORMATTED "GunStar:~n~INI file not found. Creating new file."
  GOSUB @Init_Footcop_Array
  GOSUB @Create_INI_File
end

while true
  WAIT 50
  if
    IS_PLAYER_PLAYING $PLAYER_CHAR
  then
    STORE_WANTED_LEVEL $PLAYER_CHAR wanted_level
    WRITE_MEMORY footcop_gun2 size 1 val footcop_array(wanted_level,7i) vp 1
    WRITE_MEMORY carcops_gun2 size 1 val footcop_array(wanted_level,7i) vp 1
  end
end
TERMINATE_THIS_CUSTOM_SCRIPT


:Read_INI_File
if or
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "0_STAR" store_to footcop_array[0]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "1_STAR" store_to footcop_array[1]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "2_STAR" store_to footcop_array[2]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "3_STAR" store_to footcop_array[3]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "4_STAR" store_to footcop_array[4]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "5_STAR" store_to footcop_array[5]
  not READ_INT_FROM_INI_FILE ini_file section "FOOTCOP" key "6_STAR" store_to footcop_array[6]
then
  PRINT_HELP_FORMATTED "GunStar:~n~Error reading INI file. Using default values."
  GOSUB @Init_Footcop_Array
end
RETURN

:Init_Footcop_Array
SET_LVAR_INT_TO_CONSTANT footcop_array[0] Pistol
SET_LVAR_INT_TO_CONSTANT footcop_array[1] Pistol
SET_LVAR_INT_TO_CONSTANT footcop_array[2] Pistol
SET_LVAR_INT_TO_CONSTANT footcop_array[3] Spas12
SET_LVAR_INT_TO_CONSTANT footcop_array[4] Mp5
SET_LVAR_INT_TO_CONSTANT footcop_array[5] Rifle
SET_LVAR_INT_TO_CONSTANT footcop_array[6] M4
RETURN

:Create_INI_File
WRITE_INT_TO_INI_FILE footcop_array[0] path ini_file section "FOOTCOP" key "0_STAR"
WRITE_INT_TO_INI_FILE footcop_array[1] path ini_file section "FOOTCOP" key "1_STAR"
WRITE_INT_TO_INI_FILE footcop_array[2] path ini_file section "FOOTCOP" key "2_STAR"
WRITE_INT_TO_INI_FILE footcop_array[3] path ini_file section "FOOTCOP" key "3_STAR"
WRITE_INT_TO_INI_FILE footcop_array[4] path ini_file section "FOOTCOP" key "4_STAR"
WRITE_INT_TO_INI_FILE footcop_array[5] path ini_file section "FOOTCOP" key "5_STAR"
WRITE_INT_TO_INI_FILE footcop_array[6] path ini_file section "FOOTCOP" key "6_STAR"
RETURN

 

nice works as a charm

 

 

Edited by gtamoder1234
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.