• 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 NPC TRADE Storage Value

rexgandi

Member
Joined
Oct 22, 2011
Messages
189
Reaction score
9
Hello.
I need NPC.
If player have storage = xxxx then can sell items:

abc

elseif have storage = zzzz then can sell items:

def

elseif ....
 
using this as an example..


I'm pretty sure you can move the buy and sell stuff into an onGreet method

Something like this...?
Lua:
local storage = 45001
local function greetCallback(cid)
    local player = Player(cid)
    if player:getStorageValue(storage) > 0 then
        shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook')
    end
    return true
end
Lua:
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
 
using this as an example..


I'm pretty sure you can move the buy and sell stuff into an onGreet method

Something like this...?
Lua:
local storage = 45001
local function greetCallback(cid)
    local player = Player(cid)
    if player:getStorageValue(storage) > 0 then
        shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook')
    end
    return true
end
Lua:
npcHandler:setCallback(CALLBACK_GREET, greetCallback)

Yes, something like this, but i try write this code and nothig...
Actions/ Movements etc. i like write, but NPC... WTF? ...
 
@Xikini As shopModule is not re-instanciated every time (and it's per npc) it would addBuyableItem into shopModule and all players later could benefit that.
 
@Xikini As shopModule is not re-instanciated every time (and it's per npc) it would addBuyableItem into shopModule and all players later could benefit that.
Ah. I knew it sounded too easy. xD

I remember people doing something strange like modifying/creating their own shop function.. this is probably why.
 
Yeaa I remember back in the days I wrote some additional parameter to pass storageId to addBuyableItem/addSellableItem and check it later on buy/sell. There's probably easiest way but that was looong time ago :)
 
Back
Top