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

Lua npc help

redguy

New Member
Joined
Mar 20, 2010
Messages
45
Reaction score
1
i need a npc that u can trade with items not coins
like when you say buy guardian shield
it says withdraws that amount of scarab coins or says sorry not enought scarab coins
 
uh, that's not one of the best scripts i posted though.
Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic= {}

local t = {
	['Deep Sea Fishing'] = {
		'The secret to Deep-Sea Fishing is to use the right kind of bait. I can sell you 100 special worms in exchange for 10 White Pearls. Interested?',
		{ {2143, 10} },
		{ {3976, 100} }
	},
	['Ice Fishing'] = {
		'The secret to Ice Fishing is to use the right kind of bait. I can sell you 100 Shrimp in exchange for 3 Ice Cubes. Interested?',
		{ {7441, 3} },
		{ {2670, 100} }
	},
	['Lava Fishing'] = {
		'The secret to Lava Fishing is to use the right kind of bait. I can sell you 100 Nails in exchange for 50 Talons. Interested?',
		{ {2151, 50} },
		{ {8309, 100} }
	},
}

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 evamsg = 'Here you are!!'
local noimsg = 'What are you trying to do? You don\'t have the appropriate items!'
local deny      = 'Not sure, eh? Okay.'
 
function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end

	for txt, v in pairs(t) do
		if msgcontains(msg, txt) then
			Topic[cid] = txt
			selfSay(v[1], cid)
			return true
		end
	end

	if Topic[cid] and Topic[cid] ~= '' then
		if msgcontains(msg, 'yes') then
			local v = t[Topic[cid]]
			for i = 1, #v[2] do
				if getPlayerItemCount(cid, v[2][i][1]) < v[2][i][2] then
					return selfSay(noimsg, cid)
				end
			end
			for i = 1, #v[2] do
				doPlayerRemoveItem(cid, v[2][i][1], v[2][i][2])
			end
			for i = 1, #v[3] do
				doPlayerAddItem(cid, v[3][i][1], v[3][i][2])
			end
			selfSay(evamsg, cid)
		else
			selfSay(deny, cid)
		end
		Topic[cid] = ''
	elseif msgcontains(msg, 'trade') then
		selfSay('I sell fish bait for (Deep-Sea Fishing), (Ice Fishing) and (Lava Fishing). What type of fishing do you plan on doing?', cid)
		Topic[cid] = ''
	elseif msgcontains(msg, 'help') then
		selfSay('To learn more about the different types of fishing speak with Fishing Guru, Marvin.', cid)
		Topic[cid] = ''
	end

	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
i got that workin, that script was for my vip npc who uses scarabs coin instead of gold
but my question is about reagular npc that buy and sell stuff in that little pop up trade window on the right
im useing crying damson for 8.54
idk if i edit the item and prices in the npc or the loot script that is my question i just need a quick tutorial
 
Back
Top