• 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 doubt!

demondark

New Member
Joined
Dec 20, 2007
Messages
140
Reaction score
0
How do I sell only 1 NPC (trade) for 1 player that is premium.

Code:
shopModule:addBuyableItem({'small health'}, 2173, 20000, 1, 'amulet of loss')
shopModule:addBuyableItem({'small health'}, 8704, 20, 1, 'small health potion')
shopModule:addBuyableItem({'health potion'}, 7618, 45, 1, 'health potion')
 
Make the NPC check for premium ;) Right now I'm at school. Maybe later :) (You can check the functions in data/lib/functions.lua if you want to try it alone)
 
exemplo:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}


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

    if(not npcHandler:isFocused(cid)) then
        return false
    end

keywordHandler:addKeyword({'hi'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Welcome, human Player, to our humble abode.'})

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


if (getPlayerStorageValue(cid, xxxxx) == 1) then 

	local shopModule = ShopModule:new()
	npcHandler:addModule(shopModule)

	shopModule:addSellableItem({'dragon lance'}, 2414, 9000, 'dragon lance')
	
	return true

else
	npcHandler:say('You Need Quest for trade', cid)

	return true

end



end

function onThink()                         npcHandler:onThink() end


npcHandler:addModule(FocusModule:new())


Is possible?
 
exemplo:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}


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

    if(not npcHandler:isFocused(cid)) then
        return false
    end

keywordHandler:addKeyword({'hi'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Welcome, human Player, to our humble abode.'})

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


if (getPlayerStorageValue(cid, xxxxx) == 1) then 

	local shopModule = ShopModule:new()
	npcHandler:addModule(shopModule)

	shopModule:addSellableItem({'dragon lance'}, 2414, 9000, 'dragon lance')
	
	return true

else
	npcHandler:say('You Need Quest for trade', cid)

	return true

end



end

function onThink()                         npcHandler:onThink() end


npcHandler:addModule(FocusModule:new())


Is possible?
Confused, do you want players to be premium or should they have done a quest before they can trade?

But if you want him to check for prem test this instead
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}


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

    if(not npcHandler:isFocused(cid)) then
        return false
    end

keywordHandler:addKeyword({'hi'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Welcome, human Player, to our humble abode.'})

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid


if isPremium(cid) ~= 1 then

	local shopModule = ShopModule:new()
	npcHandler:addModule(shopModule)

	shopModule:addSellableItem({'dragon lance'}, 2414, 9000, 'dragon lance')
	
	return true

else
	npcHandler:say('Get some respect before you talk to me', cid)

	return true

end



end

function onThink()                         npcHandler:onThink() end


npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top