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

Upgrader Npc

Tobbz

New Member
Joined
Jan 7, 2008
Messages
35
Reaction score
3
Location
Sweden
Hello i found a npc script before, is works good. But i need to make it possible to upgrade one more item and wounder is any one can help me? :)

removeitem1 = 2308, --VIP SD
removeitem2 = 9636, --VIP SD Updrage
prizeitem = 2284 --Ultimate SD

Lua:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
local Topic = {}
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 otswe = {
removeitem1 = 2267, --Survival Rune
removeitem2 = 11198, --Upgrader
prizeitem = 2265  --Ultimate Survival Rune
}
function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
 
	if msgcontains(msg, 'help') or msgcontains(msg, 'survival rune') or msgcontains(msg, 'upgrade') then
			npcHandler:say('Hello i can upgrade your Survival Rune.', cid)
			npcHandler:say('Do you want to upgrade? {yes}.', cid)
			elseif(msgcontains(msg, 'yes')) then
			if doPlayerRemoveItem(cid, otswe.removeitem1, 1) and doPlayerRemoveItem(cid, otswe.removeitem2, 1) then
				npcHandler:say('Thank you!', cid)
				doPlayerAddItem(cid,otswe.prizeitem,1)
				focus = 0
			else
				npcHandler:say('Are you kidding me ? I dont see any survival upgrader or survival rune with you! You didn\'t get them! Grrr... come back when you\'ve got them.', cid)
		end
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


REP! ++
 
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 config = {
	["survival rune"] = {removeitems = {2267, 11198}, prizeitem = 2265},
	["vip sd"] = {removeitems = {2308, 9636}, prizeitem = 2284}
}

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local x = config[msg:lower()]

	if msgcontains(msg, "help") or msgcontains(msg, "upgrade") then
		selfSay("Which item do you want to upgrade?", cid)
		talkState[talkUser] = 1
	elseif x and talkState[talkUser] == 1 then
		local info1, info2 = getItemInfo(x.removeitems[1]), getItemInfo(x.removeitems[2])
		selfSay("Upgrading "..info1.article.." "..msg.." will cost you the "..info1.name.." and "..info2.article.." "..info2.name..", are you sure?", cid)
		xmsg = msg
		talkState[talkUser] = 2
	elseif(msgcontains(msg, "yes") and talkState[talkUser] == 2) then
		x = config[xmsg:lower()]
		if doPlayerRemoveItem(cid, x.removeitems[1], 1) and doPlayerRemoveItem(cid, x.removeitems[2], 1) then
			selfSay("Thank you!", cid)
			doPlayerAddItem(cid, x.prizeitem, 1)
		else
			local info1, info2 = getItemInfo(x.removeitems[1]), getItemInfo(x.removeitems[2])
			selfSay("Are you kidding me? You need "..info2.article.." "..info2.name.." and the "..info1.name..".", cid)
		end
		talkState[talkUser] = 0
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
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 config = {
	["survival rune"] = {removeitems = {2267, 11198}, prizeitem = 2265},
	["vip sd"] = {removeitems = {2308, 9636}, prizeitem = 2284}
}

function creatureSayCallback(cid, type, msg)
	if not npcHandler:isFocused(cid) then
		return false
	end
 
	local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
	local x = config[msg:lower()]

	if msgcontains(msg, "help") or msgcontains(msg, "upgrade") then
		selfSay("Which item do you want to upgrade?", cid)
		talkState[talkUser] = 1
	elseif x and talkState[talkUser] == 1 then
		local info1, info2 = getItemInfo(x.removeitems[1]), getItemInfo(x.removeitems[2])
		selfSay("Upgrading "..info1.article.." "..msg.." will cost you the "..info1.name.." and "..info2.article.." "..info2.name..", are you sure?", cid)
		xmsg = msg
		talkState[talkUser] = 2
	elseif(msgcontains(msg, "yes") and talkState[talkUser] == 2) then
		x = config[xmsg:lower()]
		if doPlayerRemoveItem(cid, x.removeitems[1], 1) and doPlayerRemoveItem(cid, x.removeitems[2], 1) then
			selfSay("Thank you!", cid)
			doPlayerAddItem(cid, x.prizeitem, 1)
		else
			local info1, info2 = getItemInfo(x.removeitems[1]), getItemInfo(x.removeitems[2])
			selfSay("Are you kidding me? You need "..info2.article.." "..info2.name.." and the "..info1.name..".", cid)
		end
		talkState[talkUser] = 0
	end
	return true
end
 
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Exact what i mean! thanks alot Limos! REP!++ :)
 
Back
Top