shared
GetCurrentResourceName
FiveM shared native documentation with a Lua example.
Summary
Returns the name of the resource the code is running in. Used to filter resource events and to reference your own resource generically.
Returns
string — the resource name.
Example
AddEventHandler('onResourceStart', function(res)
if res == GetCurrentResourceName() then
-- only run for my own resource
end
end)Common pitfalls
- Pairs naturally with onResourceStart/Stop to run setup/cleanup only for your resource.
- Lets you write portable code that doesn't hardcode the folder name.
Related natives
Related guides
FiveM scripts done right
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.
Browse Scripts →