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

Request Mission,npc,script!

Zorenia

Hoster of Zorenia
Joined
Jan 21, 2009
Messages
598
Reaction score
64
Location
The Netherlands
Hello,

I already looking for 3 days!!
I scripting real Questes into my ankrahmun, but I can´t finda perfect script thats like..

You speak to a npc...you get a mission...you get the Quest item..and trade it for a reward at npc.. I saw a lot of threads and scripts but didn´t find the good one..

I hope anyone can help me! so I can finish my scripting work!!!

THANKS IN ADVANCE!!!,

Rick!

I use client: 8.4

TFS: 0.3b3-gui
 
Code:
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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local storage = getPlayerStorageValue(cid,XXXX)

	if msgcontains(msg, 'mission') then
		if storage == -1 then
			selfSay('Your mission is to bring me {ABCD}. Are you able to do that?', cid)
			talkState[talkUser] = 1
		elseif storage == 1 then
			selfSay('I'm still waiting your {ABCD}. Did you bring it to me?', cid)
			talkState[talkUser] = 2
		else
			selfSay('You already made this mission!', cid)
			talkState[talkUser] = 0
		end

	elseif msgcontains(msg, 'yes') then
		if talkState[talkUser] == 1 then
			setPlayerStorageValue(cid,XXXX,1)
			selfSay('Alright. I will be waiting for the {ABCD}!', cid)
			talkState[talkUser] = 0
		end
		elseif talkState[talkUser] == 2 then
			if (doPlayerRemoveItem(cid,ABCD_ID,1) == TRUE) then
				doPlayerAddItem(cid,EFGH,1)
				setPlayerStorageValue(cid,XXXX,2)
				selfSay('Thank you for giving me the ABCD! Here, take your reward.', cid)
				talkState[talkUser] = 0
			else
				selfSay('Hey, I\'m not fool! You didn\'t got the {ABCD}!', cid)
				talkState[talkUser] = 0
			end
		end
	end
	return true
end

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

You must change the variables (ABCD, XXXX, EFGH) to anything you want. Also rewrite the texts, I made it fast.

Hm... It works like this: You say mission to the NPC, and then say "yes". So it will be given to you a storage XXXX with value 1. After that, you will be able to open a "magic door" (Just put the actionid XXXX on that door with a flashing red).
 
Well with a lot of script my npc don´t even spawmed because he can´t read the script :S but this script don't work really :S

errorerrorerrorkz8.jpg
 
Last edited:
Code:
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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    local storage = getPlayerStorageValue(cid,XXXX)

	if msgcontains(msg, 'mission') then
		if storage == -1 then
			selfSay('Your mission is to bring me {ABCD}. Are you able to do that?', cid)
			talkState[talkUser] = 1
		elseif storage == 1 then
			selfSay('I\'m still waiting your {ABCD}. Did you bring it to me?', cid)
			talkState[talkUser] = 2
		else
			selfSay('You already made this mission!', cid)
			talkState[talkUser] = 0
		end

	elseif msgcontains(msg, 'yes') then
		if talkState[talkUser] == 1 then
			setPlayerStorageValue(cid,XXXX,1)
			selfSay('Alright. I will be waiting for the {ABCD}!', cid)
			talkState[talkUser] = 0
		elseif talkState[talkUser] == 2 then
			if (doPlayerRemoveItem(cid, ABCD_ID, 1) == TRUE) then
				doPlayerAddItem(cid,EFGH,1)
				setPlayerStorageValue(cid,XXXX,2)
				selfSay('Thank you for giving me the ABCD! Here, take your reward.', cid)
				talkState[talkUser] = 0
			else
				selfSay('Hey, I\'m not fool! You didn\'t got the {ABCD}!', cid)
				talkState[talkUser] = 0
			end
		end
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
@Godely yes I did :S

@Rudolf.. I used ur script I filled it in like this way:

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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local storage = getPlayerStorageValue(cid,19001)

if msgcontains(msg, 'mission') then
if storage == -1 then
selfSay('Your mission is to bring me {Spike Sword}. Are you able to do that?', cid)
talkState[talkUser] = 1
elseif storage == 1 then
selfSay('I\'m still waiting your {Spike Sword}. Did you bring it to me?', cid)
talkState[talkUser] = 2
else
selfSay('You already made this mission!', cid)
talkState[talkUser] = 0
end

elseif msgcontains(msg, 'yes') then
if talkState[talkUser] == 1 then
setPlayerStorageValue(cid,19002,1)
selfSay('Alright. I will be waiting for the {Spike Sword}!', cid)
talkState[talkUser] = 0
elseif talkState[talkUser] == 2 then
if (doPlayerRemoveItem(cid, 2383_ID, 1) == TRUE) then
doPlayerAddItem(cid,2400,1)
setPlayerStorageValue(cid,19003,2)
selfSay('Thank you for giving me the ABCD! Here, take your reward.', cid)
talkState[talkUser] = 0
else
selfSay('Hey, I\'m not fool! You didn\'t got the {Spike Sword}!', cid)
talkState[talkUser] = 0
end
end
end
return true
end

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



But the npc don't even spawm at the server :S
Maybe I use the script wrong?? or I have a wrong npc.xml file :S
I hope anyone could help me so I can finish my project I really appreciate your help guys :)
 
Last edited:
First: Did you even create a normal XML file with the .lua file in scripts? like "script="data/npc/scripts/thenpc.lua"
Second: Please you could post the script you reedited here with [.code] THE SCRIPT [./code] without the .?
 
Last edited:
Hm... I was looking again, here is the problem:
Code:
			if (doPlayerRemoveItem(cid, 2383_ID, 1) == TRUE) then
				doPlayerAddItem(cid,2400,1)
				setPlayerStorageValue(cid,19003,2)
				selfSay('Thank you for giving me the ABCD! Here, take your reward.', cid)

Remove this _ID and change the ABCD. It would be like this:

Code:
			if (doPlayerRemoveItem(cid, 2383, 1) == TRUE) then
				doPlayerAddItem(cid,2400,1)
				setPlayerStorageValue(cid,19003,2)
				selfSay('Thank you for giving me the {spike sword}! Here, take your reward.', cid)
 
ROY.XML
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Roy" script="data/npc/scripts/stealfrom.lua" autowalk="1" floorchange="0">
<health now="100" max="100"/>
<look type="63" head="20" body="39" legs="45" feet="7" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. Hello I have a mission for you." />
</parameters>
</npc>

-----------------------------------------------------------------------

Script npc/scripts

stealfrom.xml

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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local storage = getPlayerStorageValue(cid,19001)

if msgcontains(msg, 'mission') then
if storage == -1 then
selfSay('Your mission is to bring me {Spike Sword}. Are you able to do that?', cid)
talkState[talkUser] = 1
elseif storage == 1 then
selfSay('I\'m still waiting your {Spike Sword}. Did you bring it to me?', cid)
talkState[talkUser] = 2
else
selfSay('You already made this mission!', cid)
talkState[talkUser] = 0
end

elseif msgcontains(msg, 'yes') then
if talkState[talkUser] == 1 then
setPlayerStorageValue(cid,19002,1)
selfSay('Alright. I will be waiting for the {Spike Sword}!', cid)
talkState[talkUser] = 0

if (doPlayerRemoveItem(cid, 2383, 1) == TRUE) then
doPlayerAddItem(cid,2400,1)
setPlayerStorageValue(cid,19003,2)
selfSay('Thank you for giving me the {spike sword}! Here, take your reward.', cid)
talkState[talkUser] = 0
else
selfSay('Hey, I\'m not fool! You didn\'t got the {Spike Sword}!', cid)
talkState[talkUser] = 0
end
end
end
return true
end
 
ROY.XML
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Roy" script="data/npc/scripts/stealfrom.lua" autowalk="1" floorchange="0">
<health now="100" max="100"/>
<look type="63" head="20" body="39" legs="45" feet="7" addons="0"/>
<parameters>
<parameter key="message_greet" value="Hello |PLAYERNAME|. Hello I have a mission for you." />
</parameters>
</npc>

-----------------------------------------------------------------------

Script npc/scripts

stealfrom.xml

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 talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local storage = getPlayerStorageValue(cid,19001)

if msgcontains(msg, 'mission') then
if storage == -1 then
selfSay('Your mission is to bring me {Spike Sword}. Are you able to do that?', cid)
talkState[talkUser] = 1
elseif storage == 1 then
selfSay('I\'m still waiting your {Spike Sword}. Did you bring it to me?', cid)
talkState[talkUser] = 2
else
selfSay('You already made this mission!', cid)
talkState[talkUser] = 0
end

elseif msgcontains(msg, 'yes') then
if talkState[talkUser] == 1 then
setPlayerStorageValue(cid,19002,1)
selfSay('Alright. I will be waiting for the {Spike Sword}!', cid)
talkState[talkUser] = 0

if (doPlayerRemoveItem(cid, 2383, 1) == TRUE) then
doPlayerAddItem(cid,2400,1)
setPlayerStorageValue(cid,19003,2)
selfSay('Thank you for giving me the {spike sword}! Here, take your reward.', cid)
talkState[talkUser] = 0
else
selfSay('Hey, I\'m not fool! You didn\'t got the {Spike Sword}!', cid)
talkState[talkUser] = 0
end
end
end
return true
end

Look that thing in bold. You named it "stealfrom.xml", but it's "stealfrom.lua" :P
 
WITH THIS SCRIPT HE ANSWERING! so maybe we can use some lines or examples from this script?



-- WAS NOT Made by Coltain13 // Coltain, I only made it work for TFS --


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

-- OTServ event handling functions start
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
-- OTServ event handling functions end

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

player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
playerCap = getPlayerFreeCap(cid)
item = 8293 --Hallowed Axe
itemweight = getItemWeight(item, 1)

if msgcontains(msg, 'hallowed axe') then
if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
npcHandler:say('Do you want to buy a Hallowed Axe from me?', cid)
talk_state = 1
else
npcHandler:say('You have to bring me an axe and 1000 gp first.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
if doPlayerTakeItem(cid,2386,1) == 1 and pay(cid,3500000) and playerCap >= itemweight then
npcHandler:say('Here you are. You can now defeat the demon oak with this axe.', cid)
doPlayerAddItem(cid,item,1)
talk_state = 0
else
npcHandler:say('The Hallowed Axe is too heavy for you. Make sure that you have enough capacity.', cid)
talk_state = 0
end
else
npcHandler:say('Please bring with you an axe and enough with money.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'demon oak') then
if getPlayerItemCount(cid,2386) >= 1 and player_money >= 3500000 then
npcHandler:say('Did you defeat the demon oak?', cid)
talk_state = 2
else
npcHandler:say('Go defeat the demon oak.', cid)
talk_state = 0
end
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerStorageValue(cid,21545) == 1 then
npcHandler:say('Good job!', cid)
setPlayerStorageValue(cid,21545,2)
end
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 1) then
npcHandler:say('Ok thanks.', cid)
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())
 
Back
Top