Ir para conteúdo
  • 0

Quero vender um item que tenho no meu inventário, set ou bp, então na compra de item de jogador, compre o item por exemplo !venda escudo de placa, 1000000000 outro jogador !compre escudo de placa, 1000000000


Muvuka

Pergunta

BUY .LUA

LUA:
--[[ Buy & Sell Talkaction System

Made by Yohan(me). ]]--

function onSay(cid, words, param) -- script by Yohan

local config = {

              levelNeeded = 8,

              muteTime = 120, -- time in Seconds that the player will be without broadcasting.

              storage = 7896 -- storage that controls the broadcasting of the player.

              }

if param == '' then

doPlayerPopupFYI(cid, "Say '!buy Item Name, Price in GP'")

end



t = string.explode(param, ",")

if not(t[1]) or not(t[2]) then

doPlayerSendCancel(cid, "Command requires more than one parameter.")

else



if getPlayerLevel(cid) >= config.levelNeeded then



  if getPlayerStorageValue(cid,config.storage) == -1 then

  setPlayerStorageValue(cid, config.storage, os.time())



  elseif getPlayerStorageValue(cid,config.storage) > os.time() then

  doPlayerSendCancel(cid, "You can only place one offer in " .. config.muteTime .. " seconds.")



  elseif getPlayerStorageValue(cid,config.storage) <= os.time() then

  doBroadcastMessage("Player " .. getPlayerName(cid) .. " is buying " .. t[1] .. " for " .. t[2] .. " gold coins.")

  setPlayerStorageValue(cid,config.storage, (os.time() + config.muteTime))

  end



else

doPlayerSendCancel(cid, "Only players with level " .. config.levelNeeded .. "+ can broadcast one offer.")

end

end



return true

end

SELL .LUA

LUA:
--[[ Buy & Sell Talkaction System
Made by Yohan(me). ]]--
function onSay(cid, words, param) -- script by Yohan
local config = {
              levelNeeded = 8,
              muteTime = 120, -- time in Seconds that the player will be without broadcasting.
              storage = 7896 -- storage that controls the broadcasting of the player.
              }
if param == '' then
doPlayerPopupFYI(cid, "Say '!sell Item Name, Price in GP'")
end

t = string.explode(param, ",")
if not(t[1]) or not(t[2]) then
doPlayerSendCancel(cid, "Command requires more than one parameter.")
else

if getPlayerLevel(cid) >= config.levelNeeded then

  if getPlayerStorageValue(cid,config.storage) == -1 then
  setPlayerStorageValue(cid, config.storage, os.time())

  elseif getPlayerStorageValue(cid,config.storage) > os.time() then
  doPlayerSendCancel(cid, "You can only place one offer in " .. config.muteTime .. " seconds.")

  elseif getPlayerStorageValue(cid,config.storage) <= os.time() then
  doBroadcastMessage("Player " .. getPlayerName(cid) .. " is selling " .. t[1] .. " for " .. t[2] .. " gold coins.")
  setPlayerStorageValue(cid,config.storage, (os.time() + config.muteTime))
  end

else
doPlayerSendCancel(cid, "Only players with level " .. config.levelNeeded .. "+ can broadcast one offer.")
end
end

return true
end

validCurrencies = {9971, 2160, 2148, 2152, 2159}, maxPrice = 1000000000

 

EXEMPLO SE UM PLAYER VENDE UM ITEM !sell plate armor, 10 preço que for deferido NO COMANDO SELL APARECE A MEMSAGEM EM BROADCAST QUE PLAYER TA VENDENDO O ITEM AI ELE FALA !buy plate armor,10 qualquer item que player estive no set iventario bp

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • 0

Para o comando !sell:
 

function onSay(cid, words, param)
    local config = {
        levelNeeded = 8,
        muteTime = 120, -- tempo em segundos
        storage = 7896
    }
    
    if param == "" then
        doPlayerPopupFYI(cid, "Use: !sell itemName, price in GP")
        return true
    end
    
    local t = string.explode(param, ",")
    if not(t[1]) or not(t[2]) then
        doPlayerSendCancel(cid, "Command requires more than one parameter.")
        return true
    end

    if getPlayerLevel(cid) >= config.levelNeeded then
        if getPlayerStorageValue(cid, config.storage) == -1 then
            setPlayerStorageValue(cid, config.storage, os.time())
        elseif getPlayerStorageValue(cid, config.storage) > os.time() then
            doPlayerSendCancel(cid, "You can only place one offer in " .. config.muteTime .. " seconds.")
            return true
        else
            local itemName = t[1]:trim()
            local price = tonumber(t[2])
            if price <= 0 then
                doPlayerSendCancel(cid, "Invalid price.")
                return true
            end
            local itemId = getItemIdByName(itemName)
            if getPlayerItemCount(cid, itemId) > 0 then
                doBroadcastMessage("Player " .. getPlayerName(cid) .. " is selling " .. itemName .. " for " .. price .. " gold coins.")
                setPlayerStorageValue(cid, config.storage, (os.time() + config.muteTime))
            else
                doPlayerSendCancel(cid, "You don't have the item '" .. itemName .. "' to sell.")
            end
        end
    else
        doPlayerSendCancel(cid, "Only players with level " .. config.levelNeeded .. " can broadcast an offer.")
    end
    return true
end


Para o comando !buy:
 

function onSay(cid, words, param)
    local config = {
        levelNeeded = 8,
        muteTime = 120,
        storage = 7896
    }
    
    if param == "" then
        doPlayerPopupFYI(cid, "Use: !buy itemName, price in GP")
        return true
    end
    
    local t = string.explode(param, ",")
    if not(t[1]) or not(t[2]) then
        doPlayerSendCancel(cid, "Command requires more than one parameter.")
        return true
    end

    if getPlayerLevel(cid) >= config.levelNeeded then
        if getPlayerStorageValue(cid, config.storage) == -1 then
            setPlayerStorageValue(cid, config.storage, os.time())
        elseif getPlayerStorageValue(cid, config.storage) > os.time() then
            doPlayerSendCancel(cid, "You can only place one offer in " .. config.muteTime .. " seconds.")
            return true
        else
            local itemName = t[1]:trim()
            local price = tonumber(t[2])
            if price <= 0 then
                doPlayerSendCancel(cid, "Invalid price.")
                return true
            end

            -- Logica de compra do item: verificar se algum jogador está vendendo o item
            -- e o preço condiz com a oferta. Se sim, retirar o item do vendedor e
            -- transferir para o comprador

            doBroadcastMessage("Player " .. getPlayerName(cid) .. " is buying " .. itemName .. " for " .. price .. " gold coins.")
            setPlayerStorageValue(cid, config.storage, (os.time() + config.muteTime))
        end
    else
        doPlayerSendCancel(cid, "Only players with level " .. config.levelNeeded .. " can broadcast an offer.")
    end
    return true
end

 

Link para o comentário
Compartilhar em outros sites

  • Quem Está Navegando   0 membros estão online

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