• 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 Is it possible to add storage on Trader npc?

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
873
Solutions
2
Reaction score
49
Is it possible to add a storage check for a trader? Lets say if you he doesnt have storage 6541 npc would say "You have to finish blablabla" so trade wont open and if he have that storage it would allow to type trade.

And whats the max amount money you can ask from player is it 999gold or 1000gold?

Lua:
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
 
shopModule:addBuyableItem({'test1'}, 2672, 400, 1, 'test1')
shopModule:addBuyableItem({'test2'}, 2691, 300, 1, 'test2')
shopModule:addBuyableItem({'test3'}, 2675, 300, 1, 'test3')
shopModule:addBuyableItem({'test4'}, 2677, 200, 1, 'test4')
shopModule:addBuyableItem({'test5'}, 2678, 200, 1, 'test5')
shopModule:addBuyableItem({'test6'}, 2666, 300, 1, 'test6')
 
function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Solution
And whats the max amount money you can ask from player is it 999gold or 1000gold?
I don't think there is a limit to how much gold something can cost.
At the very least, I know it can go to 99 million, so basically limitless.
Is it possible to add a storage check for a trader? Lets say if you he doesnt have storage 6541 npc would say "You have to finish blablabla" so trade wont open and if he have that storage it would allow to type trade.

Try this.

Untested.
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)...
And whats the max amount money you can ask from player is it 999gold or 1000gold?
I don't think there is a limit to how much gold something can cost.
At the very least, I know it can go to 99 million, so basically limitless.
Is it possible to add a storage check for a trader? Lets say if you he doesnt have storage 6541 npc would say "You have to finish blablabla" so trade wont open and if he have that storage it would allow to type trade.

Try this.

Untested.
Lua:
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'test1'}, 2672, 400, 1, 'test1')
shopModule:addBuyableItem({'test2'}, 2691, 300, 1, 'test2')
shopModule:addBuyableItem({'test3'}, 2675, 300, 1, 'test3')
shopModule:addBuyableItem({'test4'}, 2677, 200, 1, 'test4')
shopModule:addBuyableItem({'test5'}, 2678, 200, 1, 'test5')
shopModule:addBuyableItem({'test6'}, 2666, 300, 1, 'test6')

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

local function onTradeRequest(cid)
    if Player(cid):getStorageValue(6541) < 1 then
        npcHandler:say("You have to finish blablabla", cid)
        return false
    end
    return true
end

npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Solution
I don't think there is a limit to how much gold something can cost.
At the very least, I know it can go to 99 million, so basically limitless.


Try this.

Untested.
Lua:
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 shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'test1'}, 2672, 400, 1, 'test1')
shopModule:addBuyableItem({'test2'}, 2691, 300, 1, 'test2')
shopModule:addBuyableItem({'test3'}, 2675, 300, 1, 'test3')
shopModule:addBuyableItem({'test4'}, 2677, 200, 1, 'test4')
shopModule:addBuyableItem({'test5'}, 2678, 200, 1, 'test5')
shopModule:addBuyableItem({'test6'}, 2666, 300, 1, 'test6')

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

local function onTradeRequest(cid)
    if Player(cid):getStorageValue(6541) < 1 then
        npcHandler:say("You have to finish blablabla", cid)
        return false
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
No errors but didnt worked
 
Back
Top