• 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 I Need Npc

ADDONS:

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 buyAddons(cid, message, keywords, parameters, node)
	if(not npcHandler:isFocused(cid)) then
		return false
	end

	local addon = parameters.addon
	local cost = parameters.cost

		if doPlayerRemoveMoney(cid, cost) == TRUE then
			doPlayerAddAddons(cid, addon)
			npcHandler:say('There, you are now able to use all addons!', cid)
		else
			npcHandler:say('Sorry, you do not have enough money.', cid)
		end

	keywordHandler:moveUp(1)
	return true
end

local node1 = keywordHandler:addKeyword({'first addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first addons set for 50000 gold coins?'})
	node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 50000})
	node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for 100000 gold coins?'})
	node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 100000})
	node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell the first addons set for 50000 gold coins and the second addons set for 100000 gold coins.'})

npcHandler:addModule(FocusModule:new())

And .xml!

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Addons" script="data/npc/scripts/addons.lua" walkinterval="111" floorchange="0">
	<health now="100" max="100"/>
	<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
</npc>
 
BLESSER:

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 creatureSayCallback(cid, type, msg)
	--- TODO: bless function in modules.lua
	if(npcHandler.focus ~= cid) then
		return FALSE
	end

	if msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
		npcHandler:say("I can provide you with five blessings... the 'first bless', 'second bless', 'third bless', 'fourth bless' and the 'fifth bless', they cost 10000 gold coins each.")
		talkState = 0
	elseif msgcontains(msg, 'first bless') then
		npcHandler:say("Do you want to buy the first blessing for 10000 gold?")
		talkState = 1
	elseif msgcontains(msg, 'second bless') then
		npcHandler:say("Do you want to buy the second blessing for 10000 gold?")
		talkState = 2
	elseif msgcontains(msg, 'third bless') then
		npcHandler:say("Do you want to buy the third blessing for 10000 gold?")
		talkState = 3
	elseif msgcontains(msg, 'fourth bless') then
		npcHandler:say("Do you want to buy the fourth blessing for 10000 gold?")
		talkState = 4
	elseif msgcontains(msg, 'fifth bless') then
		npcHandler:say("Do you want to buy the fifth blessing for 10000 gold?")
		talkState = 5
	elseif talkState > 0 then
		if msgcontains(msg, 'yes') then
			if getPlayerBlessing(cid, talkState) then
				npcHandler:say("A god has already blessed you with this blessing.")
			elseif isPremium(cid) == TRUE then
				if doPlayerRemoveMoney(cid, 10000) == TRUE then
					doPlayerAddBlessing(cid, talkState)
					npcHandler:say("You have been blessed by one of the five gods!")
				else
					npcHandler:say("You don't have enough money.")
				end
			else
				npcHandler:say("You need a premium account to buy blessings.")
			end
		elseif msgcontains(msg, 'no') then
			npcHandler:say("Then not.")
		end
		talkState = 0
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

And .xml!

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Blesser" script="data/npc/scripts/bless.lua" autowalk="0" speed="1" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="138" head="55" body="68" legs="96" feet="32" corpse="2212"/>
	<parameters>
	<parameter key="message_greet" value="Hello,  |PLAYERNAME|. I sell 'first', 'second', 'third', 'fourth' and 'fifth' bless for 10.000 gold coins each." />	
	</parameters>
</npc>
 
... on data\npc\scripts create 2 .lua files, named "addons" and "bless", open them with notepad and paste my addon & blesser codes into them.
Then go data\npc create 2 .xml files, named "addons" and "bless", paste my addon & blesser xml codes into them.

Done! xD
 
Bump... I need real system bless 8.42 ! 5 bless - each 20 k + increase lost equpiment
Chance to lost equipment:
Firs bless 30%
second bless 55%
third bless 75%
fourth bless -90%
fifth bless - you don't drop equpiment.

Please give me that script. I Give rep ++
 
BLESSER:

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 creatureSayCallback(cid, type, msg)
	--- TODO: bless function in modules.lua
	if(npcHandler.focus ~= cid) then
		return FALSE
	end

	if msgcontains(msg, 'blessing') or msgcontains(msg, 'blessings') or msgcontains(msg, 'help') or msgcontains(msg, 'offer') then
		npcHandler:say("I can provide you with five blessings... the 'first bless', 'second bless', 'third bless', 'fourth bless' and the 'fifth bless', they cost 20000 gold coins each.")
		talkState = 0
	elseif msgcontains(msg, 'first bless') then
		npcHandler:say("Do you want to buy the first blessing for 20000 gold?")
		talkState = 1
	elseif msgcontains(msg, 'second bless') then
		npcHandler:say("Do you want to buy the second blessing for 20000 gold?")
		talkState = 2
	elseif msgcontains(msg, 'third bless') then
		npcHandler:say("Do you want to buy the third blessing for 20000 gold?")
		talkState = 3
	elseif msgcontains(msg, 'fourth bless') then
		npcHandler:say("Do you want to buy the fourth blessing for 20000 gold?")
		talkState = 4
	elseif msgcontains(msg, 'fifth bless') then
		npcHandler:say("Do you want to buy the fifth blessing for 20000 gold?")
		talkState = 5
	elseif talkState > 0 then
		if msgcontains(msg, 'yes') then
			if getPlayerBlessing(cid, talkState) then
				npcHandler:say("A god has already blessed you with this blessing.")
			elseif isPremium(cid) == TRUE then
				if doPlayerRemoveMoney(cid, 20000) == TRUE then
					doPlayerAddBlessing(cid, talkState)
					npcHandler:say("You have been blessed by one of the five gods!")
				else
					npcHandler:say("You don't have enough money.")
				end
			else
				npcHandler:say("You need a premium account to buy blessings.")
			end
		elseif msgcontains(msg, 'no') then
			npcHandler:say("Then not.")
		end
		talkState = 0
	end
	return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

And .xml!

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Blesser" script="data/npc/scripts/bless.lua" autowalk="0" speed="1" floorchange="0" access="5" level="1" maglevel="1">
	<health now="150" max="150"/>
	<look type="138" head="55" body="68" legs="96" feet="32" corpse="2212"/>
	<parameters>
	<parameter key="message_greet" value="Hello,  |PLAYERNAME|. I sell 'first', 'second', 'third', 'fourth' and 'fifth' bless for 20.000 gold coins each." />	
	</parameters>
</npc>

last time i repeat.
 
Back
Top