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

[Request]Rewarder NPC

tokubasher

New Member
Joined
Nov 6, 2008
Messages
3
Reaction score
0
Hello,

I'm searching for a Rewarder NPC.
If you say Hi, the NPC must say "Hello are you the one?"
if player says: "yes"
Player get item 2160 cid: 50
and npc says: "Thanks for your help."

If Players says no then npc say "Well bye then"

Is this possible? Very much thanks! :D
(It's like a Quest)
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

function onCreatureAppear(cid) npcHandlerCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlerCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlerCreatureSay(cid, type, msg) end
function onThink() npcHandlerThink() end

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'hi') then
selfSay('Hello are you the one?')
if msgcontains(msg, 'yes') then
selfSay('Thanks for your help.')
doPlayerAddItem(cid,2160,1)
else 
selfSay('Well bye then ..')

return true
end

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


if player need a {storage}

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

function onCreatureAppear(cid) npcHandlerCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandlerCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandlerCreatureSay(cid, type, msg) end
function onThink() npcHandlerThink() end

function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'hi') then
selfSay('Hello are you the one?')
if msgcontains(msg, 'yes') and getPlayerStorageValue(cid, STORAGE HERE,1) == 1 then
selfSay('Thanks for your help.')
doPlayerAddItem(cid,2160,1)
else 
selfSay('Well bye then ..')

return true
end

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

not tested/
 
Thanks for you help!

I tested the first one, but there is an error
PHP:
[01/04/2009  20:16:48] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/princessalexia.lua
[01/04/2009  20:16:48] data/npc/scripts/princessalexia.lua:27: 'end' expected (to close 'if' at line 14) near '<eof>'

Then I added an end.
PHP:
[01/04/2009  20:17:33] [Warning - NpcScript::NpcScript] Can not load script: data/npc/scripts/princessalexia.lua
[01/04/2009  20:17:33] data/npc/scripts/princessalexia.lua:29: 'end' expected (to close 'function' at line 10) near '<eof>'

Then I added one more end. And this message came up
PHP:
[01/04/2009  20:17:55] Lua Script Error: [Npc interface] 
[01/04/2009  20:17:55] data/npc/scripts/princessalexia.lua:onCreatureAppear

[01/04/2009  20:17:55] data/npc/scripts/princessalexia.lua:5: attempt to call global 'npcHandlerCreatureAppear' (a nil value)
[01/04/2009  20:17:55] stack traceback:
[01/04/2009  20:17:55] 	data/npc/scripts/princessalexia.lua:5: in function <data/npc/scripts/princessalexia.lua:5>

And when I was trying to say hi (I guess) This happened and it was spamming the whole server window
PHP:
[01/04/2009  20:17:55] Lua Script Error: [Npc interface] 
[01/04/2009  20:17:55] data/npc/scripts/princessalexia.lua:onThink

[01/04/2009  20:17:55] data/npc/scripts/princessalexia.lua:8: attempt to call global 'npcHandlerThink' (a nil value)
[01/04/2009  20:17:55] stack traceback:
[01/04/2009  20:17:55] 	data/npc/scripts/princessalexia.lua:8: in function <data/npc/scripts/princessalexia.lua:8>



( I'm using TFS 0.2 )
 
Back
Top