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

ReDe

New Member
Joined
Mar 5, 2009
Messages
48
Reaction score
0
Hey, i need npc who will selling key with actionid 5580 for 10 cryctal coins.

please help me
 
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)        end
function onThink()                    npcHandler:onThink()                    end

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

    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    local keyid = 2222 -- Key ID
    local actionk = 5580 -- actionid of key
    
    if msgcontains(msg, 'key') then
    selfSay('Do you want buy my key?', cid)
    talkState[talkUser] = 1

    elseif talkState[talkUser] == 1 then
    if msgcontains(msg, 'yes') then
    if(doPlayerRemoveMoney(cid, 100000) == TRUE) then
    local item = doPlayerAddItem(cid,keyid,1)
    doSetItemActionId(item,actionk)
    selfSay('Great..', cid)
    talkState[talkUser] = 0
    else
    selfSay('You dont have enough money.', cid)
    talkState[talkUser] = 0
    end
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Fast made, untested.
If it won't work let me know, then i'll try to fix it :)
 
Back
Top