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

Npc sells a action key

galsegal90

New Member
Joined
Aug 21, 2007
Messages
130
Reaction score
3
Hey.. I want to put into the sellable list of an npc a key which open a door.. I mean I need to set this key into an ID..
no?

anyway, help please :)

I hope its in the right place..
 
Here you go, this should work:
(the NPC will reply if you tell him they keyword 'key')

Code:
		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

function KeySell(cid, message, keywords, parameters, node)

    if(not npcHandler:isFocused(cid)) then
        return false
    end
	
[COLOR="#008080"]	local price = [COLOR="#008080"][COLOR="#FF8C00"]1000 [/COLOR][/COLOR]-- enter the desired price here
	local kid = [COLOR="#FF8C00"]6666 [/COLOR]-- action ID to set to key
	local keyd = [COLOR="#FF8C00"]10000 [/COLOR]-- ID of the key
	local descrp = "[COLOR="#FF8C00"]enter some text here[/COLOR]" -- Set a description for the key
	local keynm = "[COLOR="#FF8C00"]Mystical Key[/COLOR]" -- Set a name for the key[/COLOR]


    if getPlayerMoney(cid) >= price then 
	
		doPlayerRemoveMoney(cid, price)
		
		local thing = doPlayerAddItem(cid, keyd)
		doItemSetAttribute(thing, "aid", kid) -- Set action
		doItemSetAttribute(thing, "description", descrp)
		doItemSetAttribute(thing, "name", keynm) -- Set a name for the key
		
		doSendMagicEffect(getCreaturePosition(cid), 12)	
        npcHandler:say('Well that was quite a bargain!',cid)  
        
	elseif
	    npcHandler:say('You don\'t have enough money.',cid)
    end

end


keywordHandler:addKeyword({'key'}, KeySell, {})

npcHandler:addModule(FocusModule:new())
 
Prefer to use
Lua:
doSetItemActionId(uid, actionid)
because 0.2 does not support item attribute modifications, yet.
 
Back
Top