Hooks (client-side only)
You can use this feature to execute code on some events and modify the script behaviour.
Use RegisterHook export to add a hook and RemoveHook or RemoveResourceHooks exports to remove a hook
openMenu hook
openMenu hookThis hook will be triggered when the user opens the sound player UI. The payload sent to the hook function will contain:
soundId:
stringorniltype:
'carRadio'or'boombox'or'zone'vehicle:
numberornilboombox:
numberornilfromType:
stringornil
By returning false, the action will be canceled
Example:
local hookId = exports["evo_sound_player"]:RegisterHook('openMenu', function(payload)
print('Triggered openMenu hook')
print(' - SoundId: ', payload.soundId)
print(' - Type: ', payload.type)
print(' - Vehicle: ', payload.vehicle)
print(' - Boombox: ', payload.boombox)
print(' - Zone: ', payload.zone)
return true
end)closeMenu hook
closeMenu hookThis hook will be triggered when the user closes the sound player UI. The payload sent to the hook function will contain:
soundId:
stringorniltype:
'carRadio'or'boombox'or'zone'vehicle:
numberornilboombox:
numberornilfromType:
stringornil
By returning false, the action will be canceled
Example:
local hookId = exports["evo_sound_player"]:RegisterHook('closeMenu', function(payload)
print('Triggered closeMenu hook')
print(' - SoundId: ', payload.soundId)
print(' - Type: ', payload.type)
print(' - Vehicle: ', payload.vehicle)
print(' - Boombox: ', payload.boombox)
print(' - Zone: ', payload.zone)
return true
end)createSound hook
createSound hookThis hook will be triggered when the user starts playing a sound The payload sent to the hook function will contain:
type:
'carRadio'or'boombox'or'zone'vehicle:
numberornilboombox:
numberornilfromType:
stringornil
By returning false, the action will be canceled
Example:
local hookId = exports["evo_sound_player"]:RegisterHook('createSound', function(payload)
print('Triggered createSound hook.')
print(' - Type: ', payload.type)
print(' - Vehicle: ', payload.vehicle)
print(' - Boombox: ', payload.boombox)
print(' - Zone: ', payload.zone)
return true
end)Last updated