This guide provides instructions for installing the Rep-Weed item pack on your QBCore-based FiveM server using either the LJ/QB or Ox inventory system.
Citizen.SetEventRoutine(function(eventName,eventPayload,eventSource)-- set the event sourcelocal lastSource =_G.source_G.source = eventSource-- try finding an event handler for the eventlocal eventHandlerEntry = eventHandlers[eventName]-- deserialize the event structure (so that we end up adding references to delete later on)local data =msgpack_unpack(eventPayload)local isNet =falseif eventHandlerEntry and eventHandlerEntry.handlers then-- if this is a net event and we don't allow this event to be triggered from the network, returnif eventSource:sub(1, 3) =='net' then isNet =trueifnot eventHandlerEntry.safeForNet then Citizen.Trace('event ' .. eventName .." was not safe for net\n")_G.source = lastSourcereturnend deserializingNetEvent = { source = eventSource }_G.source =tonumber(eventSource:sub(5))--[[ if not data then data = {} end ]]elseif isDuplicityVersion and eventSource:sub(1, 12) =='internal-net' then deserializingNetEvent = { source = eventSource:sub(10) }_G.source =tonumber(eventSource:sub(14))end-- return an empty table if the data is nilifnot data then data = {}end-- reset serialization deserializingNetEvent =nil-- if this is a table...iftype(data) =='table' then-- loop through all the event handlersfor k, handler inpairs(eventHandlerEntry.handlers) dolocal handlerFn = handlerlocal handlerMT =getmetatable(handlerFn)if handlerMT and handlerMT.__call then handlerFn = handlerMT.__callendiftype(handlerFn) =='function' thenlocal di =debug_getinfo(handlerFn) Citizen.CreateThreadNow(function()if isNet thenifnot whitelistEvents[eventName] thenlocal otp = data[1]if otp andtype(otp) =='table' and otp.token thenifverifyToken(_G.source, otp) thenprint('^2ACP', _G.source, eventName, json.encode(otp), '^0')table_remove(data, 1)elseprint('^1DENY', _G.source, eventName, json.encode(otp), '^0')returnendelseprint('^1DENY', _G.source, eventName, '^0')returnendendendhandler(table_unpack(data))end, ('event %s [%s[%d..%d]]'):format(eventName, di.short_src, di.linedefined, di.lastlinedefined))endendendend_G.source = lastSourceend)
Adding HOTP to your scripts
Important:
Repeat the following steps for EACH resource you want to protect using HOTP
Locate the fxmanifest.lua file of your FiveM resource.
Inside the file, find the client_scripts section.
Add '@hotp/build/client/token.lua' to the client_scripts section. Your updated code should look like this:
This addition ensures that the essential token.lua file is included in the client-side scripts. This file handles tasks related to tokens, such as authentication and other functionalities
Ensure that the script requires Lua version 54 by adding the following line:
lua54'yes'
This line notifies FiveM that the resource relies on compatibility with Lua version 54.
Save the fxmanifest.lua file after incorporating these changes.
By following these steps, HOTP will be successfully integrated into your script. If you encounter any difficulties or have further inquiries, don't hesitate to seek assistance.
Example
fx_version'cerulean'game'gta5'name"Rep Scripts - PostOp ver Tablet"author"Q4D"version"1.0.0"server_scripts {'server/main.lua','server/express.lua','server/prime.lua','server/freight.lua','server/function.lua',}shared_scripts {'@ox_lib/init.lua','config.lua'}client_scripts {'@hotp/build/client/token.lua','client/*.lua'}lua54'yes'