Product Image
Ir para conteúdo
  • Cadastre-se

flawlessgui

Membro
  • Total de Posts

    50
  • Registro em

  • Última visita

  • Dias Ganhos

    1

flawlessgui ganhou no último dia Abril 30 2024

flawlessgui teve o conteúdo mais curtida!

1 advertência


Não há restrições sendo aplicadas

1 Seguidor

Sobre flawlessgui

Últimos Visitantes

O bloco dos últimos visitantes está desativado e não está sendo visualizado por outros usuários.

  1. Bom dia, Comecei a usar o script Okok Marketplace e pensei num RP muito interessante com ele, tinha alguns erros ocorrendo mas consegui arrumar, porém, ainda estou com um problema. Quando abro a NUI, os itens que estão no meu inventário aparecem no script porém, todos com o nome UNDEFINED, e nao estou conseguindo mudar. Os itens aparecem, com a quantidade correta, mas nao aparece o nome, se alguém puder me dar um help, fico muito grato. aqui estão os scripts client.lua -- ESX = nil ----------------------------------------------------------------------------------------------------------------------------------------- -- VRP ----------------------------------------------------------------------------------------------------------------------------------------- local Tunnel = module("vrp","lib/Tunnel") local Proxy = module("vrp","lib/Proxy") vRP = Proxy.getInterface("vRP") ----------------------------------------------------------------------------------------------------------------------------------------- -- CONEXÃO ----------------------------------------------------------------------------------------------------------------------------------------- src = {} Tunnel.bindInterface("fw_marketplace",src) vSERVER = Tunnel.getInterface("fw_marketplace") local TE = TriggerEvent local TSE = TriggerServerEvent local job = nil local isMarketOpen = false local blipsLoaded = false -- Citizen.CreateThread(function() -- while ESX == nil do -- TE("esx:getSharedObject", function(obj) ESX = obj end) -- Citizen.Wait(0) -- end -- while ESX.GetPlayerData().job == nil do -- Citizen.Wait(10) -- end -- PlayerData = ESX.GetPlayerData() -- job = PlayerData.job -- end) -- RegisterNetEvent("esx:setJob") -- AddEventHandler("esx:setJob", function(_job) -- job = _job -- end) if not Config.UseBlipToAccessMarket then RegisterCommand(Config.MarketCommand, function() TE('fw_marketplace:open') end, false) else Citizen.CreateThread(function() if Config.ShowBlipsOnMap then Citizen.Wait(2000) for k,v in ipairs(Config.BlipCoords) do local blip = AddBlipForCoord(v.x, v.y, v.z) SetBlipSprite(blip, v.blipId) SetBlipDisplay(blip, 4) SetBlipScale(blip, v.blipScale) SetBlipColour(blip, v.blipColor) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") AddTextComponentString(v.blipText) EndTextCommandSetBlipName(blip) end end end) Citizen.CreateThread(function() if not blipsLoaded then blipsLoaded = true Citizen.Wait(2000) local playerPed = GetPlayerPed(-1) local waitMoreTime = true local playerExists = false while Config.ShowFloorBlips do Citizen.Wait(5) if not playerExists then if DoesEntityExist(playerPed) then playerExists = true else playerPed = GetPlayerPed(-1) end end if playerExists then local playerCoords = GetEntityCoords(PlayerPedId()) if waitMoreTime then waitMoreTime = false end for k,v in pairs(Config.BlipCoords) do local distance = GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, v.x, v.y, v.z) if distance < v.showMarkerRadius then DrawMarker(v.MarkerID, v.x, v.y, v.z-0.0, 0, 0, 0, 0, 0, 0, 0.75, 0.75, 0.75, 31, 94, 255, 155, 0, 0, 2, 1, 0, 0, 0) end end end if waitMoreTime then Citizen.Wait(1000) end end end end) Citizen.CreateThread(function() local inZone = false local nearZone = false local enteredRange = false local inWideRange = false while true do Citizen.Wait(5) local playerCoords = GetEntityCoords(PlayerPedId()) nearZone = false inZone = false for k,v in pairs(Config.BlipCoords) do local distance = GetDistanceBetweenCoords(playerCoords.x, playerCoords.y, playerCoords.z, v.x, v.y, v.z) if distance < v.radius + 2 then local height = playerCoords.z - v.z nearZone = true if waitMore and not isMarketOpen then waitMore = false elseif not waitMore and isMarketOpen then waitMore = true end if distance < v.radius and height < 3 and height > -3 then inZone = true -- if not Config.UseOkokTextUI and not isMarketOpen then -- ESX.ShowHelpNotification('~INPUT_CONTEXT~ To open the marketplace') -- end if IsControlJustReleased(0, Config.OpenMarketKey) then if GetVehiclePedIsUsing(PlayerPedId()) == 0 then TE('fw_marketplace:open') else TriggerEvent("Notify", "aviso", "Você não pode acessar o mercado dentro de um veículo", 5000) end end end elseif not waitMore and not inWideRange then waitMore = true end end if nearZone and not enteredRange then enteredRange = true inWideRange = true elseif not nearZone and enteredRange then enteredRange = false inWideRange = false end if inZone and not hasEntered then -- if Config.UseOkokTextUI then -- exports['okokTextUI']:Open('[E] To open the Marketplace', 'darkblue', 'left') -- end hasEntered = true elseif not inZone and hasEntered then -- if Config.UseOkokTextUI then -- exports['okokTextUI']:Close() -- end hasEntered = false end if waitMore then Citizen.Wait(1000) end end end) end RegisterNetEvent("fw_marketplace:open") AddEventHandler("fw_marketplace:open", function() local vehiclesTable = {} local itemsTable = {} local blackmarketTable = {} local accessBlackmarket = false if not isMarketOpen then -- vSERVER.getItems(items) local items = vSERVER.getItems() table.insert(vehiclesTable, {vehicle = "Indisponível", plate = "XXX-XXX", name = "Indisponível"}) -- for k,v in ipairs(vehicles) do -- local canAdd = true -- for k2,v2 in ipairs(Config.BlacklistVehicles) do -- if GetDisplayNameFromVehicleModel(v.vehicle.model) == v2 then -- canAdd = false -- break -- end -- end -- if canAdd then -- table.insert(vehiclesTable, {vehicle = v.vehicle, plate = v.plate, name = GetDisplayNameFromVehicleModel(v.vehicle.model)}) -- end -- end -- print(json.encode(items)) -- print(items) -- local items = {"maconha",2} for k,v in pairs(items) do local canAdd = true local blackmarketItem = false if v.amount > 0 then for k2,v2 in ipairs(Config.BlacklistItems) do if v.item == v2 then canAdd = false break end end if canAdd then table.insert(itemsTable, {id = v.item, label = vSERVER.getItemInfos(v.item), count = vSERVER.getItemParseVal(v.amount)}) -- else -- for k2,v2 in ipairs(Config.Blackmarket) do -- if v.name == v2[1] and not v2[2] then -- blackmarketItem = true -- break -- end -- end -- if blackmarketItem then -- table.insert(blackmarketTable, {id = v.name, label = v.label, count = v.count, type = "item"}) -- end end end end -- for k,v in ipairs(loadout) do -- for k2,v2 in ipairs(Config.Blackmarket) do -- if v.name == v2[1] and v2[2] then -- table.insert(blackmarketTable, {id = v.name, label = v.label, count = 1, type = "weapon"}) -- end -- end -- end -- vSERVER.getAds(vehAds, itemsAds, blackmarketAds, identifier) local vehAds1 = {} local identifier = vSERVER.getIdentifer() -- local vehAds1 = {} local itemsAds1 = {} local blackmarketAds1 = {} local myAds = {} -- for k,v in ipairs(vehAds) do -- if v.author_identifier ~= identifier then -- if not v.sold then -- table.insert(vehAds1, v) -- end -- else -- table.insert(myAds, v) -- end -- end -- print(json.encode(itemsAds)) local itemsAds = vSERVER.getItemAds() local myAds = vSERVER.getMyAds() for k,v in pairs(itemsAds) do if identifier then if not v.sold then -- print('chegou aq 1') table.insert(itemsAds1, v) end else -- print('chegou aq 2') table.insert(myAds, v) end end -- print(json.encode(myAds)) -- local blackmarketAds = {} -- for k,v in ipairs(blackmarketAds) do -- if identifier then -- if not v.sold then -- table.insert(blackmarketAds1, v) -- end -- else -- table.insert(myAds, v) -- end -- end -- for k,v in ipairs(Config.BlackmarketAllowedJobs) do -- if v.job == job.name then -- if v.grade[1] == nil then -- accessBlackmarket = true -- break -- else -- for k2,v2 in ipairs(v.grade) do -- if v2 == job.grade_name then -- accessBlackmarket = true -- break -- end -- end -- break -- end -- end -- end isMarketOpen = true SetNuiFocus(true, true) SendNUIMessage({ action = 'openVehicleMarket', vehicles = vehiclesTable, vehAds = vehAds1, items = itemsTable, itemsAds = itemsAds1, blackmarket = blackmarketTable, blackmarketAds = blackmarketAds1, myAds = myAds, accessBlackmarket = accessBlackmarket, }) end end) -- RegisterNetEvent("fw_marketplace:updateVehicles") -- AddEventHandler("fw_marketplace:updateVehicles", function() -- Citizen.Wait(100) -- -- vSERVER.getAds(vehAds, itemsAds, blackmarketAds, identifier) -- local vehAds1 = {} -- for k,v in ipairs(vehAds) do -- if v.author_identifier ~= identifier and not v.sold then -- table.insert(vehAds1, v) -- end -- end -- SendNUIMessage({ -- action = 'updateVehicles', -- vehAds = vehAds1, -- }) -- end) RegisterNetEvent("fw_marketplace:updateItems") AddEventHandler("fw_marketplace:updateItems", function() Citizen.Wait(100) -- local adsvar = vSERVER.getAds(vehAds, itemsAds, blackmarketAds, identifier) -- local ads = vSERVER.getAds(vehAds, itemsAds, blackmarketAds, identifier) -- local GetItemAds = vSERVER.getItemAds() local itemsAds = vSERVER.getItemAds() local identifier = vSERVER.getIdentifer() local itemsAds1 = {} -- print(ads[2]) -- print(json.encode(adsvar)) -- print(adsvar[2]) for k,v in ipairs(itemsAds) do if v.author_identifier ~= identifier and not v.sold then table.insert(itemsAds1, v) end end SendNUIMessage({ action = 'updateItems', itemsAds = itemsAds1, }) end) -- RegisterNetEvent("fw_marketplace:updateBlackmarket") -- AddEventHandler("fw_marketplace:updateBlackmarket", function() -- Citizen.Wait(100) -- -- vSERVER.getAds(vehAds, itemsAds, blackmarketAds, identifier) -- local blackmarketAds1 = {} -- for k,v in ipairs(blackmarketAds) do -- if v.author_identifier ~= identifier and not v.sold then -- table.insert(blackmarketAds1, v) -- end -- end -- SendNUIMessage({ -- action = 'updateBlackmarket', -- blackmarketAds = blackmarketAds1, -- }) -- end) RegisterNetEvent("fw_marketplace:updateMyAds") AddEventHandler("fw_marketplace:updateMyAds", function() -- print('chegou aq') Citizen.Wait(100) -- vSERVER.getAds(vehAds, itemsAds, blackmarketAds, identifier) local myAds = {} local itemsAds = vSERVER.getItemAds() local identifier = vSERVER.getIdentifer() -- for k,v in ipairs(vehAds) do -- if v.author_identifier == identifier then -- table.insert(myAds, v) -- end -- end for k,v in ipairs(itemsAds) do if v.author_identifier == identifier then table.insert(myAds, v) end end -- for k,v in ipairs(blackmarketAds) do -- if v.author_identifier == identifier then -- table.insert(myAds, v) -- end -- end SendNUIMessage({ action = 'updateMyAds', myAds = myAds, }) end) RegisterNetEvent("fw_marketplace:updateMyAdsTable") AddEventHandler("fw_marketplace:updateMyAdsTable", function() Citizen.Wait(100) -- vSERVER.getAds(vehAds, itemsAds, blackmarketAds, identifier) local myAds = {} -- for k,v in ipairs(vehAds) do -- if v.author_identifier == identifier then -- table.insert(myAds, v) -- end -- end local itemsAds = vSERVER.getItemAds() local identifier = vSERVER.getIdentifer() for k,v in ipairs(itemsAds) do if v.author_identifier == identifier then table.insert(myAds, v) end end -- for k,v in ipairs(blackmarketAds) do -- if v.author_identifier == identifier then -- table.insert(myAds, v) -- end -- end SendNUIMessage({ action = 'updateMyAdsTable', myAds = myAds, }) end) -- RegisterNetEvent("fw_marketplace:updateVehiclesDropdown") -- AddEventHandler("fw_marketplace:updateVehiclesDropdown", function() -- Citizen.Wait(100) -- local vehiclesTable = {} -- vSERVER.getItems(items) -- for k,v in ipairs(vehicles) do -- local canAdd = true -- for k2,v2 in ipairs(Config.BlacklistVehicles) do -- if GetDisplayNameFromVehicleModel(v.vehicle.model) == v2 then -- canAdd = false -- break -- end -- end -- if canAdd then -- table.insert(vehiclesTable, {vehicle = v.vehicle, plate = v.plate, name = GetDisplayNameFromVehicleModel(v.vehicle.model)}) -- end -- end -- SendNUIMessage({ -- action = 'updateVehiclesDropdown', -- vehicles = vehiclesTable, -- }) -- end) RegisterNetEvent("fw_marketplace:closeMarket") AddEventHandler("fw_marketplace:closeMarket", function() -- isMarketOpen = false -- SetNuiFocus(false, false) SendNUIMessage({ action = 'closeMenu' }) end) RegisterNetEvent("fw_marketplace:updateItemsDropdown") AddEventHandler("fw_marketplace:updateItemsDropdown", function() Citizen.Wait(100) local itemsTable = {} local items = vSERVER.getItems() for k,v in ipairs(items) do local canAdd = true if v.amount > 0 then for k2,v2 in ipairs(Config.BlacklistItems) do if v.item == v2 then canAdd = false break end end if canAdd then table.insert(itemsTable, {id = v.item, label = vSERVER.getItemInfos(v.item), count = vSERVER.getItemParseVal(v.amount)}) end end end SendNUIMessage({ action = 'updateItemsDropdown', items = itemsTable, }) end) -- RegisterNetEvent("fw_marketplace:updateBlackmarketDropdown") -- AddEventHandler("fw_marketplace:updateBlackmarketDropdown", function() -- Citizen.Wait(100) -- local blackmarketTable = {} -- vSERVER.getItems(items) -- for k,v in ipairs(items) do -- local canAdd = true -- local blackmarketItem = false -- if v.count > 0 then -- for k2,v2 in ipairs(Config.BlacklistItems) do -- if v.name == v2 then -- canAdd = false -- break -- end -- end -- if not canAdd then -- for k2,v2 in ipairs(Config.Blackmarket) do -- if v.name == v2[1] and not v2[2] then -- blackmarketItem = true -- break -- end -- end -- if blackmarketItem then -- table.insert(blackmarketTable, {id = v.name, label = v.label, count = v.count, type = "item"}) -- end -- end -- end -- end -- for k,v in ipairs(loadout) do -- for k2,v2 in ipairs(Config.Blackmarket) do -- if v.name == v2[1] and v2[2] then -- table.insert(blackmarketTable, {id = v.name, label = v.label, count = 1, type = "weapon"}) -- end -- end -- end -- SendNUIMessage({ -- action = 'updateBlackmarketDropdown', -- blackmarket = blackmarketTable, -- }) -- end) RegisterNUICallback("action", function(data, cb) -- print(data) local phone = vSERVER.getPhone(phone) if data.action == "close" then isMarketOpen = false SetNuiFocus(false, false) elseif data.action == "placeAd" then if data.window == "vehicles" then -- vSERVER.getPhone(phone) -- if data.desc == "" then -- local desc = "Nothing to add" -- TSE('fw_marketplace:addVehicle', data.item, data.price, desc, phone) -- else -- TSE('fw_marketplace:addVehicle', data.item, data.price, data.desc, phone) -- end elseif data.window == "items" then -- print('aq') -- vSERVER.getPhone(phone) if data.desc == "" then local desc = "Nothing to add" TSE('fw_marketplace:addItem', data.item, tonumber(data.amount), data.price, desc, phone) else TSE('fw_marketplace:addItem', data.item, tonumber(data.amount), data.price, data.desc, phone) end elseif data.window == "blackmarket" then -- vSERVER.getPhone(phone) -- if data.desc == "" then -- local desc = "Nothing to add" -- TSE('fw_marketplace:addBlackmarket', data.item, data.price, desc, phone, tonumber(data.amount)) -- else -- TSE('fw_marketplace:addBlackmarket', data.item, data.price, data.desc, phone, tonumber(data.amount)) -- end end elseif data.action == "missing" then TriggerEvent("Notify", "aviso", "Por favor, preencha todos os campos obrigatórios", 5000) elseif data.action == "missingSearch" then TriggerEvent("Notify", "aviso", "Preencha os campos corretamente", 5000) elseif data.action == "high" then TriggerEvent("Notify", "aviso", "Você não tem itens suficientes para vender", 5000) elseif data.action == "buyVehicle" then -- ESX.TriggerServerCallback("fw_marketplace:getVehicle", function(veh) -- TSE('fw_marketplace:buyVehicle', veh) -- end, data.id) elseif data.action == "buyItem" then -- vSERVER.getItem(item) -- data.id, data.item -- print(data.id, data.item) -- print(data.price) -- print(data.amount) -- print(data.target) TSE('fw_marketplace:buyItem', data.id, data.item, data.price, data.amount, data.target) elseif data.action == "buyBlackmarket" then -- ESX.TriggerServerCallback("fw_marketplace:getBlackmarket", function(blackmarket) -- TSE('fw_marketplace:buyBlackmarket', blackmarket) -- end, data.id, data.blackmarket) elseif data.action == "myAd" then -- print('my adddd') TSE('fw_marketplace:removeMyAd', data.item) elseif data.action == "refresh" then if data.window == "vehicles" then -- TriggerEvent('fw_marketplace:updateVehicles') elseif data.window == "items" then TriggerEvent('fw_marketplace:updateItems') elseif data.window == "blackmarket" then -- TriggerEvent('fw_marketplace:updateBlackmarket') end end end) e server.lua ----------------------------------------------------------------------------------------------------------------------------------------- -- VRP ----------------------------------------------------------------------------------------------------------------------------------------- local Tunnel = module("vrp","lib/Tunnel") local Proxy = module("vrp","lib/Proxy") vRP = Proxy.getInterface("vRP") vRPclient = Tunnel.getInterface("vRP") ----------------------------------------------------------------------------------------------------------------------------------------- -- CONEXÃO ----------------------------------------------------------------------------------------------------------------------------------------- src = {} Tunnel.bindInterface("fw_marketplace",src) vCLIENT = Tunnel.getInterface("fw_marketplace") -- ESX = nil local Webhook = '' -- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) src.getItemInfos = function(item) return vRP.itemNameList(item) end src.getItemParseVal = function(val) -- return vRP.format(parseInt(val)) return parseInt(val) end src.getItems = function() -- local _source = source -- local xPlayer = vRP.getUserId(_source) local source = source local user_id = vRP.getUserId(source) local inv = vRP.getInventory(user_id) or {} local allItems = {} for k,v in pairs(inv) do table.insert(allItems, v) end -- local vehicles = {} -- local loadout = xPlayer.getLoadout() -- MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND Type = @Type AND job = @job AND `stored` = 1', { -- ['@owner'] = xPlayer.identifier, -- ['@Type'] = 'car', -- ['@job'] = 'civ', -- }, function(data) -- for _,v in pairs(data) do -- local vehicle = json.decode(v.vehicle) -- table.insert(vehicles, {vehicle = vehicle, plate = v.plate}) -- end -- local vehicles = {} -- print(vRP.getInventory(xPlayer)) -- return vRP.getInventory(xPlayer) -- end) -- print(allItems) return allItems end vRP.prepare('fw_marketplace/getMyAds', 'SELECT * FROM fw_marketplace_items WHERE author_identifier = @author_identifier') src.getMyAds = function() local _source = source local xPlayer = vRP.getUserId(_source) local data = vRP.query('fw_marketplace/getMyAds', {author_identifier=xPlayer}) -- print(json.encode(data)) return data end vRP.prepare('fw_marketplace/getItemsDB', 'SELECT * FROM fw_marketplace_items ORDER BY id ASC') src.getItemAds = function() local _source = source local xPlayer = vRP.getUserId(_source) -- MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_vehicles ORDER BY id ASC', { -- }, function(veh) -- MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_items ORDER BY id ASC', { -- }, function(items) -- MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_blackmarket ORDER BY id ASC', { -- }, function(blackmarket) -- local veh = {} -- local blackmarket = {} -- local data = vRP.query('fw_marketplace/getItemsDB') local items = vRP.query('fw_marketplace/getItemsDB', {user_id=user_id}) -- print(json.encode(data)) return items -- end) -- end) -- end) end src.getAds = function() local _source = source local xPlayer = vRP.getUserId(_source) -- MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_vehicles ORDER BY id ASC', { -- }, function(veh) -- MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_items ORDER BY id ASC', { -- }, function(items) -- MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_blackmarket ORDER BY id ASC', { -- }, function(blackmarket) local veh = {} local blackmarket = {} -- local data = vRP.query('fw_marketplace/getItemsDB') local items = vRP.query('fw_marketplace/getItemsDB') -- print(json.encode(data)) return veh, items, blackmarket, xPlayer -- end) -- end) -- end) end src.getIdentifer = function() local _source = source local xPlayer = vRP.getUserId(_source) -- local xPlayer = ESX.GetPlayerFromId(_source) -- MySQL.Async.fetchAll('SELECT * FROM users WHERE identifier = @identifier',{ -- ['@identifier'] = xPlayer.identifier -- }, function(result) -- cb(result[1].phone_number) -- end) return xPlayer end src.getPhone = function() local _source = source local xPlayer = vRP.getUserId(_source) -- local xPlayer = ESX.GetPlayerFromId(_source) -- MySQL.Async.fetchAll('SELECT * FROM users WHERE identifier = @identifier',{ -- ['@identifier'] = xPlayer.identifier -- }, function(result) -- cb(result[1].phone_number) -- end) return vRP.getUserIdentity(xPlayer).phone end -- RegisterServerEvent("fw_marketplace:addVehicle") -- AddEventHandler("fw_marketplace:addVehicle", function(vehicle, price, desc, phone_number) -- local _source = source -- local xPlayer = ESX.GetPlayerFromId(_source) -- local plate = vehicle.plate -- local id = plate:gsub("%s+", "") -- MySQL.Async.execute('UPDATE owned_vehicles SET owner = @owner WHERE plate = @plate', { -- ['@plate'] = vehicle.plate, -- ['@owner'] = "selling", -- }) -- MySQL.Async.insert('INSERT INTO fw_marketplace_vehicles (item_id, plate, label, author_identifier, author_name, phone_number, description, price, start_date) VALUES (@item_id, @plate, @label, @author_identifier, @author_name, @phone_number, @description, @price, @start_date)', { -- ['@item_id'] = id, -- ['@plate'] = plate, -- ['@label'] = vehicle.name, -- ['@author_identifier'] = xPlayer.identifier, -- ['@author_name'] = xPlayer.getName(), -- ['@phone_number'] = phone_number, -- ['@description'] = desc, -- ['@price'] = price, -- ['@start_date'] = os.date("%d/%m - %H:%M"), -- }, function(result) -- TriggerClientEvent('fw_marketplace:updateVehiclesDropdown', xPlayer.source) -- TriggerClientEvent('fw_marketplace:updateVehicles', xPlayer.source) -- TriggerClientEvent('fw_marketplace:updateMyAdsTable', xPlayer.source) -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You are now selling the vehicle "..vehicle.name.." ("..vehicle.plate..")", 5000, 'success') -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "add", -- action = "Added an Ad", -- item = vehicle.name.." ("..vehicle.plate..")", -- price = price, -- desc = desc, -- title = "MARKETPLACE - Vehicles", -- } -- discordWenhook(data) -- end -- end) -- end) vRP.prepare('fw_marketplace/SetDBItems', 'INSERT INTO fw_marketplace_items (item_id, label, amount, author_identifier, author_name, phone_number, description, price, start_date) VALUES (@item_id, @label, @amount, @author_identifier, @author_name, @phone_number, @description, @price, @start_date)') RegisterServerEvent("fw_marketplace:addItem") AddEventHandler("fw_marketplace:addItem", function(item, amount, price, desc, phone_number) -- print(item, amount, price, desc, phone_number) -- print(item.id) local _source = source local xPlayer = vRP.getUserId(_source) local amount = tonumber(amount) -- Certifique-se de obter a identidade do jogador local identity = xPlayer and vRP.getUserIdentity(xPlayer) or nil local phone_number = identity and identity.phone or "Número não encontrado" local player_name = identity and identity.name or "Sem nome" -- Certifique-se de que o item existe e tem um ID válido local item_id = item and item.id or nil local item_label = item_id and vRP.itemNameList(item_id) or "Item desconhecido" if not item_id then print("Erro: item.id está nil.") TriggerClientEvent('Notify', _source, "negado", "Erro ao identificar o item.", 5000) return end -- Certifique-se de que o jogador tem itens suficientes no inventário if vRP.getInventoryItemAmount(xPlayer, item_id) >= amount and amount > 0 then -- Inserir o item no banco de dados vRP.execute('fw_marketplace/SetDBItems', { item_id = item_id, label = item_label, amount = amount, author_identifier = xPlayer, author_name = player_name, phone_number = phone_number, description = desc or "Sem descrição", price = price or 0, start_date = os.date("%d/%m - %H:%M"), }) -- Atualizar o cliente e remover o item do inventário TriggerClientEvent('fw_marketplace:updateItemsDropdown', _source) TriggerClientEvent('fw_marketplace:updateItems', _source) TriggerClientEvent('fw_marketplace:updateMyAdsTable', _source) vRP.tryGetInventoryItem(xPlayer, item_id, amount) -- Notificar o jogador TriggerClientEvent('Notify', _source, "sucesso", "Agora você está vendendo " .. item_label .. " (" .. amount .. ")", 5000) else -- Notificar o jogador caso não tenha itens suficientes TriggerClientEvent('Notify', _source, "negado", "Itens insuficientes para venda", 5000) end end) RegisterServerEvent("fw_marketplace:addBlackmarket") AddEventHandler("fw_marketplace:addBlackmarket", function(item, price, desc, phone_number, amount) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) if item.type == "weapon" and xPlayer.hasWeapon(item.id) and amount <= item.count then MySQL.Async.insert('INSERT INTO fw_marketplace_blackmarket (item_id, label, type, amount, author_identifier, author_name, phone_number, description, price, start_date) VALUES (@item_id, @label, @type, @amount, @author_identifier, @author_name, @phone_number, @description, @price, @start_date)', { ['@item_id'] = item.id, ['@label'] = item.label, ['@type'] = item.type, ['@amount'] = amount, ['@author_identifier'] = xPlayer.identifier, ['@author_name'] = xPlayer.getName(), ['@phone_number'] = phone_number, ['@description'] = desc, ['@price'] = price, ['@start_date'] = os.date("%d/%m - %H:%M"), }, function(result) TriggerClientEvent('fw_marketplace:updateBlackmarketDropdown', xPlayer.source) TriggerClientEvent('fw_marketplace:updateBlackmarket', xPlayer.source) TriggerClientEvent('fw_marketplace:updateMyAdsTable', xPlayer.source) xPlayer.removeWeapon(item.id, amount) TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You are now selling the item "..item.label, 5000, 'success') if Webhook ~= '' then local identifierlist = ExtractIdentifiers(xPlayer.source) local data = { playerid = xPlayer.source, identifier = identifierlist.license:gsub("license2:", ""), discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", type = "add", action = "Added an Ad", item = item.label.." (x"..amount..")", price = price, desc = desc, title = "MARKETPLACE - Blackmarket", } discordWenhook(data) end end) elseif item.type == "item" and xPlayer.getInventoryItem(item.id).count > 0 and amount <= xPlayer.getInventoryItem(item.id).count then MySQL.Async.insert('INSERT INTO fw_marketplace_blackmarket (item_id, label, type, amount, author_identifier, author_name, phone_number, description, price, start_date) VALUES (@item_id, @label, @type, @amount, @author_identifier, @author_name, @phone_number, @description, @price, @start_date)', { ['@item_id'] = item.id, ['@label'] = item.label, ['@type'] = item.type, ['@amount'] = amount, ['@author_identifier'] = xPlayer.identifier, ['@author_name'] = xPlayer.getName(), ['@phone_number'] = phone_number, ['@description'] = desc, ['@price'] = price, ['@start_date'] = os.date("%d/%m - %H:%M"), }, function(result) TriggerClientEvent('fw_marketplace:updateBlackmarketDropdown', xPlayer.source) TriggerClientEvent('fw_marketplace:updateBlackmarket', xPlayer.source) TriggerClientEvent('fw_marketplace:updateMyAdsTable', xPlayer.source) xPlayer.removeInventoryItem(item.id, amount) TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You are now selling the item "..item.label, 5000, 'success') if Webhook ~= '' then local identifierlist = ExtractIdentifiers(xPlayer.source) local data = { playerid = xPlayer.source, identifier = identifierlist.license:gsub("license2:", ""), discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", type = "add", action = "Added an Ad", item = item.label.." (x"..amount..")", price = price, desc = desc, title = "MARKETPLACE - Blackmarket", } discordWenhook(data) end end) else TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You don't have enough "..item.label.." to sell", 5000, 'error') end end) RegisterServerEvent('fw_marketplace:getVehicle', function(source, cb, id) local _source = source local xPlayer = ESX.GetPlayerFromId(_source) MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_vehicles WHERE item_id = @item_id AND sold = false', { ['@item_id'] = id, }, function(veh) if veh[1] ~= nil then cb(veh) else TriggerClientEvent('fw_marketplace:updateVehicles', xPlayer.source) TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "This vehicle is no longer for sale", 5000, 'error') end end) end) src.getItem = function(source, cb, id, item) local _source = source local xPlayer = vRP.getUserId(_source) MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_items WHERE id = @id AND item_id = @item_id AND sold = false', { ['@id'] = id, ['@item_id'] = item, }, function(item) if item[1] ~= nil then cb(item) else TriggerClientEvent('fw_marketplace:updateItems', xPlayer.source) TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "This item is no longer for sale", 5000, 'error') end end) end -- RegisterServerCallback('fw_marketplace:getBlackmarket', function(source, cb, id, blackmarket) -- local _source = source -- local xPlayer = ESX.GetPlayerFromId(_source) -- MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_blackmarket WHERE id = @id AND item_id = @item_id AND sold = false', { -- ['@id'] = id, -- ['@item_id'] = blackmarket, -- }, function(blackmarket) -- if blackmarket[1] ~= nil then -- cb(blackmarket) -- else -- TriggerClientEvent('fw_marketplace:updateBlackmarket', xPlayer.source) -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "This item is no longer for sale", 5000, 'error') -- end -- end) -- end) -- RegisterServerEvent("fw_marketplace:buyVehicle") -- AddEventHandler("fw_marketplace:buyVehicle", function(veh) -- local _source = source -- local xPlayer = ESX.GetPlayerFromId(_source) -- local xTarget = ESX.GetPlayerFromIdentifier(veh[1].author_identifier) -- local money = xPlayer.getAccount('bank').money -- local price = tonumber(veh[1].price) -- if money >= price then -- MySQL.Async.execute('UPDATE fw_marketplace_vehicles SET sold = 1 WHERE plate = @plate AND sold = 0', {['@plate'] = veh[1].plate}, -- function (rowsChanged) -- if rowsChanged > 0 then -- xPlayer.removeAccountMoney('bank', price) -- MySQL.Async.execute('UPDATE owned_vehicles SET owner = @owner WHERE plate = @plate', { -- ['@plate'] = veh[1].plate, -- ['@owner'] = xPlayer.identifier, -- }) -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You bought the vehicle "..veh[1].label.." ("..veh[1].plate..")", 5000, 'success') -- TriggerClientEvent('fw_marketplace:updateVehiclesDropdown', xPlayer.source) -- TriggerClientEvent('fw_marketplace:updateVehicles', xPlayer.source) -- if xTarget ~= nil then -- TriggerClientEvent('okokNotify:Alert', xTarget.source, "MARKET", "You sold the vehicle "..veh[1].label.." ("..veh[1].plate..")", 5000, 'success') -- end -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "buy", -- action = "Bought a vehicle", -- item = veh[1].label.." ("..veh[1].plate..")", -- price = veh[1].price, -- desc = veh[1].description, -- from = veh[1].author_name.." ("..veh[1].author_identifier..")", -- title = "MARKETPLACE - Vehicles", -- } -- discordWenhook(data) -- end -- else -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "Something went wrong, please try again later!", 5000, 'error') -- end -- end) -- else -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You don't have enough money to buy this vehicle", 5000, 'error') -- end -- end) RegisterServerEvent("fw_marketplace:buyItem") AddEventHandler("fw_marketplace:buyItem", function(item_id, item, value, amountVal, playerTarget) local _source = source local xPlayer = vRP.getUserId(_source) -- local xTarget = ESX.GetPlayerFromIdentifier(item[1].author_identifier) local money = vRP.getBankMoney(xPlayer) -- print(playerTarget) -- local targetSource = vRP.getUserSource(parseInt(playerTarget)) -- local targetId = vRP.getUserId(targetSource) -- local targetMoney = vRP.getBankMoney(targetId) -- print(targetMoney) if xPlayer == parseInt(playerTarget) then TriggerClientEvent("Notify", _source, "negado", "Você não pode comprar seu próprio item.") return end local amount = parseInt(amountVal) -- print(item) -- print(item[1].price) local price = tonumber(value) if money >= price then MySQL.Async.execute('UPDATE fw_marketplace_items SET sold = 1 WHERE id = @id AND item_id = @item_id AND sold = 0', { ['@id'] = item_id, ['@item_id'] = item, },function (rowsChanged) if rowsChanged > 0 then -- print('user') -- print(money-price) -- print('target') -- print(targetMoney+price) vRP.setBankMoney(xPlayer, parseInt(money-price)) vRP.giveInventoryItem(xPlayer, item, amount) TriggerClientEvent('Notify', _source, "sucesso", "Você comprou o item "..vRP.itemNameList(item).." (x"..amount..")", 5000) TriggerClientEvent('fw_marketplace:updateItemsDropdown', _source) TriggerClientEvent('fw_marketplace:updateItems', _source) -- if xTarget ~= nil then -- TriggerClientEvent('okokNotify:Alert', xTarget.source, "MARKET", "You sold the item "..item[1].label.." (x"..item[1].amount..")", 5000, 'success') -- end -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "buy", -- action = "Bought an item", -- item = item[1].label.." (x"..item[1].amount..")", -- price = item[1].price, -- desc = item[1].description, -- from = item[1].author_name.." ("..item[1].author_identifier..")", -- title = "MARKETPLACE - Items", -- } -- discordWenhook(data) -- end else TriggerClientEvent('Notify', _source, "negado", "Algo deu errado, tente novamente mais tarde!", 5000) end end) else TriggerClientEvent('Notify', _source, "negado", "Você não tem dinheiro para comprar este item", 5000) end end) -- RegisterServerEvent("fw_marketplace:buyBlackmarket") -- AddEventHandler("fw_marketplace:buyBlackmarket", function(blackmarket) -- local _source = source -- local xPlayer = ESX.GetPlayerFromId(_source) -- local xTarget = ESX.GetPlayerFromIdentifier(blackmarket[1].author_identifier) -- local money -- local price = tonumber(blackmarket[1].price) -- if Config.UseDirtyMoneyOnBlackmarket then -- money = xPlayer.getAccount('black_money').money -- else -- money = xPlayer.getAccount('bank').money -- end -- if money >= price then -- if blackmarket[1].type == "item" and xPlayer.canCarryItem(blackmarket[1].item_id, 1) then -- MySQL.Async.execute('UPDATE fw_marketplace_blackmarket SET sold = 1 WHERE id = @id AND item_id = @item_id AND sold = 0', { -- ['@id'] = blackmarket[1].id, -- ['@item_id'] = blackmarket[1].item_id, -- },function (rowsChanged) -- if rowsChanged > 0 then -- xPlayer.addInventoryItem(blackmarket[1].item_id, blackmarket[1].amount) -- if Config.UseDirtyMoneyOnBlackmarket then -- xPlayer.removeAccountMoney('black_money', price) -- else -- xPlayer.removeAccountMoney('bank', price) -- end -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You bought the item "..blackmarket[1].label, 5000, 'success') -- TriggerClientEvent('fw_marketplace:updateBlackmarketDropdown', xPlayer.source) -- TriggerClientEvent('fw_marketplace:updateBlackmarket', xPlayer.source) -- if xTarget ~= nil then -- TriggerClientEvent('okokNotify:Alert', xTarget.source, "MARKET", "You sold the item "..blackmarket[1].label, 5000, 'success') -- end -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "buy", -- action = "Bought an item", -- item = blackmarket[1].label.." (x"..blackmarket[1].amount..")", -- price = blackmarket[1].price, -- desc = blackmarket[1].description, -- from = blackmarket[1].author_name.." ("..blackmarket[1].author_identifier..")", -- title = "MARKETPLACE - Blackmarket", -- } -- discordWenhook(data) -- end -- else -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "Something went wrong, please try again later!", 5000, 'error') -- end -- end) -- elseif blackmarket[1].type == "weapon" and not xPlayer.hasWeapon(blackmarket[1].item_id) then -- MySQL.Async.execute('UPDATE fw_marketplace_blackmarket SET sold = 1 WHERE id = @id AND item_id = @item_id AND sold = 0', { -- ['@id'] = blackmarket[1].id, -- ['@item_id'] = blackmarket[1].item_id, -- },function (rowsChanged) -- if rowsChanged > 0 then -- xPlayer.addWeapon(blackmarket[1].item_id, blackmarket[1].amount) -- if Config.UseDirtyMoneyOnBlackmarket then -- xPlayer.removeAccountMoney('black_money', price) -- else -- xPlayer.removeAccountMoney('bank', price) -- end -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You bought the item "..blackmarket[1].label, 5000, 'success') -- TriggerClientEvent('fw_marketplace:updateBlackmarketDropdown', xPlayer.source) -- TriggerClientEvent('fw_marketplace:updateBlackmarket', xPlayer.source) -- if xTarget ~= nil then -- TriggerClientEvent('okokNotify:Alert', xTarget.source, "MARKET", "You sold the item "..blackmarket[1].label, 5000, 'success') -- end -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "buy", -- action = "Bought an item", -- item = blackmarket[1].label.." (x"..blackmarket[1].amount..")", -- price = blackmarket[1].price, -- desc = blackmarket[1].description, -- from = blackmarket[1].author_name.." ("..blackmarket[1].author_identifier..")", -- title = "MARKETPLACE - Blackmarket", -- } -- discordWenhook(data) -- end -- else -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "Something went wrong, please try again later!", 5000, 'error') -- end -- end) -- else -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You can't carry this item", 5000, 'error') -- end -- else -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You don't have enough money to buy this item", 5000, 'error') -- end -- end) RegisterServerEvent("fw_marketplace:removeMyAd") AddEventHandler("fw_marketplace:removeMyAd", function(item) local _source = source local xPlayer = vRP.getUserId(_source) if item.plate then -- MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_vehicles WHERE item_id = @item_id AND id = @id', { -- ['@item_id'] = item.item_id, -- ['@id'] = item.id, -- }, function(veh) -- MySQL.Async.execute('DELETE FROM fw_marketplace_vehicles WHERE item_id = @item_id AND id = @id', { -- ['@id'] = veh[1].id, -- ['@item_id'] = veh[1].item_id, -- },function (rowDeleted) -- if rowDeleted > 0 then -- if veh[1].sold then -- vRP.addAccountMoney('bank', tonumber(veh[1].price)) -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You claimed "..veh[1].price.." R$", 5000, 'success') -- -- if Webhook ~= '' then -- -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- -- local data = { -- -- playerid = xPlayer.source, -- -- identifier = identifierlist.license:gsub("license2:", ""), -- -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- -- type = "claim", -- -- action = "Claimed an Ad", -- -- item = veh[1].label.." ("..veh[1].plate..")", -- -- price = veh[1].price, -- -- desc = veh[1].description, -- -- title = "MARKETPLACE - Vehicles", -- -- } -- -- discordWenhook(data) -- -- end -- else -- MySQL.Async.execute('UPDATE owned_vehicles SET owner = @owner WHERE plate = @plate', { -- ['@plate'] = veh[1].plate, -- ['@owner'] = veh[1].author_identifier, -- }) -- TriggerClientEvent('fw_marketplace:updateVehiclesDropdown', xPlayer.source) -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You canceled the AD "..veh[1].label.." ("..veh[1].plate..")", 5000, 'success') -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "cancel", -- action = "Canceled an Ad", -- item = veh[1].label.." ("..veh[1].plate..")", -- price = veh[1].price, -- desc = veh[1].description, -- title = "MARKETPLACE - Vehicles", -- } -- discordWenhook(data) -- end -- end -- else -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "Something went wrong, please try again later!", 5000, 'error') -- end -- end) -- end) elseif item.type then -- MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_blackmarket WHERE item_id = @item_id AND id = @id', { -- ['@item_id'] = item.item_id, -- ['@id'] = item.id, -- }, function(blackmarket) -- local canCarry = true -- if not blackmarket[1].sold then -- if blackmarket[1].type == "weapon" and xPlayer.hasWeapon(blackmarket[1].item_id) then -- canCarry = false -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You don't have enough space to carry this item", 5000, 'error') -- elseif blackmarket[1].type == "item" and not xPlayer.canCarryItem(blackmarket[1].item_id, tonumber(blackmarket[1].amount)) then -- canCarry = false -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You don't have enough space to carry this item", 5000, 'error') -- end -- end -- if canCarry then -- MySQL.Async.execute('DELETE FROM fw_marketplace_blackmarket WHERE item_id = @item_id AND id = @id', { -- ['@id'] = blackmarket[1].id, -- ['@item_id'] = blackmarket[1].item_id, -- },function (rowDeleted) -- if rowDeleted > 0 then -- if blackmarket[1].sold then -- xPlayer.addAccountMoney('bank', tonumber(blackmarket[1].price)) -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You claimed "..blackmarket[1].price.." R$", 5000, 'success') -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "claim", -- action = "Claimed an Ad", -- item = blackmarket[1].label.." (x"..blackmarket[1].amount..")", -- price = blackmarket[1].price, -- desc = blackmarket[1].description, -- title = "MARKETPLACE - Blackmarket", -- } -- discordWenhook(data) -- end -- else -- if blackmarket[1].type == "weapon" then -- xPlayer.addWeapon(blackmarket[1].item_id, 1) -- elseif blackmarket[1].type == "item" then -- xPlayer.addInventoryItem(blackmarket[1].item_id, tonumber(blackmarket[1].amount)) -- end -- TriggerClientEvent('fw_marketplace:updateBlackmarketDropdown', xPlayer.source) -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "You canceled the AD "..blackmarket[1].label.." (x"..blackmarket[1].amount..")", 5000, 'success') -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "cancel", -- action = "Canceled an Ad", -- item = blackmarket[1].label.." (x"..blackmarket[1].amount..")", -- price = blackmarket[1].price, -- desc = blackmarket[1].description, -- title = "MARKETPLACE - Blackmarket", -- } -- discordWenhook(data) -- end -- end -- else -- TriggerClientEvent('okokNotify:Alert', xPlayer.source, "MARKET", "Something went wrong, please try again later!", 5000, 'error') -- end -- end) -- end -- end) else MySQL.Async.fetchAll('SELECT * FROM fw_marketplace_items WHERE item_id = @item_id AND id = @id', { ['@item_id'] = item.item_id, ['@id'] = item.id, }, function(items) -- if xPlayer.canCarryItem(items[1].item_id, tonumber(items[1].amount)) then MySQL.Async.execute('DELETE FROM fw_marketplace_items WHERE item_id = @item_id AND id = @id', { ['@id'] = items[1].id, ['@item_id'] = items[1].item_id, },function (rowDeleted) if rowDeleted > 0 then if items[1].sold then vRP.giveBankMoney(xPlayer, tonumber(items[1].price)) TriggerClientEvent('Notify', _source, "sucesso", "Você retirou "..items[1].price.." R$", 5000) -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "claim", -- action = "Claimed an Ad", -- item = items[1].label.." (x"..items[1].amount..")", -- price = items[1].price, -- desc = items[1].description, -- title = "MARKETPLACE - Items", -- } -- discordWenhook(data) -- end else vRP.giveInventoryItem(xPlayer, items[1].item_id, tonumber(items[1].amount)) TriggerClientEvent('fw_marketplace:updateItemsDropdown', _source) TriggerClientEvent('fw_marketplace:closeMarket', _source) TriggerClientEvent('Notify', _source, "sucesso", "Você cancelou o anúncio "..items[1].label.." (x"..items[1].amount..")", 5000) -- if Webhook ~= '' then -- local identifierlist = ExtractIdentifiers(xPlayer.source) -- local data = { -- playerid = xPlayer.source, -- identifier = identifierlist.license:gsub("license2:", ""), -- discord = "<@"..identifierlist.discord:gsub("discord:", "")..">", -- type = "cancel", -- action = "Canceled an Ad", -- item = items[1].label.." (x"..items[1].amount..")", -- price = items[1].price, -- desc = items[1].description, -- title = "MARKETPLACE - Items", -- } -- discordWenhook(data) -- end end else TriggerClientEvent('Notify', _source, "negado", "Algo deu errado, tente novamente mais tarde!", 5000) end end) -- else -- TriggerClientEvent('Notify', _source, "negado", "Você não tem espaço na mochila.", 5000) -- end end) end TriggerClientEvent('fw_marketplace:updateMyAds', _source) end) -------------------------- IDENTIFIERS function ExtractIdentifiers(id) local identifiers = { steam = "", ip = "", discord = "", license = "", xbl = "", live = "" } for i = 0, GetNumPlayerIdentifiers(id) - 1 do local playerID = GetPlayerIdentifier(id, i) if string.find(playerID, "steam") then identifiers.steam = playerID elseif string.find(playerID, "ip") then identifiers.ip = playerID elseif string.find(playerID, "discord") then identifiers.discord = playerID elseif string.find(playerID, "license") then identifiers.license = playerID elseif string.find(playerID, "xbl") then identifiers.xbl = playerID elseif string.find(playerID, "live") then identifiers.live = playerID end end return identifiers end -------------------------- WEBHOOK function discordWenhook(data) local color = '65352' local category = 'test' local information = {} if data.type == 'add' then color = Config.AddAdColor elseif data.type == 'buy' then color = Config.BuyItemColor information = { { ["color"] = color, ["author"] = { ["icon_url"] = Config.IconURL, ["name"] = Config.ServerName..' - Logs', }, ["title"] = data.title, ["description"] = '**Action:** '..data.action..'\n**Item:** '..data.item..'\n**Price:** '..data.price..'\n**Descrição:** '..data.desc..'\n**From:** '..data.from..'\n\n**ID:** '..data.playerid..'\n**Identifier:** '..data.identifier..'\n**Discord:** '..data.discord, ["footer"] = { ["text"] = os.date(Config.DateFormat), } } } elseif data.type == 'cancel' then color = Config.RemoveAdColor elseif data.type == 'claim' then color = Config.ClaimAdColor end information = { { ["color"] = color, ["author"] = { ["icon_url"] = Config.IconURL, ["name"] = Config.ServerName..' - Logs', }, ["title"] = data.title, ["description"] = '**Action:** '..data.action..'\n**Item:** '..data.item..'\n**Price:** '..data.price..'\n**Descrição:** '..data.desc..'\n\n**ID:** '..data.playerid..'\n**Identifier:** '..data.identifier..'\n**Discord:** '..data.discord, ["footer"] = { ["text"] = os.date(Config.DateFormat), } } } PerformHttpRequest(Webhook, function(err, text, headers) end, 'POST', json.encode({username = Config.BotName, embeds = information}), {['Content-Type'] = 'application/json'}) end Tem também um arquivo javamas é enorme Obrigado! scripts.js
  2. Encontrei esta parte do script tbm, será que pode estar aqui o erro? elseif OpennedChestUser[user_id] and OpennedChestUser[user_id].tipo == "HOUSE" then local bau = OpennedChestUser[user_id].name if OpennedHouse[bau] and dataHouseChest[bau] and OpennedHouse[bau] == user_id and dataHouseChest[bau][1][tostring(slot)] and dataHouseChest[bau][1][tostring(slot)].item ~= nil then if dataHouseChest[bau][1][tostring(slot)].amount >= amount then if vRP.computeInvWeight(user_id) + vRP.getItemWeight(tostring(dataHouseChest[bau][1][tostring(slot)].item)) * parseInt(amount) <= vRP.getInventoryMaxWeight(user_id) then vRP.giveInventoryItem(user_id, dataHouseChest[bau][1][tostring(slot)].item,amount, true, playerslot) vRP.sendLog("[Conteúdo oculto]_","O ID " .. user_id .. " retirou o ITEM: "..dataHouseChest[bau][1][tostring(slot)].item.." do bau da CASA: "..bau.." na quantidade de " .. amount .."x.") dataHouseChest[bau][1][tostring(slot)].amount = dataHouseChest[bau][1][tostring(slot)].amount - amount if dataHouseChest[bau][1][tostring(slot)].amount <= 0 then dataHouseChest[bau][1][tostring(slot)] = nil end return { success = "Item retirado com sucesso" } else return { error = "Mochila cheia." } end else return { error = "Você está tentando dumpar itens." } end else return { error = "Você não está com esse bau aberto." } end end Na real to deixando anexo todo o arquivo do server do script main.lua
  3. sim, no main.lua tem o dataHouseChest = {} e dentro de client\modules\chest.lua está assim: RegisterNetEvent("mirt1n:myHouseChest",function(id,houseid, maxBau) print(id, maxBau) local response = Remote.requireChest("HOUSE",maxBau,id) local source = source if vRP.getHealth(source) <= 101 then TriggerEvent('Notify', 'negado', 'Você não pode acessar o seu inventário agora.', 5000) return end if response then response.chest_type = "HOUSE" SendNUIMessage({route = "OPEN_CHEST",payload = response}) SetNuiFocus(true,true) end end)
  4. Obrigado pela resposta Mudei assim: elseif data == "HOUSE" then local minBauValue = nil -- Define minBauValue com um valor padrão if OpennedHouse[id] then return end if dataHouseChest[data[3]] == nil then local rows = vRP.query("s4-house/getAllHouses", { id = id }) local tmpChestData = vRP.getSData("homeChest:" .. id) -- Modificação aqui para obter os dados do tmpChest dataHouseChest[id] = { json.decode(tmpChestData) or json.decode(rows[1].bau) or {}, id, minBau } -- Usar os dados do tmpChest if tmpChestData then vRP.setSData("homeChest:" .. id, json.encode(dataHouseChest[id][1])) end for i, row in ipairs(rows) do if row.id == id then -- Verifica se a linha corresponde à casa específica minBauValue = row.minBau -- Atualiza o valor de minBauValue end end end local myHouseChest = {} local weight = 0.0 for k, v in pairs(dataHouseChest[id][1]) do if Items[v.item] then if Items[v.item] then v["amount"] = parseInt(v["amount"]) v["name"] = Items[v["item"]].name v["peso"] = Items[v["item"]].weight v["index"] = Items[v["item"]].index v["key"] = v["item"] v["slot"] = k myHouseChest[k] = v weight = weight + (Items[v.item].weight * parseInt(v["amount"])) end end end OpennedChestUser[user_id] = { tipo = "HOUSE", name = id } OpennedHouse[id] = user_id return { inventory = myHouseChest, weight = weight, max_weight = minBauValue } -- Usando minBauValue aqui end Da maneira que vc havia colocado (mirtin/allInfoHome) o baú nem abriu, coloquei s4-house/getAllHouses como vc informou e o bau abriu, porém, na identificação da capacidade de peso do bau apareceu UNDEFINED e se eu tentar colocar algo, aparece "Baú está cheio."
  5. Voltei aqui, pq é o unico lugar possivel de achar ajuda Este é a parte do código do inventário que está administrando os baús, os baus de de CARROS eORGs estão funcionando perfeitamente, só o das casas que estão com problemas. Segue o script: RegisterTunnel.requireChest = function(data, maxbau, id) local source = source local user_id = vRP.getUserId(source) if user_id then if data[1] == "VEHICLE" then if data[3] == 'malas' then local plate = GetVehicleNumberPlateText(NetworkGetEntityFromNetworkId(data[2])) local name = vehList[GetEntityModel(NetworkGetEntityFromNetworkId(data[2]))].model if OpennedVehicle[plate ..":" ..name] then return false end local nuser_id = vRP.getUserByRegistration(plate) if nuser_id ~= user_id then local check = vRP.getInventoryItemAmount(user_id, 'pedecabra') ------ alterar aqui fox if check > 0 then local request = vRP.request(source, "Você deseja arrombar esse porta malas?", 30) if request and vRP.tryGetInventoryItem(user_id, 'pedecabra', 1) then else return end ----- alterar aqui fox else local request = vRP.request(vRP.getUserSource(nuser_id), "Você deseja liberar acesso ao seu porta malas?", 30) if not request then TriggerClientEvent('Notify',source, "Negado", "O dono do veiculo recusou seu pedido para acessar o porta malas.", 5000) return end end end vRPclient._playAnim(source, true, { { "veh@break_in@0h@p_m_one@","low_force_entry_ds"} }, true) if dataVehicle[plate .. ":" .. name] == nil then if nuser_id then local rows = vRP.query("vRP/get_portaMalas",{ user_id = parseInt(nuser_id), veiculo = string.lower(name) }) or {} if #rows > 0 then local malas = json.decode(rows[1].portamalas) or {} dataVehicle[plate .. ":" .. name] = { malas, name, plate, false, true } else local rows = vRP.getSData("tmpChest:" .. name .. "_" .. plate) dataVehicle[plate .. ":" .. name] = { json.decode(rows) or {}, name, plate, true, true } end else local rows = vRP.getSData("tmpChest:" .. name .. "_" .. plate) dataVehicle[plate .. ":" .. name] = { json.decode(rows) or {}, name, plate, true, true } end end local myVehicle = {} local weight = 0.0 if dataVehicle[plate .. ":" .. name] then for k, v in pairs(dataVehicle[plate .. ":" .. name][1]) do if Items[v.item] then v["amount"] = parseInt(v["amount"]) v["name"] = Items[v["item"]].name v["peso"] = Items[v["item"]].weight v["index"] = v["item"] v["key"] = v["item"] v["slot"] = k myVehicle[k] = v weight = weight + (Items[v.item].weight * parseInt(v.amount)) end end end OpennedVehicle[plate .. ":" .. name] = user_id OpennedChestUser[user_id] = { tipo = "VEHICLE", name = plate .. ":" .. name, vehname = name } return { inventory = myVehicle, weight = weight, max_weight = vRP.getVehicleTrunk(name) } else local plate = GetVehicleNumberPlateText(NetworkGetEntityFromNetworkId(data[2])) local name = vehList[GetEntityModel(NetworkGetEntityFromNetworkId(data[2]))].model if OpennedVehicle[plate..":" ..name..':'..data[3]] then return false end local nuser_id = vRP.getUserByRegistration(plate) if nuser_id ~= user_id then local check = vRP.getInventoryItemAmount(user_id, 'pedecabra') ------ alterar aqui fox if check > 0 then local request = vRP.request(source, "Você deseja arrombar esse porta luvas?", 3000) if request and vRP.tryGetInventoryItem(user_id, 'pedecabra', 1) then else return end ----- alterar aqui fox else local request = vRP.request(vRP.getUserSource(nuser_id), "Você deseja liberar acesso ao seu porta luvas?", 3000) if not request then TriggerClientEvent('Notify',source, "Negado", "O dono do veiculo recusou seu pedido para acessar o porta luvas.", 5000) return end end end vRPclient._playAnim(source, true, { { "amb@prop_human_parking_meter@female@idle_a","idle_a_female"} }, true) if dataVehicle[plate..":" ..name..':'..data[3]] == nil then if nuser_id then local rows = vRP.query("vRP/get_portaLuvas",{ user_id = parseInt(nuser_id), veiculo = string.lower(name) }) or {} if #rows > 0 then local malas = json.decode(rows[1].portaluvas) or {} dataVehicle[plate..":" ..name..':'..data[3]] = { malas, name, plate, false, false } else local rows = vRP.getSData("tmpChest2:" .. name .. "_" .. plate) dataVehicle[plate..":" ..name..':'..data[3]] = { json.decode(rows) or {}, name, plate, true, false } end else local rows = vRP.getSData("tmpChest2:" .. name .. "_" .. plate) dataVehicle[plate..":" ..name..':'..data[3]] = { json.decode(rows) or {}, name, plate, true, false } end end local myVehicle = {} local weight = 0.0 if dataVehicle[plate..":" ..name..':'..data[3]] then for k, v in pairs(dataVehicle[plate..":" ..name..':'..data[3]][1]) do if Items[v.item] then v["amount"] = parseInt(v["amount"]) v["name"] = Items[v["item"]].name v["peso"] = Items[v["item"]].weight v["index"] = v["item"] v["key"] = v["item"] v["slot"] = k myVehicle[k] = v weight = weight + (Items[v.item].weight * parseInt(v.amount)) end end end OpennedVehicle[plate..":" ..name..':'..data[3]] = user_id OpennedChestUser[user_id] = { tipo = "VEHICLE", name = plate..":" ..name..':'..data[3], vehname = name } return { inventory = myVehicle, weight = weight, max_weight = parseInt(vRP.getVehicleTrunk(name)/3) } end elseif data[1] == "GROUP" then if OpennedOrg[data[3]] then return end vRPclient._playAnim(source, true, { { "amb@prop_human_parking_meter@female@idle_a","idle_a_female"} }, false) if (Chests[data[3]] and Chests[data[3]].permission ~= nil and vRP.hasPermission(user_id, Chests[data[3]].permission)) or (Chests[data[3]] and Chests[data[3]].permission == true) then if dataOrgChest[data[3]] == nil then local rows = vRP.getSData("orgChest:" .. data[3]) dataOrgChest[data[3]] = { json.decode(rows) or {} } end local myOrgChest = {} local weight = 0.0 for k, v in pairs(dataOrgChest[data[3]][1]) do if Items[v.item] then v["amount"] = parseInt(v["amount"]) v["name"] = Items[v["item"]].name v["peso"] = Items[v["item"]].weight v["index"] = v["item"] v["key"] = v["item"] v["slot"] = k myOrgChest[k] = v weight = weight + (Items[v.item].weight * parseInt(v["amount"])) end end OpennedChestUser[user_id] = { tipo = "GROUP", name = data[3] } OpennedOrg[data[3]] = user_id return { inventory = myOrgChest, weight = weight, max_weight = Chests[data[3]].weight } else TriggerClientEvent("Notify", source, "negado", "Você não tem permissão para acessar esse bau!", 8000) end elseif data == "HOUSE" then if OpennedHouse[id] then return end vRPclient._playAnim(source, true, { { "amb@prop_human_parking_meter@female@idle_a","idle_a_female"} }, false) if dataHouseChest[id] == nil then local rows = vRP.query("s4-house/getAllHouses", { id = id }) dataHouseChest[id] = { json.decode(rows[1].bau) or {}, houseID, maxbau } end local myHouseChest = {} local weight = 0.0 for k, v in pairs(dataHouseChest[id][1]) do if Items[v.item] then if Items[v.item] then v["amount"] = parseInt(v["amount"]) v["name"] = Items[v["item"]].name v["peso"] = Items[v["item"]].weight v["index"] = v["item"] v["key"] = v["item"] v["slot"] = k myHouseChest[k] = v weight = weight + (Items[v.item].weight * parseInt(v["amount"])) end end end OpennedChestUser[user_id] = { tipo = "HOUSE", name = id } OpennedHouse[id] = user_id -- vRPclient._stopAnim(source, false) return { inventory = myHouseChest, weight = weight, max_weight = maxbau } end end end
  6. Boa tarde meus amigos, Estou com uma base Havana muito top, quase sem bugs, porém, ela está com um bugzinho que nao consigo arrumar, quando eu coloco um item no baú da casa e saio da casa da esse erro: (node:16052) UnhandledPromiseRejectionWarning: Error: Query expected a string but received object instead at parseArguments (@oxmysql/dist/build.js:21579:11) at rawQuery (@oxmysql/dist/build.js:21734:29) (Use FXServer --trace-warnings ... to show where the warning was created) (node:16052) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see [Conteúdo oculto]). (rejection id: 1) O item até vai pro baú, e fica lá até resetar a cidade, quando reinicia, o bau volta vazio! Alguém da uma luz de como arrumar? Estou usando o inventário próprio da base havana_inventory e o sistema de house é s4-house Desde já, grato!
  7. Segue links com os scripts, inventário e de devistar! [Conteúdo oculto]
×
×
  • Criar Novo...

Informação Importante

Esse website utiliza Cookies, se continuar navegando você concordar na usabilidade.