Ir para conteúdo

Npc De Addon 2.0 Para Forgotten Server


Malukete

Posts Recomendados

Estava passando pelo fórum e olhei o NPC de addons feito pelo Lithium para as versões do Forgotten Server e então decidi fazer um sistema que algumas pessoas devem se interessar.

Vc pede first citizen addon e vc compra somente ele e etc.

Vc também pode modificar ao invés de ser compra, ser por itens igual ao tibia global, mas fiz por dinheiro e fiz somente os exemplos de citizen e hunter.

 

Vamos lá, mãos a obra. Primeiramente precisamos do sistema If Pay porquê o addon tava de graça. Abra na pasta data/npc/lib o npc.lua e adcione em qualquer parte:

 

function pay(cid, cost)

if doPlayerRemoveMoney(cid, cost) == 1 then

return true

else

return false

end

end

 

Agora vamos a melhor parte. Ainda mesmo no npc.lua adcione esse sistema feita por mim

----------- Each Addons System By Malukete -----------

function citizenaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 128, 128 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 136, 136 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function hunteraddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 129, 129 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 137, 137 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function mageaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 130, 130 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 141, 141 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function knightaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 131, 131 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 139, 139 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function nobleaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 132, 132 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 140, 140 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function summoneraddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 133, 133 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 138, 138 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function warrioraddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 134, 134 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 142, 142 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function barbarianaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 143, 143 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 147, 147 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function druidaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 144, 144 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 148, 148 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function wizardaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 145, 145 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 149, 149 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function orientaladdon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 146, 146 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 150, 150 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function pirateaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 151, 151 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 155, 155 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function assassinaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 152, 152 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 156, 156 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function beggaraddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 153, 153 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 157, 157 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function shamanaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 154, 154 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 158, 158 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

function norseaddon(cid, addon)

if getPlayerSex(cid) == 1 then

for x = 251, 251 do

doPlayerAddOutfit(cid, x, addon)

end

 

else

for x = 252, 252 do

doPlayerAddOutfit(cid, x, addon)

end

end

end

----------- Each Addons System By Malukete -----------

 

Agora vc já possui o sistema, então vamos usar. Mude o arquivo Varkhal.xml para isso:

<?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" />

<parameters>

<parameter key="message_greet" value="Hello |PLAYERNAME|. I sell addons for each outfit. Example first citizen addon." />

</parameters>

</npc>

Agora seu npc já explica como comprar na hora de comprimentá-lo. Vamos ao script agora. Mude o addon.lua para isso:

------------------------------------------------------------------------

------------- Addon NPC for Forgotten Server ---------------

---------------------- Script by Lithium --------------------------

---------------------- Edited by Malukete --------------------------

------------------------------------------------------------------------

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 creatureSayCallback(cid, type, msg)

-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.

if(npcHandler.focus ~= cid) then

return false

end

 

if msgcontains(msg, 'addons') or msgcontains(msg, 'addoner') or msgcontains(msg, 'addon') then

selfSay('I sell the first addon of each outfit for 5000 gold and the second addon of each outfit for 10000 gold, just say the addon and outfit.')

elseif getPlayerPremiumDays(cid) > 0 then

if msgcontains(msg, 'first citizen') then

selfSay('Do you want to buy the first citizen addon for 5000 gold?')

talk_state = 1

elseif msgcontains(msg, 'second citizen') then

selfSay('Do you want to buy the second citizen addon for 10000 gold?')

talk_state = 2

elseif msgcontains(msg, 'first hunter') then

selfSay('Do you want to buy the first hunter addon for 5000 gold?')

talk_state = 3

elseif msgcontains(msg, 'second hunter') then

selfSay('Do you want to buy the second hunter addon for 10000 gold?')

talk_state = 4

 

elseif talk_state == 1 then

if msgcontains(msg, 'yes') then

if pay(cid,5000) then

citizenaddon(cid, 1)

selfSay('Now you can use this acessory.')

else

selfSay('Sorry, you don\'t have enough money.')

end

end

talk_state = 0

elseif talk_state == 2 then

if msgcontains(msg, 'yes') then

if pay(cid,10000) then

citizenaddon(cid, 2)

selfSay('Now you can use this acessory.')

else

selfSay('Sorry, you don\'t have enough money.')

end

end

talk_state = 0

elseif talk_state == 3 then

if msgcontains(msg, 'yes') then

if pay(cid,5000) then

hunteraddon(cid, 1)

selfSay('Now you can use this acessory.')

else

selfSay('Sorry, you don\'t have enough money.')

end

end

talk_state = 0

elseif talk_state == 4 then

if msgcontains(msg, 'yes') then

if pay(cid,10000) then

hunteraddon(cid, 2)

selfSay('Now you can use this acessory.')

else

selfSay('Sorry, you don\'t have enough money.')

end

end

talk_state = 0

 

elseif msgcontains(msg, 'bye') then

selfSay('Good bye!')

 

talk_state = 0

end

else

selfSay('You need a premium account to buy \'addons\', there\'s nothing else you can do here..')

end

return TRUE

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

Pronto agora é so falar first citizen, second citizen, first hunter e second hunter.

Vc também pode adcionar os outros ai, pois meu sistema suporta todos os tipos de outfits, inclusive o norseman.

Exemplo:

mageaddon(cid, qualaddon)

knightaddon(cid, qualaddon)

nobleaddon(cid, qualaddon)

summoneraddon(cid, qualaddon)

warrioraddon(cid, qualaddon)

barbarianaddon(cid, qualaddon)

druidaddon(cid, qualaddon)

wizardaddon(cid, qualaddon)

orientaladdon(cid, qualaddon)

pirateaddon(cid, qualaddon)

assassinaddon(cid, qualaddon)

beggaraddon(cid, qualaddon)

shamanaddon(cid, qualaddon)

norseaddon(cid, qualaddon)

 

Apenas isso, espero que gostem, comentem plx

Créditos:

50% Lithium Por Fazer o Script

50% Malukete Por Editar e Criar Esse Sistema

 

Editado por Malukete
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...