• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Trade Window

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,326
Reaction score
136
Hello i recieveing a problem we made it work but it works only if you have gold coins in your inventory if you dont have it you cant use the ID coins. posible too somehow fix that ? or its deeper changes we should do ?

there is script of npc
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end

local shopWindow = {}

local things = {
     {action = 0, id = 6512, buy = 25, name = "Stamina Doll"},
     {action = 0, id = 5958, buy = 1, name = "Charged Summon Scroll"}
}

local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
local TradeItem = 2328
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought "..shopWindow[item].Price*amount.."")
        if doPlayerRemoveItem(cid, TradeItem, shopWindow[item].Price*amount)  then
         if isItemStackable(item) then
             doPlayerAddItem(cid, item, amount)
         else
             for x = 1, amount do
                 doPlayerAddItem(cid, item, 1)
             end
         end
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought "..amount.."x "..shopWindow[item].Name.." for "..shopWindow[item].Price*amount.." warfare tokens.")
     else
         selfSay("You don't have warfare tokens.", cid)
     end
     return true
end



function creatureSayCallback(cid, type, msg)
     if not npcHandler:isFocused(cid) then
         return false
     end

    if msgcontains(msg, 'rem') then
        doPlayerRemoveItem(cid, 2328, 5)
    end


     if msgcontains(msg, 'trade') then
        if getPlayerGroupId(cid) > 0 then
             for var, item in pairs(things) do
                if item.action == 0 then
                    shopWindow[item.id] = {Price = item.buy, Name = item.name}
                elseif item.action == 1 then
                    shopWindow[item.id] = {Price = item.sell, Name = item.name}
                end
             end
             openShopWindow(cid, things, onBuy,2, onSell)
        else
            npcHandler:say("This shop is only for tutors sorry.")
        end
     end
     return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
I don't really know if is on the engine or client-sided, but nothing that you could fix changing your script.
 
Back
Top