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 voices = {{text = "Hey! I have items for you!"}}
npcHandler:addModule(VoiceModule:new(voices))
local function greetCallback(cid)
local player = Player(cid)
player:setStorageValue(399399, 0)
return true
end
local function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if not npcHandler:isFocused(cid) then
return false
end
if msgcontains(msg, "test ring") then
npcHandler:say("Do you want buy test ring for 10 GI?", cid)
player:setStorageValue(399399, 1)
end
if msgcontains(msg, "yes") and player:getStorageValue(399399) == 1 then
if player:removeMoney(10000000) then
npcHandler:say("Nice, there is your test ring! Have a good day!", cid)
player:addItem(2376, 1, true, 500)
player:setStorageValue(399399, 0)
else
npcHandler:say("You don\'t have enough money!", cid)
player:setStorageValue(399399, 0)
end
end
if msgcontains(msg, "no") then
npcHandler:say("Ok.", cid)
player:setStorageValue(399399, 0)
end
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. I have items for you, check it:\n>> {Test Ring} for 10 GI')
npcHandler:addModule(FocusModule:new())