• 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 sells hp and mana

DestinationSer

@echo off
Joined
Mar 7, 2009
Messages
2,806
Solutions
1
Reaction score
676
I want a NPC that sells 1 million hp or mana for 1 item type of 2159 =ID.
Answer as soon as possible :)
 
-- Credits To: Ruggedmage.

function onUse(cid, item, fromPosition, itemEx, toPosition)
if doPlayerRemoveItem(cid, 2159) then
return setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+1000000)
end
return doPlayerSendCancel(cid, "You don't have this item.")
end

This should work when you use the item, it will add 1million hp and below will add 1million mp on use

-- Credits To: Ruggedmage.

function onUse(cid, item, fromPosition, itemEx, toPosition)
if doPlayerRemoveItem(cid, 2159) then
return setCreatureMaxMana(cid, getCreatureMaxMana(cid)+1000000)
end
return doPlayerSendCancel(cid, "You don't have this item.")
end
 
I meen like a NPC not a Item.
Player: Hi
Npc: Hi playername, Do you wanna buy some 'Health' or 'Mana'? I can sell you a great amount
Player: Health
Npc: Ok, i can add you '1 million health' Is that ok?
Player: 1 million health
Npc: Im sorry, you dont have the required item
If player have the item
Npc: 1 million health have been added to your character! :)
 
Should Work, Not Tested:

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
 
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 buyMana(cid, message, keywords, parameters, node)
		if doPlayerRemoveItem(cid, 2159, 1) then
		setCreatureMaxMana(cid, getCreatureMaxMana(cid)+1000000)
		npcHandler:say("Thank you.", cid)
		npcHandler:releaseFocus(cid)
	else
		npcHandler:say("You don't have items required yet...", cid)
		npcHandler:releaseFocus(cid)
	end
	return true
end
 
function buyHealth(cid, message, keywords, parameters, node)
		if doPlayerRemoveItem(cid, 2159, 1) then
		setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+1000000)
		npcHandler:say("Thank you.", cid)
		npcHandler:releaseFocus(cid)
	else
		npcHandler:say("You don't have items required yet..", cid)
		npcHandler:releaseFocus(cid)
	end
	return true
end
 
local node1 = keywordHandler:addKeyword({'mana'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you want to buy 1000000 mana for xxxx?"})
	node1:addChildKeyword({'yes'}, buyMana, {npcHandler = npcHandler, onlyFocus = true, reset = true})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
 
local node2 = keywordHandler:addKeyword({'health'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you want to buy 1000000 health for xxxx?"})
	node2:addChildKeyword({'yes'}, buyMana, {npcHandler = npcHandler, onlyFocus = true, reset = true})
	node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Ok then.', reset = true})
 
npcHandler:addModule(FocusModule:new())

Replace the "xxxx"'s with the item name.
 
Back
Top