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

Lua Problem with NPC

Adi69

Active Member
Joined
Mar 14, 2008
Messages
161
Reaction score
35
Location
Poland
Hello OTlanders, who knew how to turn a this script?

script looks like this:

12:16 Naomi Smithson: Hello GOD Adi,welcome to my home! What brings you to me?
12:16 GOD Adi [200]: brings
12:16 Naomi Smithson: Ok, you can started your mission? Just say it.
12:16 GOD Adi [200]: mission
12:16 Naomi Smithson: Please bring me 50 blueberries, and tell me when you had them.
12:16 GOD Adi [200]: blueberries
12:16 Naomi Smithson: You already did it for me. I dont need more berries at the moment

and I wants to after writing "Brings" npc once stated that I have already done the task like this (unless of course I have already done the task):

12:16 Naomi Smithson: Hello GOD Adi,welcome to my home! What brings you to me?
12:16 GOD Adi [200]: brings
12:16 Naomi Smithson: You already did it for me. I dont need more berries at the moment

Code of this script:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() 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
if(msgcontains(msg, 'bring')) then
selfSay('Ok, you can started your {mission}? Just say it.', cid)
end
---------------------------------------------------------
if(msgcontains(msg, 'mission')) then
selfSay('Please bring me 50 {blueberries}, and tell me when you had them.', cid)
talkState[talkUser] = 1
elseif(msgcontains(msg, 'blueberries') and talkState[talkUser] == 1) then
if (getPlayerStorageValue(cid,100) > 0) then
selfSay('You already did it for me. I dont need more berries at the moment', cid)
else
if(doPlayerRemoveItem(cid, 2677, 50) == TRUE) then
setPlayerStorageValue(cid,100,1)
doPlayerAddExperience(cid,150)
doCreatureSay(cid, "You have earned +150 experience, right now.", TALKTYPE_ORANGE_1, cid)
selfSay('A very nice thank you! You are new here and I have liked you very much rigt now!', cid)
else
selfSay('You must have more items', cid)
end
end
return true
end

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

and:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Naomi Smithson" script="data/npc/scripts/mission.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1">
<health now="100" max="100"/>
<look type="136" head="59" body="76" legs="0" feet="38" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|,welcome to my home! What {brings} you to me?"/>
</parameters>
</npc>

and if you could add that in addition to experience npc give items and money :)
Thanks in advance!
 
Lua:
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 creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'bring') then
		selfSay('Okay, you can start your {mission}. Just say it.', cid)
	elseif msgcontains(msg, 'mission') or msgcontains(msg, 'blueberries') or msgcontains(msg, 'blueberry') then
		if getPlayerStorageValue(cid, 100) > 0 then
			selfSay('You already brought me 50 blueberries. I don\'t need any more berries at the moment.', cid)
		elseif doPlayerRemoveItem(cid, 2677, 50) then
			setPlayerStorageValue(cid, 100, 1)
			doPlayerAddExperience(cid, 150)
			doCreatureSay(cid, 'You have earned +150 experience, right now.', TALKTYPE_ORANGE_1, false, cid)
			selfSay('A very nice thank you! You are new here and I like you very much right now!', cid)
		else
			selfSay('Please bring me 50 {blueberries}, and tell me when you had them.', cid)
		end
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
(Sory I was not there a few days)

But Cykotitan unfortunately I must tell you, npc doesn't works :(

15:27 GOD Adi [200]: hi
15:27 Naomi Smithson: Hello GOD Adi,welcome to my home! What brings you to me?
15:27 GOD Adi [200]: brings
15:27 Naomi Smithson: Okay, you can start your mission. Just say it.
15:27 GOD Adi [200]: mission
15:27 GOD Adi [200]: blueberies

and then nothing happens, after that.
 
oh! what a fast response! But it works great thanks! :) Rep++

and this is a surprise for you:


sory but i wrote cykotian rather than cykotitan :D
 
Back
Top