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

Addon NPC for Forgotten Server

Lithium

Ex-TFS Developer
Joined
Jun 2, 2007
Messages
334
Reaction score
0
Hello people
I post here one script of Addon NPC for Forgotten Server


gogogo to script

Please update the NPC
Changelog
18/06/07 improvement of NPC using loop
18/06/07 Fixed minor bug and removed some blank lines
13/08/07 Remade by Jiddo
13/08/07 Added Support to Norseman Outfit and Changesex Command (Lithium)

Create a file named Varkhal.xml in data/npc/ and put inside it:
Code:
<?xml version="1.0"?>
<npc name="Varkhal" script="data/npc/scripts/addon.lua" autowalk="1" floorchange="0">
    <health now="100" max="100"/>
    <look type="134" head="78" body="88" legs="0" feet="88" addons="3" />
</npc>

Then create a file named addon.lua in data/npc/scripts/ and copy this into it:
PHP:
------------------------------------------------------------------------
---------------- Addon NPC for Forgotten Server ------------------------
---------------- Script by originally by Lithium -----------------------
---------------------- Remade by Jiddo ---------------------------------
------------------------------------------------------------------------
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)

-- OTServ event handling functions start
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
-- OTServ event handling functions end


function doPlayerGiveAddons(cid, addon)
        for x = 128, 134 do
            doPlayerAddOutfit(cid, x, addon)
        end
        for y = 143, 146 do
            doPlayerAddOutfit(cid, y, addon)
        end
        for z = 151, 154 do
            doPlayerAddOutfit(cid, z, addon)
        end
            doPlayerAddOutfit(cid, 251, addon)
        for x = 136, 142 do
            doPlayerAddOutfit(cid, x, addon)
        end
        for y = 147, 150 do
            doPlayerAddOutfit(cid, y, addon)
        end
        for z = 155, 158 do
            doPlayerAddOutfit(cid, z, addon)
        end
		    doPlayerAddOutfit(cid, 252, addon)
end

function confirmBuyAddons(cid, message, keywords, parameters, node)
    if(cid ~= npcHandler.focus) then
        return false
    end
    
    local addon = parameters.addon
    local cost = parameters.cost
    local premium = (parameters.premium ~= nil and parameters.premium ~= false)
    
    if(isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or premium == false) then
        if doPlayerRemoveMoney(cid, cost) then
            doPlayerGiveAddons(cid, addon)
            npcHandler:say('Here you go! Enjoy your addons.')
        else
            npcHandler:say('Sorry, you do not have enough money.')
        end
    else
        npcHandler:say('I only serve customers with premium accounts.')
    end
    keywordHandler:moveUp(1)
    return true
end


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

local nodeSecond = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the second addon for 10000 gold coins?.'})
    nodeSecond:addChildKeyword({'yes'}, confirmBuyAddons, {addon = 2, cost = 10000, premium = true})
    nodeSecond: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 addon for 5000 gold coins and the second one for 10000 gold coins.'})


npcHandler:addModule(FocusModule:new())

Credits: Original Lithium
Remade Jiddo

Coments Please ;)
 
Last edited:
Great work Lithium,make it give only 1 addon for each outfit a time.
 
Great code, using it for my server just edited =), oh and btw... It works without you having to pay the money too, that may be a dificult bug to fix... But when you do have the money, it takes it =)

Other then that excellent code.

~Kiwi Dan~
 
Not sure if this works with forgotten, but this is my citizen addon npc:

Code:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false

function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


function onCreatureDisappear(cid, pos)
  	if focus == cid then
          selfSay('Good bye then.')
          focus = 0
          talk_start = 0
  	end
end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
  	msg = string.lower(msg)

  	if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('Hello ' .. creatureGetName(cid) .. '! Please read my signs. Double check your items before you trade with me.')
  		focus = cid
  		talk_start = os.clock()

  	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')

	elseif focus == cid then
		talk_start = os.clock()

		if msgcontains(msg, 'first addon') then
			selfSay('Do you want to buy the first addon?')
			talk_state = 1

		elseif msgcontains(msg, 'second addon') then
			selfSay('Do you want to buy the second addon?')
			talk_state = 2	
		
		elseif talk_state == 1 then
			if msgcontains(msg, 'yes') then
					if doPlayerRemoveItem(cid, 5878, 100) == 1 then
						doPlayerAddAddon(cid, 128, 1)
						doPlayerAddAddon(cid, 136, 1)
				else
					selfSay('Sorry, you don't have the required items.')
				end
 			end
			talk_state = 0

		elseif talk_state == 2 then
			if msgcontains(msg, 'yes') then
					if doPlayerRemoveItem(cid, 5890, 100) == 1 and 	doPlayerRemoveItem(cid, 5902, 50) == 1 then
						doPlayerAddAddon(cid, 128, 2)
						doPlayerAddAddon(cid, 136, 2)
				else
					selfSay('Sorry, you don't have enough money.')
				end
 			end
			talk_state = 0
			
		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
			selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
			focus = 0
			talk_start = 0
		end
	end
end


function onCreatureChangeOutfit(creature)

end


function onThink()
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Next Please...')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
 	end
end

A bit buggy tho, if you don't have all the required items he'll still take the items that you have, and not give you the addon.
 
heh thx but i will wait untill someon make each addon to each outfit :p
 
Back
Top