Product Image
Ir para conteúdo
  • Cadastre-se

Anuncie aqui!

Coloque a sua cidade ou o seu servidor no Google!

Saiba mais

Fechado [AJUDA] Comando /revistar


Posts Recomendados

Boa tarde meus amigos, como sempre eu aqui tirando dúvidas!

Estou usando o inventário da DOPE, ja tentei usar vários scripts do comando /revistar e nenhum deles funcionam

Poderiam me ajudar a resolver?

Segue:

client.lua

Citar

local Tunnel = module("vrp","lib/Tunnel")
local Proxy = module("vrp","lib/Proxy")
vRP = Proxy.getInterface("vRP") 

dPN = {}
Tunnel.bindInterface("dpn_revistar",dPN)
Proxy.addInterface("dpn_revistar",dPN)
dPNserver = Tunnel.getInterface("dpn_revistar")

function dPN.openCheck()
    local nome, sobrenome, idade, registro = dPNserver.IdentityPerson()
    local try = 0
    while not nome and try < 15 do
        nome, sobrenome, idade, registro = dPNserver.IdentityPerson()
        try = try + 1
        Wait(100)
    end
    if not nome then
        nome = "Indefinido"
        sobrenome = "Indefinido"
        idade = "Indefinida"
        registro = "Indefinido"
        dPNserver.reportConsole("^1[dpn_revistar] ^7Oh não! Parece que não foi possível determinar a identidade de um usuário.")
    end
    SetNuiFocus(true, true)
    SetCursorLocation(0.5, 0.5)
    SendNUIMessage({action = "showMenu",type = 'open',nome = nome,sobrenome = sobrenome,idade = idade,registro = registro})
    TransitionToBlurred(1000)
end
RegisterNUICallback("checkClose", function(data, cb)
    dPNserver.closeMenu()
    SetNuiFocus(false, false)
    SetCursorLocation(0.5, 0.5)
    TransitionFromBlurred(1000)
    SendNUIMessage({action = "hideMenu",type = 'close'})
end)
-- Request Self Inventory
RegisterNUICallback("requestBackpackUser",function(data, cb)
    local inventoryweapon, inventario, peso2, maxpeso2 = dPNserver.userBackpack()
    while not inventario do
        inventoryweapon, inventario, peso2, maxpeso2 = dPNserver.userBackpack()
        Wait(100)
    end
    if inventario then
        cb({ inventoryweapon = inventoryweapon, inventario = inventario, peso = peso2, maxpeso = maxpeso2 })
    end
end)
-- Request Suspect Inventory
RegisterNUICallback("requestBackpackNuser", function(data, cb)
    local inventoryweapon2, inventario2, peso, maxpeso, money = dPNserver.nplayerBackpack()
    while not inventario2 do
        inventoryweapon2, inventario2, peso, maxpeso, money = dPNserver.nplayerBackpack()
        Wait(100)
    end
        cb({ inventoryweapon2 = inventoryweapon2, inventario2 = inventario2, peso = peso, maxpeso = maxpeso, money = money })
end)
RegisterNUICallback("stealItem",function(data, cb)
    local amount = data.amount
    if data.amount == 0 then
        amount = 1
    end
    dPNserver.stealitem(data.item, amount)
end)
RegisterNUICallback("giveBackItem", function(data, cb)
    local amount = data.amount
    if data.amount == 0 then
        amount = 1
    end
    dPNserver.giveBack(data.item, amount)
end)
RegisterNetEvent("dpn_revistar:update")
AddEventHandler("dpn_revistar:update", function(action)
    SendNUIMessage({ action = "updateCheck",type = "update" })
end)
-----------------------------------------------------------------------------------------------------------------------------------------
-- [ CARREGAR ]--------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------
local other = nil
local drag = false
local carregado = false
RegisterNetEvent("segurarrevistar")
AddEventHandler("segurarrevistar", function(p1)
    other = p1
    drag = not drag
end)

Citizen.CreateThread(function()
    while true do
        local sleep = 1000
        if drag and other then
            sleep = 5
            local ped = GetPlayerPed(GetPlayerFromServerId(other))
            Citizen.InvokeNative(0x6B9BBD38AB0796DF, PlayerPedId(), ped, 4103, 11816, 0.48, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
            carregado = true
        else
            if carregado then
                sleep = 5
                DetachEntity(PlayerPedId(), true, false)
                carregado = false
            end
        end
        Citizen.Wait(sleep)
    end
end)

function dPN.getHealth()
    return GetEntityHealth(PlayerPedId())
end
function dPN.verifyWeapon()
    local ped = PlayerPedId()
    local selectedWeapon = GetSelectedPedWeapon(ped)
    if not selectedWeapon or selectedWeapon == GetHashKey('WEAPON_UNARMED') then
        return true
    end
    TriggerEvent("Notify","negado","Você está com a mão ocupada.")
    return false
end

 

server.lua

Citar

local Tunnel = module("vrp","lib/Tunnel")
local Proxy = module("vrp","lib/Proxy")
vRP = Proxy.getInterface("vRP") 
vRPclient = Tunnel.getInterface("vRP") 

dPN = {}
Tunnel.bindInterface("dpn_revistar",dPN)
Proxy.addInterface("dpn_revistar",dPN)
dPNclient = Tunnel.getInterface("dpn_revistar")

local opened = {}
local roubados = Config.Roubado
local devolvido = Config.Devolvido
local cfgWeaponName = "|"
local opnedPlayer = {}
local revist = true

if Config.differentWeaponName ~= nil then
    print("^3[dpn_revistar] ^7Utilizando a nomenclatura especificada na configuração para os armamentos ^3(" .. cfgWeaponName .. ")^7")
    cfgWeaponName = Config.differentWeaponName
end

function SendWebhookMessage(webhook,message)
    if webhook ~= nil and webhook ~= "" then
        PerformHttpRequest(webhook, function(err, text, headers) end, 'POST', json.encode({content = message}), { ['Content-Type'] = 'application/json' })
    end
end


-----------------------------------------------------------------------------------------------------------------------------------------
-- MOCHILA USER ID
-----------------------------------------------------------------------------------------------------------------------------------------
function dPN.userBackpack()
    local source = source
    local user_id = vRP.getUserId(source)
    if user_id then
        local inventory = {}
        local inventoryweapon = {}
        local inv = vRP.getInventory(user_id)
        if inv then
            for k, v in pairs(inv) do
                if Config['inventario'] == true then
                    if vRP.itemBodyList(v.item) then
                        local type = vRP.itemTypeList(v.item)
                        if type == "equipar" then
                            table.insert(ninventory,{ amount = parseInt(v.amount), name = vRP.itemNameList(k), index = vRP.itemIndexList(k), key = k, peso = vRP.getItemWeight(k) })
                        elseif type == "usar" or type == "recarregar" then
                            table.insert(ninventory,{ amount = parseInt(v.amount), name = vRP.itemNameList(k), index = vRP.itemIndexList(k), key = k, peso = vRP.getItemWeight(k) })
                        end
                    end
                else
                    if vRP.itemBodyList(k) then
                        local type = vRP.itemTypeList(k)
                        if type == "equipar" then
                                table.insert(inventoryweapon, {
                                    amount = parseInt(v.amount),
                                    name = vRP.itemNameList(k),
                                    index = vRP.itemIndexList(k),
                                    key = k,
                                    peso = vRP.getItemWeight(k)
                            })
                        elseif type == "usar" or type == "recarregar" then
                                table.insert(inventory, {
                                    amount = parseInt(v.amount),
                                    name = vRP.itemNameList(k),
                                    index = vRP.itemIndexList(k),
                                    key = k,
                                    peso = vRP.itemWeightList(k)
                            })
                        end
                    end
                end
            end
            return inventoryweapon, inventory, vRP.computeInvWeight(user_id), vRP.getBackpack(user_id)
        end
    end
end
----------------------------------------------------------------------------------------------------------------------------------------
-- MOCHILA REVISTADO
----------------------------------------------------------------------------------------------------------------------------------------
function dPN.nplayerBackpack()
    local source = source
    local nuser_id = vRPclient.getNearestPlayer(source, 2)
    local nplayer = vRP.getUserId(nuser_id)
    local user_id = vRP.getUserId(source)
    
    if user_id and nplayer then
        local inventory = {}
        local inventoryweapon = {}
        local inv = vRP.getInventory(nplayer)
        local money = vRP.getMoney(nplayer)
        
        if inv then
            for k, v in pairs(inv) do
                local type = vRP.itemTypeList(k)
                
                if type == "equipar" then
                    table.insert(inventoryweapon, {
                        amount = parseInt(v.amount),
                        name = vRP.itemNameList(k),
                        index = vRP.itemIndexList(k),
                        key = k,
                        peso = vRP.getItemWeight(k)
                    })
                elseif type == "usar" or type == "recarregar" then
                    table.insert(inventory, {
                    amount = parseInt(v.amount),
                    name = vRP.itemNameList(k),
                    index = vRP.itemIndexList(k),
                    key = k,
                    peso = vRP.itemWeightList(k)
                    })
                end
            end
        end
        
        -- return inventoryweapon, inventory, vRP.computeInventoryWeight(nplayer), vRP.computeMaxInventoryWeight(nplayer), money
        -- return inventoryweapon, inventory, vRP.computeInvWeight(nplayer), vRP.getBackpack(nplayer), money
        return inventoryweapon,inventory,vRP.computeInvWeight(nplayer),vRP.getBackpack(nplayer), money
    end
end
-----------------------------------------------------------------------------------------------------------------------------------------
-- IDENTIDADE REVISTADO
-----------------------------------------------------------------------------------------------------------------------------------------
    function dPN.IdentityPerson()
    local source = source
    local user_id = vRP.getUserId(source)
    local nuser_id = vRPclient.getNearestPlayer(source, 2)
    local nplayer = vRP.getUserId(nuser_id)
    
    if user_id and nplayer then
        local identity = vRP.getUserIdentity(opened[user_id])
        if identity then
        return identity.name, identity.firstname, identity.age, identity.registration
    end
end
end

------------------------------------------------------------------------------------------------------------------------------------------
-- GIVE BACK ITEM
-----------------------------------------------------------------------------------------------------------------------------------------
function dPN.giveBack(item, amount)
    local source = source
    local user_id = vRP.getUserId(source)
    local nuser_id = vRPclient.getNearestPlayer(source, 2)
    local nplayer = opened[user_id]
    
    if user_id and nplayer then
        if Config.blacklistedItems then
            for _, v in pairs(Config.blacklistedItems or {}) do
                if v == item then 
                    TriggerClientEvent("Notify",source,"negado","Você não pode retirar este item!")
                    return 
                end
            end
        end
        
        -- if vRP.computeInvWeight(nplayer) + itemWeightList(item) * parseInt(amount) <= vRP.getBackpack(nplayer) then
        if vRP.computeInvWeight(opened[nplayer]) + vRP.itemWeightList(item) * parseInt(amount) <= vRP.getBackpack(opened[nplayer]) then
            if vRP.tryGetInventoryItem(user_id, item, amount) then
                vRP.giveInventoryItem(nplayer, item, amount)
                TriggerClientEvent('dpn_revistar:update', source, user_id)
                TriggerClientEvent("Notify", source, "sucesso", "Você enviou <b>" .. amount .. "x " .. vRP.itemNameList(item) .. "</b>", 8000)
                TriggerClientEvent("Notify", nuser_id, "sucesso", "Você recebeu <b>" .. amount .. "x " .. vRP.itemNameList(item) .. "</b>", 8000)
            end
        else
            TriggerClientEvent("Notify", source, "negado", "A pessoa não suporta isso", 8000)
        end
    end
end
            
------------------------------------------------------------------------------------------------------------------------------------------
-- GIVE BACK ITEM
-----------------------------------------------------------------------------------------------------------------------------------------
            
function dPN.stealitem(item, amount)
    local source = source
    local user_id = vRP.getUserId(source)
    local nuser_id = vRPclient.getNearestPlayer(source, 2)
    local nplayer = opened[user_id]
        
    if user_id and nplayer then
        if Config.blacklistedItems then
            for _, v in pairs(Config.blacklistedItems or {}) do
                if v == item then 
                    TriggerClientEvent("Notify",source,"negado","Você não pode retirar este item!")
                    return 
                end
            end
        end
        
        if item == "dinheiro" then
            if vRP.tryPayment(nplayer, amount) then
                vRP.giveMoney(user_id, amount)
                TriggerClientEvent('dpn_revistar:update', source, user_id)
            end
        end
        

        
            -- if vRP.computeInvWeight(user_id) + itemWeightList(item) * parseInt(amount) <= vRP.getBackpack(user_id) then
            if vRP.computeInvWeight(opened[user_id]) + vRP.itemWeightList(item) * parseInt(amount) <= vRP.getBackpack(opened[user_id]) then
            if vRP.tryGetInventoryItem(nplayer, item, amount) then
                vRP.giveInventoryItem(user_id, item, amount)
                TriggerClientEvent('dpn_revistar:update', source, user_id)
                TriggerClientEvent("Notify", source, "sucesso", "Retirou <b>" .. vRP.itemNameList(item) .. "</b>", 8000)
                TriggerClientEvent("Notify", nuser_id, "sucesso", "Retirado <b>" .. amount .. "x " .. vRP.itemNameList(item) .. "</b>", 8000)
            end
        else
            TriggerClientEvent("Notify", source, "negado", "Você não suporta isso", 8000)
        end
    end
end
            
function getInventoryWeight(user_id)
    local data = vRP.getUserDataTable(user_id)
    if data and data.inventory then
        return vRP.computeItemsWeight(data.inventory)
    end
    return 0
end
                        
                        ------------------------------------------------------------------------------------------------------------------------------------------
                        -- OPEN REVISTER
                        -----------------------------------------------------------------------------------------------------------------------------------------
                        
                        RegisterCommand("revistar", function(source, args, rawCommand)
                        local source = source
                        local user_id = vRP.getUserId(source)
                        if user_id then
                    local nplayer = vRPclient.getNearestPlayer(source, 2)
                    local nuser_id = vRP.getUserId(nplayer)
                    local weaponverify = dPNclient.verifyWeapon(source)
                    if nuser_id and weaponverify and revist == true then
                if not opnedPlayer[user_id] or opnedPlayer[user_id] == false then
                local vida = dPNclient.getHealth(nplayer)
                opnedPlayer[user_id] = true
                if vRP.hasPermission(user_id, Config.admin) then
                    opened[user_id] = parseInt(nuser_id)
                    dPNclient.openCheck(source)
                    armas()
                else
                    if vRP.hasPermission(user_id, Config.permissao) then
                        if Config.policia == false then
                            opened[user_id] = parseInt(nuser_id)
                            dPNclient.openCheck(source)
                            armas()
                    elseif Config.policia == true then
                            if vida > Config.vida then
                                if vRP.request(nplayer, "O policial quer lhe revisistar deseja aceitar?", 1000) then
                                    opened[user_id] = parseInt(nuser_id)
                                    dPNclient.openCheck(source)
                                    armas()
                            end
                        else
                                if Config.sapphire then
                                    if vRP.hasPermission(nuser_id, Config.permissao) then
                                        return
                                else
                                        opened[user_id] = parseInt(nuser_id)
                                        dPNclient.openCheck(source)
                                        armas()
                                end
                            else
                                    opened[user_id] = parseInt(nuser_id)
                                    dPNclient.openCheck(source)
                                    armas()
                            end
                        end
                        
                    end
                else
                        if Config.bandido == true then
                            if vida > Config.vida then
                                if vRP.request(nplayer, "Você está sendo revistado deseja aceitar?", 1000) then
                                    opened[user_id] = parseInt(nuser_id)
                                    dPNclient.openCheck(source)
                                    armas()
                            end
                        else
                                if Config.sapphire then
                                    if vRP.hasPermission(nuser_id, Config.permissao) then
                                        return
                                else
                                        opened[user_id] = parseInt(nuser_id)
                                        dPNclient.openCheck(source)
                                        armas()
                                end
                            else
                                    opened[user_id] = parseInt(nuser_id)
                                    dPNclient.openCheck(source)
                                    armas()
                            end
                        end
                    elseif Config.bandido == false then
                            opened[user_id] = parseInt(nuser_id)
                            dPNclient.openCheck(source)
                            armas()
                    end
                end
            end
        end
    else
                opened[user_id] = nil
            end
        end
    end)
        
        function progress(source)
            local source = source
            local user_id = vRP.getUserId(source)
            local nplayer = vRPclient.getNearestPlayer(source, 2)
            if nplayer then
                    if vRPclient.isInComa(nplayer) then
                TriggerClientEvent('segurarrevistar', nplayer, source)
                if Config['anim'] then
                    vRPclient._playAnim(source, false, {"amb@medic@standing@tendtodead@idle_a", "idle_a"}, true)
                else
                    vRPclient._playAnim(source, false, {{"amb@medic@standing@tendtodead@idle_a", "idle_a"}}, true)
                end
                TriggerClientEvent("progress", source, 5000, "revistando")
            else
                    TriggerClientEvent('segurarrevistar', nplayer, source)
                    if Config['anim'] then
                    vRPclient.playAnim(source, false, {"misscarsteal4@director_grip", "end_loop_grip"}, true)
                    vRPclient.playAnim(nplayer, false, {"random@mugging3", "handsup_standing_base"}, true)
                else
                    vRPclient.playAnim(source, false, {{"misscarsteal4@director_grip", "end_loop_grip"}}, true)
                    vRPclient.playAnim(nplayer, false, {{"random@mugging3", "handsup_standing_base"}}, true)
                end
                    TriggerClientEvent("progress", source, 5000, "revistando")
                    TriggerClientEvent("progress", nplayer, 5000, "sendo revistado")
                end
            end
        end
            
            function armas()
                local source = source
                local user_id = vRP.getUserId(source)
                local nplayer = vRPclient.getNearestPlayer(source, 2)
                local nuser_id = vRP.getUserId(nplayer)
                local weapons = vRPclient.replaceWeapons(nplayer, {})
                progress(source)
                TriggerClientEvent('cancelando', source, true)
                TriggerClientEvent('cancelando', nplayer, true)
                TriggerClientEvent('dope:enable:inventario',nplayer,true)
                    TriggerClientEvent('dope:inventory:close',nplayer)
                    TriggerClientEvent('dope:inventory:close',source)
                    
                    for k, v in pairs(weapons) do
                        vRP.giveInventoryItem(nuser_id, "wbody" .. cfgWeaponName .. "" .. k, 1)
                        vRP.giveInventoryItem(nuser_id, "wammo" .. cfgWeaponName .. k, v.ammo)
                        TriggerClientEvent('dpn_revistar:update', source, nuser_id)
                        TriggerClientEvent('dpn_revistar:update', source, nplayer)
                    end
                end
                    
                    function dPN.closeMenu()
                        local source = source
                        local user_id = vRP.getUserId(source)
                        local nuser_id = opened[user_id]
                        local nplayer = vRP.getUserSource(nuser_id)
                        
                        TriggerClientEvent('cancelando', source, false)
                        TriggerClientEvent('cancelando', nplayer, false)
                        
                        TriggerClientEvent('segurarrevistar', nplayer, source)
                        TriggerClientEvent('dope:enable:inventario',nplayer,false)
                        
                        vRPclient._stopAnim(nplayer, false)
                        vRPclient._stopAnim(source, false)
                        opnedPlayer[user_id] = false
                    end
                        
                        function dPN.reportConsole(text)
                        print(text)
                    end
                        
                        RegisterNetEvent('dope:enable:revistar')
                        AddEventHandler('dope:enable:revistar',function(status)
                            local source = source
                            if source then
                        revist = status
                    end
                end)

e config.lua

Citar

Config = {}

Config = {
    permissao = "policia.permissao", --Permissão de quem revistará sem verificar
    policia = false, --Coloque true caso policial precise pedir permissão para revistar
    bandido = true, --Coloque true caso bandido tenha q pedir permissao para revistar
    Roubado = "", --Coloque o webhook para quando um item for roubado
    Devolvido = "", --Coloque o webhook para quando um item for devolvido
    Command = "revistar", --Coloque o comando para abrir
    vida = 101, --Coloque a vida do personagem quando morto
    admin = "admin.permissao",
    bug = "" --Coloque aqui algum bug que você descobriu junto do seu dicord
}

 

 

Desde já, agradeço!

Link para o comentário
Compartilhar em outros sites

  • [🤖 BOT] Fivemdev

Olá, flawlessgui!

Agradecemos por compartilhar sua dúvida. Estamos comprometidos em resolver todas as questões neste tópico, mas a resolução depende do tipo de problema e da disponibilidade dos membros. Queremos ajudar, mas é importante entender que todos têm limitações de tempo. Contamos com sua compreensão e esperamos fornecer uma resposta rápida.

Coloque o máximo de informações possíveis para agilizar o seu pedido de ajuda, se possível coloque o seu script no tópico.

Obrigado.

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...

Informação Importante

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