Hello,
I was wondering if some people could help me. There is a lot of addon NPC's released on the forums, and I want to make seperate NPC's for each set of addons. I have looked at some released NPC's and have altered the script so it only does 1 outfit. For my first one I have justed used Varkhal.
I have put this in the Varkhal XML document
I have then created a new LUA document in NPC > Scripts, and have put this
I got it so the NPC would say "I can offer you feather hat or backpack", but when I tried to say first addon to lead onto me giving the items for it, he said nothing. But now when I try to import it to map editor it just says "Invalid format?"
If anyone could help I'd very much appreciate it, and also any explainations helping me to understand would be wonderful, once I understand one, I will be able to in theory do some more NPC's without so many problems!
Crunch~
I was wondering if some people could help me. There is a lot of addon NPC's released on the forums, and I want to make seperate NPC's for each set of addons. I have looked at some released NPC's and have altered the script so it only does 1 outfit. For my first one I have justed used Varkhal.
I have put this in the Varkhal XML document
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Varkhal" script="data/npc/scripts/addon.lua" access="5" lookdir="2" autowalk="25">
<mana now="800" max="800" />
<health now="200" max="200" />
<look type="134" head="78" body="88" legs="0" feet="88" addons="3" />
<parameters>
<parameter key="message_greet" value="Greetings |PLAYERNAME|. Will you help me? If you do, I'll reward you with nice addons! Just say 'addons' or 'help' if you don't know what to do." />
<parameter key="module_keywords" value="18" />
<parameter key="keyword_reply3" value="The addons I'm currently offering for the Citizen outfit are 'feather hat' and 'backpack' for males and females." />
</npc>
I have then created a new LUA document in NPC > Scripts, and have put this
Code:
-- 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
addon_need_premium = 'Sorry, you need a premium account to get addons.'
addon_have_already = 'Sorry, you already have this addon.'
addon_have_not_items = 'Sorry, you don\'t have these items.'
addon_give = 'Here you are.'
player_gold = getPlayerItemCount(cid,2148)
player_plat = getPlayerItemCount(cid,2152)*100
player_crys = getPlayerItemCount(cid,2160)*10000
player_money = player_gold + player_plat + player_crys
if msgcontains(msg, 'addons') then
selfSay('I can give you Citizen addons.')
elseif msgcontains(msg, 'help') then
selfSay('To buy the first addon say \'first NAME addon\', for the second addon say \'second NAME addon\'.')
------------------------------------------------ addon ------------------------------------------------
elseif msgcontains(msg, 'first citizen addon') then
if isPremium(cid) then
if getPlayerItemCount(cid,5878) >= 100 then
selfSay('Did you bring me 100 minotaur leathers?')
talk_state = 1
else
selfSay('I need 100 minotaur leather, to give you the first citizen addon. Come back when you have them.')
talk_state = 0
end
else
selfSay(addon_need_premium)
talk_state = 0
end
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 1 then
talk_state = 0
if getPlayerItemCount(cid,5878) >= 100 then
addon = getPlayerStorageValue(cid,10001)
if addon == -1 then
if doPlayerTakeItem(cid,5878,100) == 0 then
selfSay(addon_give)
doPlayerAddOutfit(cid, 128, 1)
doPlayerAddOutfit(cid, 136, 1)
setPlayerStorageValue(cid,10001,1)
end
else
selfSay(addon_have_already)
end
else
selfSay(addon_have_not_items)
end
------------------------------------------------ addon ------------------------------------------------
elseif msgcontains(msg, 'second citizen addon') then
if isPremium(cid) then
if getPlayerItemCount(cid,5890) >= 100 and getPlayerItemCount(cid,5902) >= 50 and getPlayerItemCount(cid,2480) >= 1 then
selfSay('Did you bring me 100 chicken feathers, 50 honeycombs and the legion helmet?')
talk_state = 2
else
selfSay('I need 100 chicken feathers, 50 honeycombs and a legion helmet, to give you the second citizen addon. Come back when you have them.')
talk_state = 0
end
else
selfSay(addon_need_premium)
talk_state = 0
end
------------------------------------------------ confirm yes ------------------------------------------------
elseif msgcontains(msg, 'yes') and talk_state == 2 then
talk_state = 0
if getPlayerItemCount(cid,5890) >= 100 and getPlayerItemCount(cid,5902) >= 50 and getPlayerItemCount(cid,2480) >= 1 then
addon = getPlayerStorageValue(cid,10002)
if addon == -1 then
if doPlayerTakeItem(cid,5890,100) == 0 and doPlayerTakeItem(cid,5902,50) == 0 and doPlayerTakeItem(cid,2480,1) == 0 then
selfSay(addon_give)
doPlayerAddOutfit(cid, 128, 2)
doPlayerAddOutfit(cid, 136, 2)
setPlayerStorageValue(cid,10002,1)
end
else
selfSay(addon_have_already)
end
else
selfSay(addon_have_not_items)
end
------------------------------------------------ confirm no ------------------------------------------------
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 34) then
selfSay('Ok than.')
talk_state = 0
end
-- 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.
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
I got it so the NPC would say "I can offer you feather hat or backpack", but when I tried to say first addon to lead onto me giving the items for it, he said nothing. But now when I try to import it to map editor it just says "Invalid format?"
If anyone could help I'd very much appreciate it, and also any explainations helping me to understand would be wonderful, once I understand one, I will be able to in theory do some more NPC's without so many problems!
Crunch~