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

looking for a npc script

lalovega

New Member
Joined
Nov 4, 2008
Messages
85
Reaction score
1
im looking for a forging npc

example:
1 broad sword + 1 crimson sword = 1 crystal sword with a 50 % chance of succes if it fails, you will lose the 2 items

i will very appreciate if you help me with that script guys, ill be waiting for it.
thx:)
 
Based on npc who wants mpa from npc section and custom bank npc:
Lua:
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 answer = {}
 
function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false

	elseif (msgcontains(msg, 'crystal sword') or msgcontains(msg, 'broad sword') or msgcontains(msg, 'broadsword') or msgcontains(msg, 'crimson sword'))then
		if getPlayerItemCount(cid, 2413) > 0 and getPlayerItemCount(cid, 7385) > 0 then
		answer = 1
			selfSay("Did you brought both items I asked?",cid)
		else
			selfSay("You need a broad sword and crimson sword to this opearation.",cid)
		end
	elseif msgcontains(msg, 'yes') and answer == 1 then
		if getPlayerItemCount(cid, 2413) > 0 and getPlayerItemCount(cid, 7385) > 0 then
		local random = math.random(1,100)
		doPlayerTakeItem(cid, 2413, 1)
		doPlayerTakeItem(cid, 7385, 1)
		if random >= 50 then
		doPlayerAddItem(cid, 7449, 1)
		selfSay("Here you are.",cid)
		else
		selfSay("Melting ended up failure.",cid)
		end
		else
			selfSay("Come on, do not hide your stuff as a child.",cid)
		end
		answer = nil
	elseif msgcontains(msg, 'no') and answer == 1 then
		npcHandler:say('As you wish. Is there something else I can do for you?', cid)
		answer = nil
		
	return true
	end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Tested on 0.3.7 (7 crystals from 10 broads and 10 crimsons)
04:37 Test: Hello Zbizo, I am here to test melting crimson sword with broadsword.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Here you are.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Here you are.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Here you are.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Here you are.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Melting ended up failure.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Here you are.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Melting ended up failure.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Here you are.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Melting ended up failure.
04:38 Zbizo [400]: broadsword
04:38 Test: Did you brought both items I asked?
04:38 Zbizo [400]: yes
04:38 Test: Here you are.
 
Based on npc who wants mpa from npc section and custom bank npc:
Lua:
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 answer = {}
 
function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false

	elseif (msgcontains(msg, 'crystal sword') or msgcontains(msg, 'broad sword') or msgcontains(msg, 'broadsword') or msgcontains(msg, 'crimson sword'))then
		if getPlayerItemCount(cid, 2413) > 0 and getPlayerItemCount(cid, 7385) > 0 then
		answer = 1
			selfSay("Did you brought both items I asked?",cid)
		else
			selfSay("You need a broad sword and crimson sword to this opearation.",cid)
		end
	elseif msgcontains(msg, 'yes') and answer == 1 then
		if getPlayerItemCount(cid, 2413) > 0 and getPlayerItemCount(cid, 7385) > 0 then
		local random = math.random(1,100)
		doPlayerTakeItem(cid, 2413, 1)
		doPlayerTakeItem(cid, 7385, 1)
		if random >= 50 then
		doPlayerAddItem(cid, 7449, 1)
		selfSay("Here you are.",cid)
		else
		selfSay("Melting ended up failure.",cid)
		end
		else
			selfSay("Come on, do not hide your stuff as a child.",cid)
		end
		answer = nil
	elseif msgcontains(msg, 'no') and answer == 1 then
		npcHandler:say('As you wish. Is there something else I can do for you?', cid)
		answer = nil
		
	return true
	end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Tested on 0.3.7 (7 crystals from 10 broads and 10 crimsons)

OMG thxx it works perfect repp++
 
Back
Top