HTNFW Script Conversion Guide
HTNFW Script Conversion Guide
This guide is for converting scripts from ESX/QBCore to HTNFW.
Rules You Must Follow
- Save ownership with
cid(characters.id), notsource. - Use framework exports for money updates. Do not manually change cash/bank vars.
- Always nil-check player data before using it.
Convert One Script In This Order
- Replace server player fetch.
- Use:
exports['htn-framework']:CharacterInformation(source, 'all')
- Use:
- Replace client player fetch.
- Use:
exports['htn-framework']:getCharacterInfo('all')
- Use:
- Replace money logic.
- Use:
exports['htn-framework']:CurrencyUpdate(...)
- Use:
- Replace job checks.
- Use:
character.job.name,character.job.rank,character.job.lable,character.job.header
- Use:
- Replace DB owner id fields.
- Old:
source - New:
cid/stateId
- Old:
- Test reconnect and ownership.
- Data should still belong to correct character after relog.
Quick API Calls
Server
- Full player data:
exports['htn-framework']:CharacterInformation(source, 'all')
- Player cid only:
exports['htn-framework']:CharacterInformation(source, 'id')
- Add/remove money:
exports['htn-framework']:CurrencyUpdate(stateId, 'cash' or 'bank', {_source=source, update=amount, status=true or false})status=trueadds moneystatus=falseremoves money
- Get online player by cid:
exports['htn-framework']:GetPlayerFromCid(cid)
- Permission check:
exports['htn-framework']:perm({comp='hasPermission', data={sourceId=src, event='permission_name'}})
Client
- Full local player data:
exports['htn-framework']:getCharacterInfo('all')
- Job only:
exports['htn-framework']:getCharacterInfo('job')
- Cash/bank only:
exports['htn-framework']:getCharacterInfo('currency')
Copy/Paste Examples
Server: Get Player + CID
local char = exports['htn-framework']:CharacterInformation(source, 'all')
if not char then return end
local cid = char.id
local fullName = (char.first_name or '') .. ' ' .. (char.last_name or '')
Server: Add/Remove Money
local char = exports['htn-framework']:CharacterInformation(source, 'all')
if not char then return end
-- Add 500 bank
exports['htn-framework']:CurrencyUpdate(char.id, 'bank', {
_source = source,
update = 500,
status = true
})
-- Remove 200 cash
exports['htn-framework']:CurrencyUpdate(char.id, 'cash', {
_source = source,
update = 200,
status = false
})
Client: Job/Currency
local p = exports['htn-framework']:getCharacterInfo('all')
if not p then return end
local jobName = p.job and p.job.name or 'unemployed'
local cash = p.currency and p.currency.cash or 0
local bank = p.currency and p.currency.bank or 0
Server: Set Job
TriggerEvent('htn-framework:UpdatePlayerJob', targetStateId, {
job = 'police',
rank = 2
})