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

Tsson

New Member
Joined
Nov 4, 2007
Messages
76
Reaction score
0
Hello, can some one make a script like this

Npc says: Hello what can i do for you?

me says: Golden Helmet

Npc says: do you got two gold nuggets for me?

me says: yes

Npc says: Here, take it as a reward!

help plz :confused:
 
Here yo go!

PHP:
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 goldenNuggetID = 2157
local goldenHelmetID = 2471
local name = getPlayerName(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid		
						-----------------------------------------
		if msgcontains(msg, 'golden helmet') then
		if getPlayerItemCount(cid, goldenNuggetID) >= 2 then
	selfSay('You got 2 golden nuggets to exchange?', cid)
	talkState[talkUser] = 1
	else
	selfSay('You don\'t have a golden helmet!', cid)
	talkState[talkUser] = 0
	end
		elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		doPlayerRemoveItem(cid, goldenNuggetID, 2)
		doPlayerAddItem(cid, goldenHelmetID, 1)
	selfSay('Thank you ' .. name ..'', cid)
	elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
		talkState[talkUser] = 0
		selfSay('Ok then.', cid)
	end	
	-----------------------------------------

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

PD: I made this NPC so you can always trade 2 golden nuggets for a Golden helmet, the times you whant...
You whant me to edit that NPC and just make the exchange once pet character?
 
Last edited:
If is a quest, need getStorageValue and setStorageValue.

Here you go with Storages...

PHP:
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 goldenNuggetID = 2157
local storageValue = 16000
local goldenHelmetID = 2471
local name = getPlayerName(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid        
                        -----------------------------------------
        if msgcontains(msg, 'golden helmet') then
        if getPlayerItemCount(cid, goldenNuggetID) >= 2 then
		if getPlayerStorageValue(cid, storageValue) == -1 then
		setPlayerStorageValue(cid, storageValue, 1)
    selfSay('You got 2 golden nuggets to exchange?', cid)
    talkState[talkUser] = 1
	    else
    selfSay('You already made this quest', cid)
    talkState[talkUser] = 0
    end
    else
    selfSay('You don\'t have a golden helmet!', cid)
    talkState[talkUser] = 0
    end
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        doPlayerRemoveItem(cid, goldenNuggetID, 2)
        doPlayerAddItem(cid, goldenHelmetID, 1)
    selfSay('Thank you ' .. name ..'', cid)
    elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
        talkState[talkUser] = 0
        selfSay('Ok then.', cid)
    end    
    -----------------------------------------

return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top Bottom