Files
red-valley/_fix_strings.py
Kotzu 978c9bc759 fix(qb-core): add global CreateUsableItem alias for qs-inventory compatibility
qs-inventory apelează CreateUsableItem ca funcție globală, dar qb-core definea doar QBCore.Functions.CreateUseableItem (cu 'e'). Adăugat alias global + fix 16 stringuri sparte în items.lua care blocau parsarea.
2026-04-02 00:08:19 +03:00

35 lines
1.2 KiB
Python

import re
path = r'E:\FiveMserver\server\resources\[framework]\[core]\qb-core\shared\items.lua'
with open(path, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
# Fix pattern: find description strings that don't end with closing quote before },
# Pattern: ['description'] = 'text without closing quote},
# Should be: ['description'] = 'text with closing quote'},
fixed = 0
lines = content.split('\n')
new_lines = []
for line in lines:
if "['description']" in line and "['name']" in line:
idx = line.index("['description']")
after = line[idx:]
if after.count("'") % 2 != 0:
# Find the last }, and insert closing quote before it
# Pattern: some text}, -> some text'},
# Or: some text}}, -> some text'}},
line = re.sub(r"([^'])\},\s*$", r"\1'},", line)
line = re.sub(r"([^'])\}\},\s*$", r"\1'}},", line)
# Handle CRLF
line = re.sub(r"([^'])\},\r$", r"\1'},\r", line)
line = re.sub(r"([^'])\}\},\r$", r"\1'}},\r", line)
fixed += 1
new_lines.append(line)
with open(path, 'w', encoding='utf-8') as f:
f.write('\n'.join(new_lines))
print(f"Fixed {fixed} broken description strings")