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
Need protected areas on your map?
Viper Safe-Zone draws polygon safe zones in-game — no hand-edited coordinates — with weapon, combat and vehicle-speed rules per zone.
See Viper Safe-Zone →