shared
GetHashKey
FiveM shared native documentation with a Lua example.
Summary
Converts a string (model name, weapon name, etc.) into its integer hash, which most natives require. In modern Lua you can use backtick syntax model for literals.
Returns
Hash (number) — the integer hash of the string.
Parameters
inputstringThe string to hash (e.g. 'adder', 'WEAPON_PISTOL').Example
local hash = GetHashKey('adder')
-- Modern literal syntax (compile-time, faster):
local hash2 = `adder`
-- Backtick only works with literal strings, not variables.Common pitfalls
- For literal strings, backtick hashing (
adder) is faster than GetHashKey('adder'). - For dynamic/variable strings, GetHashKey() is still required — backticks only work on literals.
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 →