SC R ng "..."]:58: bad argument #1 to 'gsub' (string expected, got nil) > get_wname (local items = {} items["dirty_money"] = {"Soldi sporchi","Soldi pieni di inchiostro da ripulire.",nil,0} items["parcels"] = {"Parcels","Parcels to deliver",nil,0.10} items["repairkit"] = {"Kit di riparazione","Kit di riparazione per i veicoli",nil,0.5} -- money items["money"] = {"Money","Packed money.",function(args) local choices = {} local idname = args[1] choices["Unpack"] = {function(player,choice,mod) local user_id = vRP.getUserId(player) if user_id ~= nil then local amount = vRP.getInventoryItemAmount(user_id, idname) vRP.prompt(player, "How much to unpack ? (max "..amount..")", "", function(player,ramount) ramount = parseInt(ramount) if vRP.tryGetInventoryItem(user_id, idname, ramount, true) then -- unpack the money vRP.giveMoney(user_id, ramount) vRP.closeMenu(player) end end) end end} return choices end,0} -- money binder items["money_binder"] = {"Money binder","Used to bind 1000$ of money.",function(args) local choices = {} local idname = args[1] choices["Bind money"] = {function(player,choice,mod) -- bind the money local user_id = vRP.getUserId(player) if user_id ~= nil then local money = vRP.getMoney(user_id) if money >= 1000 then if vRP.tryGetInventoryItem(user_id, idname, 1, true) and vRP.tryPayment(user_id,1000) then vRP.giveInventoryItem(user_id, "money", 1000, true) vRP.closeMenu(player) end else vRPclient.notify(player,{vRP.lang.money.not_enough()}) end end end} return choices end,0} -- parametric weapon items -- give "wbody|WEAPON_PISTOL" and "wammo|WEAPON_PISTOL" to have pistol body and pistol bullets local get_wname = function(weapon_id) local name = string.gsub(weapon_id,"WEAPON_","") name = string.upper(string.sub(name,1,1))..string.lower(string.sub(name,2)) return name end --- weapon body local wbody_name = function(args) return get_wname(args[2]).." body" end local wbody_desc = function(args) return "" end local wbody_choices = function(args) local choices = {} local fullidname = joinStrings(args,"|") choices["Equipaggia"] = {function(player,choice) local user_id = vRP.getUserId(player) if user_id ~= nil then if vRP.tryGetInventoryItem(user_id, fullidname, 1, true) then -- give weapon body local weapons = {} weapons[args[2]] = {ammo = 0} vRPclient.giveWeapons(player, {weapons}) vRP.closeMenu(player) end end end} return choices end local wbody_weight = function(args) return 0.75 end items["wbody"] = {wbody_name,wbody_desc,wbody_choices,wbody_weight} --- weapon ammo local wammo_name = function(args) return get_wname(args[2]).." ammo" end local wammo_desc = function(args) return "" end local wammo_choices = function(args) local choices = {} local fullidname = joinStrings(args,"|") choices["Carica"] = {function(player,choice) local user_id = vRP.getUserId(player) if user_id ~= nil then local amount = vRP.getInventoryItemAmount(user_id, fullidname) vRP.prompt(player, "Quante munizioni vuoi caricare? ? (max "..amount..")", "", function(player,ramount) ramount = parseInt(ramount) vRPclient.getWeapons(player, {}, function(uweapons) if uweapons[args[2]] ~= nil then -- check if the weapon is equiped if vRP.tryGetInventoryItem(user_id, fullidname, ramount, true) then -- give weapon ammo local weapons = {} weapons[args[2]] = {ammo = ramount} vRPclient.giveWeapons(player, {weapons,false}) vRP.closeMenu(player) end end end) end) end end} return choices end local wammo_weight = function(args) return 0.01 end items["wammo"] = {wammo_name,wammo_desc,wammo_choices,wammo_weight} return items :58) > [global chunk] (local items = {} items["dirty_money"] = {"Soldi sporchi","Soldi pieni di inchiostro da ripulire.",nil,0} items["parcels"] = {"Parcels","Parcels to deliver",nil,0.10} items["repairkit"] = {"Kit di riparazione","Kit di riparazione per i veicoli",nil,0.5} -- money items["money"] = {"Money","Packed money.",function(args) local choices = {} local idname = args[1] choices["Unpack"] = {function(player,choice,mod) local user_id = vRP.getUserId(player) if user_id ~= nil then local amount = vRP.getInventoryItemAmount(user_id, idname) vRP.prompt(player, "How much to unpack ? (max "..amount..")", "", function(player,ramount) ramount = parseInt(ramount) if vRP.tryGetInventoryItem(user_id, idname, ramount, true) then -- unpack the money vRP.giveMoney(user_id, ramount) vRP.closeMenu(player) end end) end end} return choices end,0} -- money binder items["money_binder"] = {"Money binder","Used to bind 1000$ of money.",function(args) local choices = {} local idname = args[1] choices["Bind money"] = {function(player,choice,mod) -- bind the money local user_id = vRP.getUserId(player) if user_id ~= nil then local money = vRP.getMoney(user_id) if money >= 1000 then if vRP.tryGetInventoryItem(user_id, idname, 1, true) and vRP.tryPayment(user_id,1000) then vRP.giveInventoryItem(user_id, "money", 1000, true) vRP.closeMenu(player) end else vRPclient.notify(player,{vRP.lang.money.not_enough()}) end end end} return choices end,0} -- parametric weapon items -- give "wbody|WEAPON_PISTOL" and "wammo|WEAPON_PISTOL" to have pistol body and pistol bullets local get_wname = function(weapon_id) local name = string.gsub(weapon_id,"WEAPON_","") name = string.upper(string.sub(name,1,1))..string.lower(string.sub(name,2)) return name end --- weapon body local wbody_name = function(args) return get_wname(args[2]).." body" end local wbody_desc = function(args) return "" end local wbody_choices = function(args) local choices = {} local fullidname = joinStrings(args,"|") choices["Equipaggia"] = {function(player,choice) local user_id = vRP.getUserId(player) if user_id ~= nil then if vRP.tryGetInventoryItem(user_id, fullidname, 1, true) then -- give weapon body local weapons = {} weapons[args[2]] = {ammo = 0} vRPclient.giveWeapons(player, {weapons}) vRP.closeMenu(player) end end end} return choices end local wbody_weight = function(args) return 0.75 end items["wbody"] = {wbody_name,wbody_desc,wbody_choices,wbody_weight} --- weapon ammo local wammo_name = function(args) return get_wname(args[2]).." ammo" end local wammo_desc = function(args) return "" end local wammo_choices = function(args) local choices = {} local fullidname = joinStrings(args,"|") choices["Carica"] = {function(player,choice) local user_id = vRP.getUserId(player) if user_id ~= nil then local amount = vRP.getInventoryItemAmount(user_id, fullidname) vRP.prompt(player, "Quante munizioni vuoi caricare? ? (max "..amount..")", "", function(player,ramount) ramount = parseInt(ramount) vRPclient.getWeapons(player, {}, function(uweapons) if uweapons[args[2]] ~= nil then -- check if the weapon is equiped if vRP.tryGetInventoryItem(user_id, fullidname, ramount, true) then -- give weapon ammo local weapons = {} weapons[args[2]] = {ammo = ramount} vRPclient.giveWeapons(player, {weapons,false}) vRP.closeMenu(player) end end end) end) end end} return choices end local wammo_weight = function(args) return 0.01 end items["wammo"] = {wammo_name,wammo_desc,wammo_choices,wammo_weight} return items :65) > getItemDefinition (@vrp/modules/inventory.lua:134) > openInventory (@vrp/modules/inventory.lua:359) > cb (@vrp/modules/inventory.lua:389) > f (@vrp/modules/gui.lua:182) > handler (local Tools = module("lib/Tools") local Debug = module("lib/Debug") -- this file describe a two way proxy between the server and the clients (request system) local Tunnel = {} -- define per dest regulator Tunnel.delays = {} -- set the base delay between Triggers for this destination in milliseconds (0 for instant trigger) function Tunnel.setDestDelay(dest, delay) Tunnel.delays[dest] = {delay, 0} end local function tunnel_resolve(itable,key) local mtable = getmetatable(itable) local iname = mtable.name local ids = mtable.tunnel_ids local callbacks = mtable.tunnel_callbacks local identifier = mtable.identifier -- generate access function local fcall = function(dest,args,callback) if args == nil then args = {} end -- get delay data local delay_data = Tunnel.delays[dest] if delay_data == nil then delay_data = {0,0} end -- increase delay local add_delay = delay_data[1] delay_data[2] = delay_data[2]+add_delay if delay_data[2] > 0 then -- delay trigger SetTimeout(delay_data[2], function() -- remove added delay delay_data[2] = delay_data[2]-add_delay -- send request if type(callback) == "function" then -- ref callback if exists (become a request) local rid = ids:gen() callbacks[rid] = callback TriggerClientEvent(iname..":tunnel_req",dest,key,args,identifier,rid) else -- regular trigger TriggerClientEvent(iname..":tunnel_req",dest,key,args,"",-1) end end) else -- no delay -- send request if type(callback) == "function" then -- ref callback if exists (become a request) local rid = ids:gen() callbacks[rid] = callback TriggerClientEvent(iname..":tunnel_req",dest,key,args,identifier,rid) else -- regular trigger TriggerClientEvent(iname..":tunnel_req",dest,key,args,"",-1) end end end itable[key] = fcall -- add generated call to table (optimization) return fcall end -- bind an interface (listen to net requests) -- name: interface name -- interface: table containing functions function Tunnel.bindInterface(name,interface) -- receive request RegisterServerEvent(name..":tunnel_req") AddEventHandler(name..":tunnel_req",function(member,args,identifier,rid) local source = source local delayed = false if Debug.active then Debug.pbegin("tunnelreq#"..rid.."_"..name..":"..member.." "..json.encode(Debug.safeTableCopy(args))) end local f = interface[member] local rets = {} if type(f) == "function" then -- bind the global function to delay the return values using the returned function with args TUNNEL_DELAYED = function() delayed = true return function(rets) rets = rets or {} if rid >= 0 then TriggerClientEvent(name..":"..identifier..":tunnel_res",source,rid,rets) end end end rets = {f(table.unpack(args))} -- call function -- CancelEvent() -- cancel event doesn't seem to cancel the event for the other handlers, but if it does, uncomment this end -- send response (even if the function doesn't exist) if not delayed and rid >= 0 then TriggerClientEvent(name..":"..identifier..":tunnel_res",source,rid,rets) end if Debug.active then Debug.pend() end end) end -- get a tunnel interface to send requests -- name: interface name -- identifier: unique string to identify this tunnel interface access (the name of the current resource should be fine) function Tunnel.getInterface(name,identifier) local ids = Tools.newIDGenerator() local callbacks = {} -- build interface local r = setmetatable({},{ __index = tunnel_resolve, name = name, tunnel_ids = ids, tunnel_callbacks = callbacks, identifier = identifier }) -- receive response RegisterServerEvent(name..":"..identifier..":tunnel_res") AddEventHandler(name..":"..identifier..":tunnel_res",function(rid,args) if Debug.active then Debug.pbegin("tunnelres#"..rid.."_"..name.." "..json.encode(Debug.safeTableCopy(args))) end local callback = callbacks[rid] if callback ~= nil then -- free request id ids:free(rid) callbacks[rid] = nil -- call callback(table.unpack(args)) end Debug.pend() end) return r end return Tunnel :100)