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

Npc help <needed> all look :d

Shake That Ass

I like to do something wi
Joined
Apr 8, 2010
Messages
171
Reaction score
3
Location
Poland/Rock Soid Mafia
NPC needs a quest to give a sample example: npc gives me money and he tells me to buy item, then when i buy for him this items and i give him it he give me exp and some cash or item... I NEED EXAMPLE
zostawcie_to

for a favor
 
Last edited:
I'm not sure if you mean this.

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

local cfg = {
	name = "Magic Sword", -- jak nazywa sie item ktory mamy mu dac
	id = 2400, -- id itemu ktory mamy mu dac
	money = 50000, -- ile kasy nam da
	storage = 6500, -- nie ruszaj xd
}

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

	if(msgcontains(msg, "mission")) then
		if(getPlayerStorageValue(cid, cfg.storage) == EMPTY_STORAGE) then
			selfSay("Do you want to do a favor for me?", cid)
			talkState[talkUser] = 1
		elseif(getPlayerStorageValue(cid, cfg.storage) == 1) then
			selfSay("Do you have an item for me?", cid)
			talkState[talkUser] = 2
		else
			selfSay("You already did this mission.", cid)
		end
		talkState[talkUser] = 1
	elseif(talkState[talkUser] == 1) then
		if(msgcontains(msg, "yes") then
			selfSay("Here's your cash, go and buy ".. cfg.name .. " for me!", cid)
			doPlayerAddMoney(cid, cfg.money)
			doPlayerSetStorageValue(cid, cfg.storage, 1)
		else
			selfSay("Okay...", cid)
			talkState[talkUser] = nil
		end
	elseif(talkState[talkUser] == 2) then
		if(msgcontains(msg, "yes")) then
			if(getPlayerItemCount(cid, cfg.id) >= 1) then
				doPlayerRemoveItem(cid, cfg.id, 1)
				doPlayerAddExperience(cid, cfg.exp)
				doPlayerSetStorageValue(cid, cfg.storage, 2)
			else
				selfSay("You don't have an item!", cid)
			end
		else
			selfSay("Okay...", cid)
			talkState[talkUser] = nil
		end
	end

	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
ow
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

local Topic = {}
local t = {
	id = 2563,
	storage = 9001,
	money = 15,
	rewardMoney = 5,
	rewardExp = 50
}

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 greetCallback(cid)
	Topic[cid] = 0
	return true
end

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	elseif msgcontains(msg, 'pan') or msgcontains(msg, 'mission') or msgcontains(msg, 'quest') then
		local v = getPlayerStorageValue(cid, storage)
		if v < 1 then
			selfSay('Do you want to do a favor for me?', cid)
			Topic[cid] = 1
		elseif v == 1 then
			selfSay('Have you brought me a ' .. getItemNameById(t.id) .. '?', cid)
			Topic[cid] = 2
		elseif v == 2 then
			selfSay('You\'ve already helped me.', cid)
		end
	elseif Topic[cid] == 1 then
		if msgcontains(msg, 'yes') then
			selfSay('Here\'s your money, I need you to buy a ' .. getItemNameById(t.id) .. ' for me!', cid)
			doPlayerAddMoney(cid, t.money)
			setPlayerStorageValue(cid, storage, 1)
		else
			selfSay('Maybe later.', cid)
		end
		Topic[cid] = 0
	elseif Topic[cid] == 2 then
		if msgcontains(msg, 'yes') then
			if doPlayerRemoveItem(cid, t.id, 1) then
				selfSay('Thank you, here is your reward!', cid)
				if t.rewardMoney then
					doPlayerAddMoney(cid, t.rewardMoney)
				end
				if t.rewardExp then
					doPlayerAddExp(cid, t.rewardExp)
					doSendAnimatedText(getThingPos(cid), t.rewardExp, COLOR_WHITE)
				end
				setPlayerStorageValue(cid, storage, 2)
			else
				selfSay('You don\'t have it!', cid)
			end
		else
			selfSay('Then what are you waiting for?', cid)
		end
		Topic[cid] = 0
	end
	return true
end

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