• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Fix so you only can do the quest once!

Kisskotte

New Member
Joined
May 26, 2008
Messages
60
Reaction score
1
Hello have an issue with a quest i have done with an npc that you can do it serval of times just want you to be able to do it once!

General Bison.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="General Bison " script="data/npc/scripts/Quest2.lua" walkinterval="0" floorchange="0">
	<health now="100" max="100"/>
         <look type="134" head="114" body="132" legs="114" feet="76" addons="3"/>
  <parameters>
    <parameter key="message_greet" value="Hey you Solider I have a {quest} for you" />
		<parameter key="module_keywords" value="1" />
  </parameters>
</npc>

Quest2.lua
Code:
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

item = 'You do not have the required items.'
done = 'Here you are.'

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
		if msgcontains(msg, 'quest') then
		selfSay('I have Your first quest here! Go down to the south east house and grab my girls wooden {doll} from the chest', cid)


			elseif msgcontains(msg, 'doll') then
			if getPlayerItemCount(cid,2108) >= 1 then
				selfSay('Great I see that you have the doll! Can I have it?', cid)
				talk_state = 2
			else
				selfSay('Ehh... are you trying to fool me?', cid)
				talk_state = 0
			end

			elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerItemCount(cid,2108) >= 1 then
			if doPlayerRemoveItem(cid,2108, 1) == TRUE then
							selfSay('Thank you so much Now that I can trust you I have a bigger task for you but wait your weapon looks awful please go to Ian and he will help you get a better weapon and here is some money for your help.', cid)
			doPlayerAddItem(cid, 2152, 40)
			doPlayerAddExp(cid, 1000)
			end
			else
				selfSay(item, cid)
			end

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('Fool! Stop wasting my time then!')
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
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

item = 'You do not have the required items.'
done = 'Here you are.'
value = getPlayerStorageValue(cid, 22222)

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
		if msgcontains(msg, 'quest') and value == false then
		selfSay('I have Your first quest here! Go down to the south east house and grab my girls wooden {doll} from the chest', cid)


			elseif msgcontains(msg, 'doll') then
			if getPlayerItemCount(cid,2108) >= 1 then
				selfSay('Great I see that you have the doll! Can I have it?', cid)
				talk_state = 2
			else
				selfSay('Ehh... are you trying to fool me?', cid)
				talk_state = 0
			end

			elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerItemCount(cid,2108) >= 1 then
			if doPlayerRemoveItem(cid,2108, 1) == TRUE then
							selfSay('Thank you so much Now that I can trust you I have a bigger task for you but wait your weapon looks awful please go to Ian and he will help you get a better weapon and here is some money for your help.', cid)
			doPlayerAddItem(cid, 2152, 40)
			doPlayerAddExp(cid, 1000)
                        setPlayerStorageValue(cid, 22222, true)
			end
			else
				selfSay(item, cid)
			end

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('Fool! Stop wasting my time then!')
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

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

Try that, I just wrote it while I am at school, so it's a guess
 
Test this:

Code:
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 storage = 4000 <-- use unused storage

item = 'You do not have the required items.'
done = 'Here you are.'

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
		if msgcontains(msg, 'quest') then
		selfSay('I have Your first quest here! Go down to the south east house and grab my girls wooden {doll} from the chest', cid)


			elseif msgcontains(msg, 'doll') then
			if getPlayerItemCount(cid,2108) >= 1 then
				selfSay('Great I see that you have the doll! Can I have it?', cid)
				talk_state = 2
			else
			    if getPlayerStorageValue(cid,storage, 1) then
				selfSay('Ehh... are you trying to fool me?', cid)
				talk_state = 0
			end

			elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerItemCount(cid,2108) >= 1 then
			if doPlayerRemoveItem(cid,2108, 1) == TRUE then
							selfSay('Thank you so much Now that I can trust you I have a bigger task for you but wait your weapon looks awful please go to Ian and he will help you get a better weapon and here is some money for your help.', cid)
			doPlayerAddItem(cid, 2152, 40)
			doPlayerAddExp(cid, 1000)
            setPlayerStorageValue(cid,storage, 1)
			end
			else
				selfSay(item, cid)
			end

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('Fool! Stop wasting my time then!')
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
got an error
errrrrooorr.jpg

post the code here
Code:
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 storage = '20000'

item = 'You do not have the required items.'
done = 'Here you are.'

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
		if msgcontains(msg, 'quest') then
		selfSay('I have Your first quest here! Go down to the south east house and grab my girls wooden {doll} from the chest', cid)


			elseif msgcontains(msg, 'doll') then
			if getPlayerItemCount(cid,2108) >= 1 then
				selfSay('Great I see that you have the doll! Can I have it?', cid)
				talk_state = 2
			else
			    if getPlayerStorageValue(cid,storage, 1) then
				selfSay('Ehh... are you trying to fool me?', cid)
				talk_state = 0
			end

			elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerItemCount(cid,2108) >= 1 then
			if doPlayerRemoveItem(cid,2108, 1) == TRUE then
							selfSay('Thank you so much Now that I can trust you I have a bigger task for you but wait your weapon looks awful please go to Ian and he will help you get a better weapon and here is some money for your help.', cid)
			doPlayerAddItem(cid, 2152, 40)
			doPlayerAddExp(cid, 1000)
            setPlayerStorageValue(cid,storage, 1)
			end
			else
				selfSay(item, cid)
			end

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('Fool! Stop wasting my time then!')
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:ad
 
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

item = 'You do not have the required items.'
done = 'Here you are.'

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	
		if msgcontains(msg, 'quest') then
	        queststatus = getPlayerStorageValue(cid,5000)
		if queststatus == -1 then
		selfSay('I have Your first quest here! Go down to the south east house and grab my girls wooden {doll} from the chest', cid)
			else
				selfSay('I can\'t help you.', cid)
			end


			elseif msgcontains(msg, 'doll') then
			if getPlayerItemCount(cid,2108) >= 1 then
				selfSay('Great I see that you have the doll! Can I have it?', cid)
				talk_state = 2
			else
				selfSay('Ehh... are you trying to fool me?', cid)
				talk_state = 0
			end

			elseif msgcontains(msg, 'yes') and talk_state == 2 then
			talk_state = 0
			if getPlayerItemCount(cid,2108) >= 1 then
			if doPlayerRemoveItem(cid,2108, 1) == TRUE then
							selfSay('Thank you so much Now that I can trust you I have a bigger task for you but wait your weapon looks awful please go to Ian and he will help you get a better weapon and here is some money for your help.', cid)
			doPlayerAddItem(cid, 2152, 40)
			doPlayerAddExp(cid, 1000)
	                doPlayerSetStorageValue(cid, 5000, 1)
			end
			else
				selfSay(item, cid)
			end

        elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
            selfSay('Fool! Stop wasting my time then!')
            talk_state = 0
        end
    -- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.
    return true
end

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

Tested and works.
 
Oh, just tested it and I could only do the quest once. What kind of server do you use? This should work for at least 8.54 and 8.6.
 
Ah, looks like doPlayerSetStorageValue doesn't work anymore in 9.31. There is also an other one you can try: setPlayerStorageValue(cid,5000,1).
 
Limos Thank You I LOVE YOU it worked like a charm thank you for helping me. I know I'm a shit Scirpter but you where there and help me out REP!!
 
Back
Top