Hi, so i dont really use python to do anything, but i decided to get chatgpt to write something for me today.
So i have to type AI=fixed Under RESTRICTOR=0 but only if the MODEL=name contains traffic (as shown below)
[CAR_63]
MODEL=traffic_dodge_challenger_srt
SKIN=00_sepang_blue_pearl_effect_br
SPECTATOR_MODE=0
DRIVERNAME=
TEAM=
GUID=
BALLAST=0
RESTRICTOR=0
AI=fixed
with the following script, it doesnt run it correctly. It opens the script for under half a second than dissapeers without even modifying the entry_list.cfg file. How may i fix this
`# Define the file path
file_path = 'entry_list.cfg'
Open the file and read its contents
with open(file_path, 'r') as file:
lines = file.readlines()
Iterate through the lines and modify as needed
modified_lines = []
for line in lines:
# Check if the line contains "MODEL=traffic"
if 'MODEL=traffic' in line:
# Add "AI=fixed" under "RESTRICTOR=0"
if line.strip().startswith('RESTRICTOR=0'):
modified_lines.append(line)
modified_lines.append('AI=fixed\n')
else:
modified_lines.append(line)
else:
modified_lines.append(line)
Write the modified content back to the file
with open(file_path, 'w') as file:
file.writelines(modified_lines)`