Jump to content
  • 0

Předělat to aby to dávalo peníze do frakce a ne hráčovi


MarsuniX

Question

Ahoj, potřeboval bych poradit jak předělat daný soubor na aby to dávalo peníze do frakce a ne hráčovi zde přikládám config určitého souboru.
 

function getMarketItems(playerId, cb, markerId)
    if(not canUseMarkerWithLog(playerId, markerId)) then return end
 
    local items = {}
   
    for itemName, itemData in pairs(fullMarkerData[markerId].data.items) do
        local color = "green"
 
        if(itemData.blackMoney) then
            color = "red"
        end
 
        table.insert(items, {
            label = getLocalizedText('market_item', ESX.GetItemLabel(itemName), color, itemData.price),
            value = itemName
        })
    end
 
    cb(items)
end
 
local function sellMarketItem(markerId, itemName, itemQuantity)
    local playerId = source
 
    if(not canUseMarkerWithLog(playerId, markerId)) then return end
 
    local itemData = fullMarkerData[markerId].data.items[itemName]
 
    if(itemData) then
        local itemLabel = ESX.GetItemLabel(itemName)
 
        local xPlayer = ESX.GetPlayerFromId(playerId)
 
        if(xPlayer.getInventoryItem(itemName).count >= itemQuantity) then
            xPlayer.removeInventoryItem(itemName, itemQuantity)
           
            local totalMoney = itemData.price * itemQuantity
 
            if(itemData.blackMoney) then
                xPlayer.addAccountMoney('black_money', totalMoney)
            else
                local moneyAccount = xPlayer.getAccounts()
 
                if(moneyAccount) then
                    xPlayer.addAccountMoney('money', totalMoney)
                else
                    xPlayer.addAccountMoney(totalMoney)
                end
            end
 
            local color = "~g~"
 
            if(itemData.blackMoney) then
                color = "~r~"
            end
 
            notify(playerId, getLocalizedText('you_sold', itemQuantity, itemLabel, color, ESX.Math.GroupDigits(totalMoney)))
 
            log(
                playerId,
                getLocalizedText('log_sold_item'),
                getLocalizedText('log_sold_item_description', itemQuantity, itemLabel, ESX.Math.GroupDigits(totalMoney)),
                'success',
                'market'
            )
        else
            notify(playerId, getLocalizedText('not_enough_item', itemLabel))
        end
    end
end
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...