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

help quest

Keru

Entrepreneur
Joined
Jul 24, 2008
Messages
1,780
Solutions
2
Reaction score
170
Location
USA
well i was working on the example of quest by npc and i were playing with it but i need help
PHP:
 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
function creatureSayCallback(cid, type, msg)
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	--[[
	REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE!
	]]--
	
	local storage = 10000
	local pos = {x=956, y=1026, z=7}
	if(msgcontains(msg, 'quest') or msgcontains(msg, 'job')) then
		if(getPlayerStorageValue(cid, storage) < 1) then
			npcHandler:say("Hey, you could pass without paying every time, just bring me please {10 crystal coins}.", cid)
			setPlayerStorageValue(cid, storage, 1)
		elseif(getPlayerStorageValue(cid, storage) == 1) then
			npcHandler:say("Do you have bring the 10 crystal coins for me?", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, storage) == 2) then
			npcHandler:say("Sorry, you have already done mi quest.", cid)
		end
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(doPlayerRemoveMoney(cid, 100000) == TRUE) then
			npcHandler:say("Thanks! As I said,now you can pass with out paying!", cid)
			--doPlayerAddItem(cid, 2160, 20)
			setPlayerStorageValue(cid, storage, 2)
			talkState[talkUser] = 0
		else
			npcHandler:say("Sorry, you don\'t have enough money.", cid)
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
		npcHandler:say("Then not.", cid)
		talkState[talkUser] = 0
	end
	
	if(msgcontains(msg, 'pass') or msgcontains(msg, 'cross')) then
	if(getPlayerStorageValue(cid, storage) < 2) then
	     npcHandler:say("I can let you go in to the private, you just need to pay a fee. Do you want to cross?", cid)
		 talkState[talkUser] = 3
	     elseif(getPlayerStorageValue(cid, storage) == 2) then
	      npcHandler:say("I can let you go in to the private,if you want to. Do you want to pass?", cid)
		  talkState[talkUser] = 2
		  end
		  elseif(msgcontains(msg, 'yes')) then 
             if(talkState[talkUser] == 2) then
		   if(doTeleportThing(cid, pos)) then
			npcHandler:say("Thanks! As I said,now you can pass with out paying. Have fun in the private quarter!", cid)
			talkState[talkUser] = 0
                                  elseif talkState[talkUser] == 3 then
                                   npcHandler:say("Ask me for {quest}", cid)
			talkState[talkUser] = 0
		else
			npcHandler:say("Sorry, you don\'t have enough money.", cid)
			talkState[talkUser] = 0
		end
                      end
	elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then
		npcHandler:say("Then not.", cid)
		talkState[talkUser] = 0
	end
	return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
its sopost to teleport some one who did not do the quest but it dosent :S can some body help me :S
srry for my english
 
Try this:
LUA:
 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 
function creatureSayCallback(cid, type, msg) 
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
    --[[ 
    REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE! 
    ]]-- 
     
    local storage = 10000 
    local pos = {x=956, y=1026, z=7} 
    if(msgcontains(msg, 'quest') or msgcontains(msg, 'job')) then 
        if(getPlayerStorageValue(cid, storage) < 1) then 
            npcHandler:say("Hey, you could pass without paying every time, just bring me please {10 crystal coins}.", cid) 
            setPlayerStorageValue(cid, storage, 1) 
        elseif(getPlayerStorageValue(cid, storage) == 1) then 
            npcHandler:say("Do you have bring the 10 crystal coins for me?", cid) 
            talkState[talkUser] = 1 
        elseif(getPlayerStorageValue(cid, storage) == 2) then 
            npcHandler:say("Sorry, you have already done mi quest.", cid) 
        end 
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then 
        if(doPlayerRemoveMoney(cid, 100000) == TRUE) then 
            npcHandler:say("Thanks! As I said,now you can pass with out paying!", cid) 
            --doPlayerAddItem(cid, 2160, 20) 
            setPlayerStorageValue(cid, storage, 2) 
            talkState[talkUser] = 0 
        else 
            npcHandler:say("Sorry, you don\'t have enough money.", cid) 
            talkState[talkUser] = 0 
        end 
    elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then 
        npcHandler:say("Then not.", cid) 
        talkState[talkUser] = 0 
    end 
     
    if(msgcontains(msg, 'pass') or msgcontains(msg, 'cross')) then 
    if(getPlayerStorageValue(cid, storage) < 2) then 
         npcHandler:say("I can let you go in to the private, you just need to pay a fee. Do you want to cross?", cid) 
         talkState[talkUser] = 3 
         elseif(getPlayerStorageValue(cid, storage) == 2) then 
          npcHandler:say("I can let you go in to the private,if you want to. Do you want to pass?", cid) 
          talkState[talkUser] = 2 
          end 
          elseif(msgcontains(msg, 'yes')) then  
             if(talkState[talkUser] == 2) then 
            doTeleportThing(cid, pos)
            npcHandler:say("Thanks! As I said,now you can pass with out paying. Have fun in the private quarter!", cid) 
            talkState[talkUser] = 0 
                                  elseif talkState[talkUser] == 3 then 
                                   npcHandler:say("Ask me for {quest}", cid) 
            talkState[talkUser] = 0 
        else 
            npcHandler:say("Sorry, you don\'t have enough money.", cid) 
            talkState[talkUser] = 0 
        end 
                      end 
    elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then 
        npcHandler:say("Then not.", cid) 
        talkState[talkUser] = 0 
    end 
    return TRUE 
end 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

btw, you posted in the wrong section xD
 
@up
Code:
[06/03/2010 09:55:22] [Error - LuaScriptInterface::loadFile] data/npc/scripts/quest.lua:63: 'end' expected (to close 'function' at line 9) near 'elseif'
[06/03/2010 09:55:22] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/quest.lua
[06/03/2010 09:55:22] data/npc/scripts/quest.lua:63: 'end' expected (to close 'function' at line 9) near 'elseif'
 
Now?
LUA:
 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 
function creatureSayCallback(cid, type, msg) 
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
    --[[ 
    REMEMBER TO SET YOUR STORAGE AS YOURSTORAGE! 
    ]]-- 
     
    local storage = 10000 
    local pos = {x=956, y=1026, z=7} 
    if(msgcontains(msg, 'quest') or msgcontains(msg, 'job')) then 
        if(getPlayerStorageValue(cid, storage) < 1) then 
            npcHandler:say("Hey, you could pass without paying every time, just bring me please {10 crystal coins}.", cid) 
            setPlayerStorageValue(cid, storage, 1)
        elseif(getPlayerStorageValue(cid, storage) == 1) then 
            npcHandler:say("Do you have bring the 10 crystal coins for me?", cid) 
            talkState[talkUser] = 1 
        elseif(getPlayerStorageValue(cid, storage) == 2) then 
            npcHandler:say("Sorry, you have already done mi quest.", cid) 
        end
   end
    if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then 
        if(doPlayerRemoveMoney(cid, 100000) == TRUE) then 
            npcHandler:say("Thanks! As I said,now you can pass with out paying!", cid) 
            --doPlayerAddItem(cid, 2160, 20) 
            setPlayerStorageValue(cid, storage, 2) 
            talkState[talkUser] = 0 
        else 
            npcHandler:say("Sorry, you don\'t have enough money.", cid) 
            talkState[talkUser] = 0 
        end
    elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then 
        npcHandler:say("Then not.", cid) 
        talkState[talkUser] = 0 
    end     
    if(msgcontains(msg, 'pass') or msgcontains(msg, 'cross')) then 
    if(getPlayerStorageValue(cid, storage) < 2) then 
         npcHandler:say("I can let you go in to the private, you just need to pay a fee. Do you want to cross?", cid) 
         talkState[talkUser] = 3 
         elseif(getPlayerStorageValue(cid, storage) == 2) then 
          npcHandler:say("I can let you go in to the private,if you want to. Do you want to pass?", cid) 
          talkState[talkUser] = 2 
          end 
          if(msgcontains(msg, 'yes')) then  
             if(talkState[talkUser] == 2) then 
            doTeleportThing(cid, pos)
            npcHandler:say("Thanks! As I said,now you can pass with out paying. Have fun in the private quarter!", cid) 
            talkState[talkUser] = 0 
                                  elseif talkState[talkUser] == 3 then 
                                   npcHandler:say("Ask me for {quest}", cid) 
            talkState[talkUser] = 0 
        else 
            npcHandler:say("Sorry, you don\'t have enough money.", cid) 
            talkState[talkUser] = 0 
        end
          elseif(msgcontains(msg, 'no') and talkState[talkUser] > 0) then 
             npcHandler:say("Then not.", cid) 
              talkState[talkUser] = 0 
          end 
    return TRUE 
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local storage = 10000
local pos = {x=956, y=1026, z=7}

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, 'quest') or msgcontains(msg, 'job') then
		local v = getPlayerStorageValue(cid, storage)
		if v < 1 then
			npcHandler:say("Hey, you could pass without paying every time, just bring me please {10 crystal coins}.", cid)
			setPlayerStorageValue(cid, storage, 1)
		elseif v == 1 then
			npcHandler:say("Do you have bring the 10 crystal coins for me?", cid)
		elseif v == 2 then
			npcHandler:say("Sorry, you have already done my quest.", cid)
		end
		Topic[cid] = v == 1 and 1 or 0
	elseif msgcontains(msg, 'yes') and Topic[cid] == 1 then
		if doPlayerRemoveMoney(cid, 100000) == TRUE then
			npcHandler:say("Thanks! As I said, now you can pass with out paying!", cid)
			setPlayerStorageValue(cid, storage, 2)
			Topic[cid] = 0
		else
			npcHandler:say("Sorry, you don't have enough money.", cid)
			Topic[cid] = 0
		end
	elseif msgcontains(msg, 'pass') or msgcontains(msg, 'cross') then
		if getPlayerStorageValue(cid, storage) < 2 then
			npcHandler:say("I can let you go in to the private, you just need to pay a fee. Do you want to cross?", cid)
			Topic[cid] = 3
		elseif getPlayerStorageValue(cid, storage) == 2 then
			npcHandler:say("I can let you go in to the private, if you want to. Do you want to pass?", cid)
			Topic[cid] = 2
		end
	elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		npcHandler:say("Thanks! As I said, now you can pass with out paying. Have fun in the private quarter!", cid)
		npcHandler:releaseFocus(cid)
		doTeleportThing(cid, pos)
		doSendMagicEffect(pos, CONST_ME_TELEPORT)
		Topic[cid] = 0
	elseif Topic[cid] == 3 then
		npcHandler:say("Ask me for {quest}.", cid)
		Topic[cid] = 0
	elseif Topic[cid] > 0 then
		npcHandler:say("Then not.", cid)
		Topic[cid] = 0
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
@up
are u human :O. na just a joke :D thx xDDDD
but can u edit it plz to cross ppl not to say askme for quest, but for a fee of mm xxx money?
 
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local storage = 10000
local pos = {x=956, y=1026, z=7}
[B]local fee = [COLOR="Red"]10000[/COLOR][/B]

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, 'quest') or msgcontains(msg, 'job') then
		local v = getPlayerStorageValue(cid, storage)
		if v < 1 then
			npcHandler:say("Hey, you could pass without paying every time, just bring me please {10 crystal coins}.", cid)
			setPlayerStorageValue(cid, storage, 1)
		elseif v == 1 then
			npcHandler:say("Do you have bring the 10 crystal coins for me?", cid)
		elseif v == 2 then
			npcHandler:say("Sorry, you have already done my quest.", cid)
		end
		Topic[cid] = v == 1 and 1 or 0
	elseif msgcontains(msg, 'yes') and Topic[cid] == 1 then
		if doPlayerRemoveMoney(cid, 100000) == TRUE then
			npcHandler:say("Thanks! As I said, now you can pass with out paying!", cid)
			setPlayerStorageValue(cid, storage, 2)
			Topic[cid] = 0
		else
			npcHandler:say("Sorry, you don't have enough money.", cid)
			Topic[cid] = 0
		end
	elseif msgcontains(msg, 'pass') or msgcontains(msg, 'cross') then
		if getPlayerStorageValue(cid, storage) < 2 then
			npcHandler:say("I can let you go in to the private, you just need to pay a fee of " .. fee .. " gold. Do you want to cross?", cid)
			Topic[cid] = 3
		elseif getPlayerStorageValue(cid, storage) == 2 then
			npcHandler:say("I can let you go in to the private, if you want to. Do you want to pass?", cid)
			Topic[cid] = 2
		end
	elseif msgcontains(msg, 'yes') and Topic[cid] == 2 then
		doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
		npcHandler:say("Thanks! As I said, now you can pass with out paying. Have fun in the private quarter!", cid)
		npcHandler:releaseFocus(cid)
		doTeleportThing(cid, pos)
		doSendMagicEffect(pos, CONST_ME_TELEPORT)
		Topic[cid] = 0
	elseif msgcontains(msg, 'yes') and Topic[cid] == 3 then
		if doPlayerRemoveMoney(cid, fee) == TRUE then
			doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
			npcHandler:say("Thanks! Have fun in the private quarter!", cid)
			npcHandler:releaseFocus(cid)
			doTeleportThing(cid, pos)
			doSendMagicEffect(pos, CONST_ME_TELEPORT)
		else
			npcHandler:say("You don't have enough money!", cid)
		end
		Topic[cid] = 0
	elseif Topic[cid] > 0 then
		npcHandler:say("Then not.", cid)
		Topic[cid] = 0
	end
	return true
end

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