Postado Dezembro 3, 2024 Dez 3 EU QUERO QUE FUNCIONA ASSIM O PLAYER VENDE UM ITEM NO SELL E É COLOCA NUM LIVRO O NOME DO ITEM E DINHEIRO QUANTIDADE DO ITEM NOME DO PLAYER TA VENDENDO ITEM PODE VENDE POR DINHEIRO MAXIMO É 1000000000 E O PLAYER VENDE ITEM O PLAYER DIGITA !CHECKSELLLIST APARECE A LISTA DOS ITENS QUE PLAYERS TA VENDENDO NOME DO ITEM QUANTIDADE E NOME DO DONO QUE TA VENDENDO O ITEM AI PLAYER DIGITA !BUY NOME DO ITEM DINHEIRO QUANTIDADE NOME DO DONO. !buy function onSay(cid, words, param) local config = { levelNeeded = 8, muteTime = 120, storage = 7896, validCurrencies = {9971, 2160, 2148, 2152, 2159}, maxPrice = 1000000000 } if param == '' then doPlayerPopupFYI(cid, "Say '!buy Item Name, 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 local itemName = t[1]:trim() local itemPrice = tonumber(t[2]) if not itemPrice or itemPrice <= 0 or itemPrice > config.maxPrice then doPlayerSendCancel(cid, "Invalid price. It must be a number between 1 and " .. config.maxPrice .. ".") return true end if getPlayerLevel(cid) < config.levelNeeded then doPlayerSendCancel(cid, "Only players with level " .. config.levelNeeded .. "+ can make a purchase.") return true end if getPlayerStorageValue(cid, config.storage) > os.time() then doPlayerSendCancel(cid, "You can only make one purchase every " .. config.muteTime .. " seconds.") return true end -- Verifica se o item existe local itemId = getItemIdByName(itemName, false) if not itemId then doPlayerSendCancel(cid, "Item '" .. itemName .. "' does not exist.") return true end -- Verifica se o jogador tem dinheiro suficiente local hasEnoughMoney = false for _, currency in ipairs(config.validCurrencies) do if getPlayerItemCount(cid, currency) >= itemPrice then doPlayerRemoveItem(cid, currency, itemPrice) hasEnoughMoney = true break end end if not hasEnoughMoney then doPlayerSendCancel(cid, "You do not have enough money to buy '" .. itemName .. "'.") return true end -- Adiciona o item ao inventário do jogador if doPlayerAddItem(cid, itemId, 1) then doBroadcastMessage("Player " .. getPlayerName(cid) .. " has purchased " .. itemName .. " for " .. itemPrice .. " gold coins.") setPlayerStorageValue(cid, config.storage, os.time() + config.muteTime) else doPlayerSendCancel(cid, "You don't have enough space to receive the item '" .. itemName .. "'.") -- Reembolsa o dinheiro doPlayerAddItem(cid, config.validCurrencies[1], itemPrice) end return true end !sell function onSay(cid, words, param) local config = { levelNeeded = 8, muteTime = 120, storage = 7897, validCurrencies = {9971, 2160, 2148, 2152, 2159}, maxPrice = 1000000000 } if param == '' then doPlayerPopupFYI(cid, "Say '!sell Item Name, 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 local itemName = t[1]:trim() local itemPrice = tonumber(t[2]) if not itemPrice or itemPrice <= 0 or itemPrice > config.maxPrice then doPlayerSendCancel(cid, "Invalid price. It must be a number between 1 and " .. config.maxPrice .. ".") return true end if getPlayerLevel(cid) < config.levelNeeded then doPlayerSendCancel(cid, "Only players with level " .. config.levelNeeded .. "+ can broadcast an offer.") return true end if getPlayerStorageValue(cid, config.storage) > os.time() then doPlayerSendCancel(cid, "You can only place one offer every " .. config.muteTime .. " seconds.") return true end -- Verifica o inventário ou backpack local itemId = getItemIdByName(itemName, false) if not itemId then doPlayerSendCancel(cid, "Item '" .. itemName .. "' does not exist.") return true end local itemCount = getPlayerItemCount(cid, itemId) if itemCount <= 0 then doPlayerSendCancel(cid, "You don't have the item '" .. itemName .. "' to sell.") return true end -- Remove o item vendido do inventário if doPlayerRemoveItem(cid, itemId, 1) then doBroadcastMessage("Player " .. getPlayerName(cid) .. " is selling " .. itemName .. " for " .. itemPrice .. " gold coins.") setPlayerStorageValue(cid, config.storage, os.time() + config.muteTime) else doPlayerSendCancel(cid, "Failed to remove the item '" .. itemName .. "' from your inventory.") end return true end
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.