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

Quest npc

Wipflash

Old School
Joined
Jul 27, 2010
Messages
1,101
Reaction score
87
Location
Sweden
Hello dear otlanders!
I'am requesting a npc script that is like a mission npc. An exampel :
U talk to Roger (starting npc) then he tells u if u wan't to accept this mission , then Roger says that u have to find Verronica in Main town! When u come to Verronica :

Verronica - Hello there, what could I do for u? do u wan't some infomamtion abut the lost ship? ,

Player - Yes

Verronica: Humm, my memory isn't the best, could u bring me a "bear" to refreash my memory?

Player - Yes ( He go and buy a beer)

Player : Hi,

Verronica: Hello there, do u have my beer?

Player - yes ,

Verronica - *Gluck* Oh thanks my friend, here you go (player receive a map) . Go on an contine with my adventure!

Then the player most go and find a chest in an underground cave (action id 9999) , and when he have found the chest, player have to go back to Roger and give him that item in the chest he received before , then Roger will give the player some exp and some item or money!

I hope someone could help me with this, becuse it one of the last thing i have to do on our project. :>
 
Don't bump anymore becouse I just made the script :D:

NPC:
.../data/npc/verronica.xml:

XML:
 <?xml version="1.0" encoding="UTF-8"?>
<npc name="Verronica" script="strangeQ.lua" walkinterval="2000" floorchange="0">
	<health now="150" max="150"/>
	<look type="136" head="132" body="79" legs="97" feet="132" corpse="2212"/>
	<parameters>
	<parameter key="message_greet" value="Hello |PLAYERNAME|, nice to see you. Do you want to follow my {adventure}?"/>
	</parameters>
</npc>

.../data/npc/scripts/strangeQ:
LUA:
 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 
function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 

local storage = 89899
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 

    if(msgcontains(msg, 'adventure')) then
		if getPlayerStorageValue(cid, storage) == -1 then
				selfSay('First go and make a beer, I need to fresh up my mind. Could you do that?', cid)
				setPlayerStorageValue(cid, storage, 5)
				talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 5) then 
                selfSay('You\'ve got my beer?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 2) then 
                selfSay('Okey, lets start. Here take my adventure map and follow it. You will find a chest and inside the chest you will find my legendary pickaxe. Could you bring it to me?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 3) then 
                selfSay('Go get my pickaxe!', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, endstorage) == 1) then 
                selfSay('Thanks alot, I can get to work again. I don\'t need any help anymore.', cid) 
                talkState[talkUser] = 1 
		elseif (getPlayerStorageValue(cid, storage) == 4) and doPlayerRemoveItem(cid, 4874, 1) then 
                selfSay('Oh my god! you did it, I can\'t believe it. Here are you reward!', cid) 
				doPlayerAddPercentLevel(cid, 4)
				setPlayerStorageValue(cid, endstorage, 1)
                talkState[talkUser] = 1 
        end
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and (getPlayerStorageValue(cid,storage) == 5)) then 
        if doPlayerRemoveItem(cid, 2015, 1) then 
            setPlayerStorageValue(cid,storage,2) 
            doPlayerAddPercentLevel(cid, 1)  
            selfSay('Thank you. Talk to me again to continue the quest.', cid) 
            talkState[talkUser] = 0 
        else 
            selfSay('Go and bring me the beer.', cid) 
        end 
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser]) == 1 then
		if(getPlayerStorageValue(cid,storage) == 2) then
            setPlayerStorageValue(cid,storage,3)
            selfSay('Good luck, and follow my map!', cid) 
            talkState[talkUser] = 0 
        else 
            return false
	end
end
        ------------------------------------------ 
	end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

Chest:
.../data/actions/actions.xml:

XML:
 	<action actionid="9999" event="script" value="legendarypickaxe.lua"/>

.../data/actions/scripts/legendarypickaxe.lua:
LUA:
 local storage = 4918411
local storage2 = 89899
local reward = 4874
local count = 1
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1740 or item.itemid == 1747 or item.itemid == 1748 or item.itemid == 1749 then
		if getPlayerStorageValue(cid, storage) == -1 then
			doPlayerAddItem(cid, reward, count)
			setPlayerStorageValue(cid, storage, 1)
			setPlayerStorageValue(cid, storage2, 4)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found a Legendary Pickaxe!") 
			return true
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
			return true
		end
	end
end

LIB:

.../lib/050-function: - Put this at the buttom of the file:

LUA:
 function doPlayerAddPercentLevel(cid, percent) 
    local player_lv, player_lv_1 = getExperienceForLevel(getPlayerLevel(cid)), getExperienceForLevel(getPlayerLevel(cid)+1) 
    local percent_lv = ((player_lv_1 - player_lv) / 100) * percent 
    doPlayerAddExperience(cid, percent_lv) 
end

Function made by Oskar1121

Rep if i helped :)
 
Last edited:
Thanks.. o.O but i need the Roger npc to. u start the quest/mission by talking to Roger, then he says that u have to go and talk to verronica ^^
 
When i read your request i took it like you meant that verronica was roger. I thought that you wrote down wrong name. But i still don't understand what verronica is doing and roger. Explain it again but more ditailed.
 
Okey. First u go to Roger ,

Player - Hi

Roger - Hello there brave "players name", would u like to do a mission for me?

Player - Mission/no

Roger - (misson)Very well, U have to go and look for Verronica in the forbidden city! I wish u my best luck!

Player - Bye

Roger - Farewell "players name"
__________________________
When u found Verronica:

Player - Hi

Verronica - Hello there, what could I do for u? do u wan't some infomamtion abut the Forbidden City?

Player - Information/no

Verronica: (information) Humm, my memory isn't the best, could u bring me a "bear(or anykinde of item)" to refreash my memory?

Player - Yes ( He go and buy a beer)

Player : Hi

Verronica: Hello there, do u have my beer?

Player - yes

Verronica - *Gluck* Oh thanks my friend, here you go (player receive a map) . Go on an contine with my adventure!

Then the player most go and find a chest in an underground cave (action id 9999) , and when he have found the chest and received a "Slingshoot(or what ever)", player have to go back to Roger and give him that item in the chest he received before , then Roger will give the player some exp and some item or money!

Last converse with Roger:

Player - Hi

Roger - Hello there , have u found that "item" in the forbidden city?

Player - Yes

Roger - oh thanks my friend (player received exp+some item).

Player - Bye

Roger - Farewell
_____________________

End of the story , i hope u get it.. :P
 
Sorry that It took alot of time. I was away from home long time. I just did these two NPCs in 20 min or something:

Tested and worked (y)

Verronica:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Verronica" script="verronica.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="136" head="20" body="39" legs="45" feet="7" addons="0"/>
	 <parameters>
  <parameter key="message_greet" value="Hello there, what could I do for you? Do you want some {infomamtion} about the Forbidden City?"/>
    </parameters>
</npc>
Script:
LUA:
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 
function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 

local storage = 89900
local storagerogerend = 89902
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 

    if(msgcontains(msg, 'information')) then
		if getPlayerStorageValue(cid, storage) == 1 then
				selfSay('Humm, my memory isn\'t the best, could you bring me a beer to refresh my memory?', cid)
				talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 4) then 
                selfSay('Thanks alot, you\'ve helped me and Roger enough.', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 3) then 
                selfSay('Bring the slingshot to Roger.', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 2) then 
                selfSay('You\'ve got my beer?', cid) 
                talkState[talkUser] = 1 
			else
				selfSay('Oh sorry, I am busy right now.', cid)
        end
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and getPlayerStorageValue(cid,storage) == 1) then 
			selfSay('Go and bring me the beer now.', cid) 
			setPlayerStorageValue(cid, storage,2)
            talkState[talkUser] = 0 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and getPlayerStorageValue(cid,storage) == 2 and doPlayerRemoveItem(cid, 2015, 1)) then 
            setPlayerStorageValue(cid,storagerogerend,3) 
            doPlayerAddPercentLevel(cid, 1)  
            selfSay('Thank you. Here take my map and try to find Rogers slingshot in the dungeon next to you.', cid) 
			setPlayerStorageValue(cid, storage, 3)
            talkState[talkUser] = 0 
		else
			selfSay('You don\'t have the beer with you...', cid)
        end 
        --------------------------------------- 
	end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

Roger:
XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Roger" script="roger.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="128" head="20" body="39" legs="45" feet="7" addons="0"/>
 <parameters>
  <parameter key="message_greet" value="Hello there brave |PLAYERNAME|, would you like to do a {mission} for me? "/>
    </parameters>
</npc>
Script:
LUA:
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 
function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 

local storage = 89902
local verronicastorage = 89900
local endstorage = 3918323
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 

    if(msgcontains(msg, 'mission')) then
		if getPlayerStorageValue(cid, storage) == -1 then
				selfSay('Very well, you have to go and look for Verronica in Forbidden City! I wish you my best luck!', cid)
				setPlayerStorageValue(cid, storage, 2)
				setPlayerStorageValue(cid, verronicastorage,1)
				talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 2) then 
                selfSay('I see that you\'ve got no information from Verronica... Go and find her and bring me the item.', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 3) then 
                selfSay('Hello there, I guess you\'ve found that "item" in Forbidden City?', cid) 
                talkState[talkUser] = 1 
        elseif (getPlayerStorageValue(cid, storage) == 4) then 
                selfSay('You\'ve helped me and Verronica enough. Thank you!', cid) 
                talkState[talkUser] = 1 
        end
        --------------------------------------- 
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and (getPlayerStorageValue(cid,storage) == 3)) then 
        if doPlayerRemoveItem(cid, 5907, 1) then 
			setPlayerStorageValue(cid, storage, 4)
            setPlayerStorageValue(cid, endstorage,1) 
            doPlayerAddPercentLevel(cid, 1)  
            selfSay('Oh thanks my friend, You\'ve complete the quest!', cid) 
			setPlayerStorageValue(cid, verronicastorage, 4)
            talkState[talkUser] = 0
		else
			selfSay('You don\'t have the item with you...', cid)
        end 
end
        ------------------------------------------ 
	end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())

Chest:
action.xml
XML:
	<action actionid="9999" event="script" value="slingshotroger.lua"/>
Script:
LUA:
local storage = 4918411
local reward = 5907
local count = 1
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == 1740 or item.itemid == 1747 or item.itemid == 1748 or item.itemid == 1749 then
		if getPlayerStorageValue(cid, storage) == -1 then
			doPlayerAddItem(cid, reward, count)
			setPlayerStorageValue(cid, storage, 1)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You found Rogers Slingshot!") 
			return true
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
			return true
		end
	end
end

LIB:

.../lib/050-function: - Put this at the buttom of the file:

LUA:
function doPlayerAddPercentLevel(cid, percent) 
    local player_lv, player_lv_1 = getExperienceForLevel(getPlayerLevel(cid)), getExperienceForLevel(getPlayerLevel(cid)+1) 
    local percent_lv = ((player_lv_1 - player_lv) / 100) * percent 
    doPlayerAddExperience(cid, percent_lv) 
end
Function made by Oskar1121

Rep if i helped ;)
 
Last edited:
I got this error when i try to import the npc.
5EC5vcBVro.png
 
i have this code inside the verronica.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Verronica" script="verronica.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="136" head="20" body="39" legs="45" feet="7" addons="0"/>
	 <parameters>
  <parameter key="message_greet" value="Hello there |PLAYERNAME|, what could I do for you? Do you want some {infomamtion} about the Forbidden City?"/>
    </parameters>
</npc
 
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Verronica" script="verronica.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="136" head="20" body="39" legs="45" feet="7" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hello there |PLAYERNAME|, what could I do for you? Do you want some {infomamtion} about the Forbidden City?"/>
</parameters>
</npc>


Witch rev are you using?
 
Back
Top