Ir para conteúdo

NPC (Você precisa de uma storage para falar com ele)


Posts Recomendados

O título já diz.

 

Script -

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

local storage = 1234


function creatureSayCallback(cid, type, msg)
if (msgcontains(msg, "hi") or msgcontains(msg, "hello")) and (not npcHandler:isFocused(cid)) then
if getPlayerStorageValue(cid, storage) < 1 then
npcHandler:say("How can I help you " .. getPlayerName(cid) .. "?", cid, TRUE)
npcHandler:releaseFocus(cid)
setPlayerStorageValue(cid, storage, 1)
doPlayerAddMoney(cid, math.ceil(math.random(500, 5000)))
elseif getPlayerStorageValue(cid, storage) == 1 then
npcHandler:say("I got no time. Bye!", cid, TRUE)
npcHandler:releaseFocus(cid)
end
elseif (not npcHandler:isFocused(cid)) then
return false
end
return true
end

npcHandler:setCallback(CALLBACK_FAREWELL, creatureFarewell)
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye then.")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

 

Pegue um arquivo qualquer de um npc em .xml para colocar na pasta NPC.

Créditos - StreamSide

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...