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

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

local t = {}

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 think(cid)
	if math.random(400) == 1 then
		npcHandler:say('By the sons of fire! Best weapons in town!')
	end
	return true
end

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		if msgcontains(msg, 'hello') or msgcontains(msg, 'hi') then
			npcHandler:say('Hiho ' .. getCreatureName(cid) .. '! Wanna {weapon}, eh?', cid)
			npcHandler:addFocus(cid)
			t[cid] = nil
			return true
		else
			return false
		end
	end

	local n
	if t[cid] == 2 and msgcontains(msg, 'yes') then
		if getPlayerItemCount(cid, 5889) ~= 0 and doPlayerRemoveItem(cid, 2425, 1) then
			doPlayerRemoveItem(cid, 5889, 1)
			npcHandler:say('Here you have it.', cid)
			doPlayerAddItem(cid, 5908, 1)
		else
			npcHandler:say('No obsidian lance, no draconian steel.', cid)
		end
	elseif msgcontains(msg, 'thank') and msgcontains(msg, 'you') then
		npcHandler:say('Me enjoy doing that.', cid)
	elseif t[cid] == 1 and msgcontains(msg, 'yes') then
		npcHandler:say('Stop make fun of old dwarf, you not having it!', cid)
	elseif t[cid] == 1 and msgcontains(msg, 'no') then
		npcHandler:say('Me wouldn\'t sell it, too.', cid)
	elseif msgcontains(msg, 'obsidian') and msgcontains(msg, 'knife') then
		npcHandler:say('Me remembering... but long time since seeing such a knife. Maybe can make one from obsidian lance. But only if you paying one draconian steel. Cyclops friend maybe can refine.', cid)
	elseif msgcontains(msg, 'bye') or msgcontains(msg, 'farewell') then
		npcHandler:say('Guut bye. Coming back soon, ' .. getCreatureName(cid) .. '.', cid)
		npcHandler:releaseFocus(cid)
	elseif msgcontains(msg, 'job') or msgcontains(msg, 'shop') then
		npcHandler:say('Me a blacksmith is, an\' weapons me sell. You want buy weapons?', cid)
	elseif msgcontains(msg, 'name') then
		npcHandler:say('Me is Uzgod Hammerslammer, son of Fire from the Savage Axes.', cid)
	elseif msgcontains(msg, 'time') then
		local h, m, a = 0, getWorldTime()
		while m > 60 do
			h, m = h + 1, m - 60
		end
		if h > 0 and h < 13 then
			a = 'am'
		else
			a = 'pm'
		end
		npcHandler:say('Time is ' .. (h == 0 and 12 or h > 12 and h - 12 or h) .. ':' .. ('%02d'):format(m) .. ' ' .. a .. ' now.', cid)
	elseif msgcontains(msg, 'help') then
		npcHandler:say('You can buy the weapons me maked or sell weapons you have, jawoll.', cid)
	elseif msgcontains(msg, 'monster') then
		npcHandler:say('Me make often hunt on big nasties. Me small, but very big muscles me have, jawoll.', cid)
	elseif msgcontains(msg, 'dungeon') then
		npcHandler:say('We no dungeon need. We prison isle have.', cid)
	elseif msgcontains(msg, 'prison') then
		npcHandler:say('Bad ones locked up there. Never come out again there, jawoll.', cid)
	elseif msgcontains(msg, 'mines') then
		npcHandler:say('Me smashing rocks as me was little dwarf, jawoll.', cid)
	elseif msgcontains(msg, 'excalibug') then
		npcHandler:say('You want sell me excalibug for 1,000 platinum coins and an enchanted armor?', cid)
		n = 1
	elseif msgcontains(msg, 'thanks') then
		npcHandler:say('Me enjoy doing that.', cid)
	elseif t[cid] == 1 then
		npcHandler:say('You joke with me!', cid)
	elseif msgcontains(msg, 'offer') or msgcontains(msg, 'goods') or msgcontains(msg, 'ware') or msgcontains(msg, 'buy') or msgcontains(msg, 'sell') or msgcontains(msg,' equipment') or msgcontains(msg, 'stuff') then
		npcHandler:say('What you need? Me just the weapons sell. Let\'s {trade}.', cid)
	elseif msgcontains(msg, 'weapon') then
		npcHandler:say('See my weapons, light an\' heavy ones? Ask for {trade}.', cid)
	elseif msgcontains(msg, 'helmet') or msgcontains(msg, 'armor') or msgcontains(msg, 'shield') or msgcontains(msg, 'trousers') or msgcontains(msg, 'legs') then
		npcHandler:say('Me just sell {weapons}.', cid)
	elseif msgcontains(msg, 'draconia') then
		npcHandler:say('You bringing me draconian steel and obsidian lance in exchange for obsidian knife?', cid)
		n = 2
	elseif t[cid] == 2 then
		npcHandler:say('Stop make fun of old dwarf.', cid)
	end
	t[cid] = n or nil
	return true
end

npcHandler:setCallback(CALLBACK_ONTHINK, think)
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Guut bye. Coming back soon.')
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
 
Last edited:
Back
Top