Wchodzimy w NPC/scripts utwarzamy notatnik , a w nim wpisujemy:
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 bless1 = getPlayerBlessing(cid,1) bless2 = getPlayerBlessing(cid,2) bless3 = getPlayerBlessing(cid,3) bless4 = getPlayerBlessing(cid,4) bless5 = getPlayerBlessing(cid,5) tbless = 'Sorry, but you already have this blessing.' pbless = 'Sorry, you need a premium account to buy blessings.' obless = 'Do you have 10000 gold coins to buy this blessing?' mbless = 'Sorry, but you need 10000 gold coins to buy this blessing.' gbless = 'Now the Gods blessed you.' 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, 'blessing') or msgcontains(msg, 'blessings') then selfSay('I can give you 5 blessing, and each blessing cost 10000 gold coins. Just say help to know how to buy.') elseif msgcontains(msg, 'help') or msgcontains(msg, 'ajuda') then selfSay('To buy the blessings say, first bless, second bless, third bless, fouth bless and fifth bless.') elseif msgcontains(msg, 'first bless') then if isPremium(cid) then if player_money >= 10000 then selfSay(obless) talk_state = 1 else selfSay(mbless) talk_state = 0 end else selfSay(pbless) talk_state = 0 end elseif msgcontains(msg, 'second bless') then if isPremium(cid) then if player_money >= 10000 then selfSay(obless) talk_state = 2 else selfSay(mbless) talk_state = 0 end else selfSay(pbless) talk_state = 0 end elseif msgcontains(msg, 'third bless') then if isPremium(cid) then if player_money >= 10000 then selfSay(obless) talk_state = 3 else selfSay(mbless) talk_state = 0 end else selfSay(pbless) talk_state = 0 end elseif msgcontains(msg, 'fourth bless') then if isPremium(cid) then if player_money >= 10000 then selfSay(obless) talk_state = 4 else selfSay(mbless) talk_state = 0 end else selfSay(pbless) talk_state = 0 end elseif msgcontains(msg, 'fifth bless') then if isPremium(cid) then if player_money >= 10000 then selfSay(obless) talk_state = 5 else selfSay(mbless) talk_state = 0 end else selfSay(pbless) talk_state = 0 end ------------------------------ Confirm yes --------------------------------- elseif msgcontains(msg, 'yes') and talk_state == 1 then talk_state = 0 if bless1 then selfSay(tbless) else if pay(cid,10000) then doPlayerAddBlessing(cid, 1) selfSay(gbless) else selfSay(mbless) end end elseif msgcontains(msg, 'yes') and talk_state == 2 then talk_state = 0 if bless2 then selfSay(tbless) else if pay(cid,10000) then doPlayerAddBlessing(cid, 2) selfSay(gbless) else selfSay(mbless) end end elseif msgcontains(msg, 'yes') and talk_state == 3 then talk_state = 0 if bless3 then selfSay(tbless) else if pay(cid,10000) then doPlayerAddBlessing(cid, 3) selfSay(gbless) else selfSay(mbless) end end elseif msgcontains(msg, 'yes') and talk_state == 4 then talk_state = 0 if bless4 then selfSay(tbless) else if pay(cid,10000) then doPlayerAddBlessing(cid, 4) selfSay(gbless) else selfSay(mbless) end end elseif msgcontains(msg, 'yes') and talk_state == 5 then talk_state = 0 if bless5 then selfSay(tbless) else if pay(cid,10000) then doPlayerAddBlessing(cid, 5) selfSay(gbless) else selfSay(mbless) end end ------------------------------------------------ confirm no ------------------------------------------------ elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) 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())
Zapisujemy jako: bless.lua
W data/npc utwarzamy notatnik , a w nim wpisujemy:
<?xml version="1.0"?> <npc name="Waterlow" script="data/npc/scripts/bless.lua" access="3" lookdir="2"> <mana now="800" max="800"/> <health now="200" max="200"/> <look type="139" head="132" body="79" legs="97" feet="132"/> </npc>
Zapisujemy jako: Waterlow.xml
Oczywiście musimy ustawić naszego Npc więc wchodzimy w data/world/npc.xml
Edytujemy plik Npc.xml
i dodajemy pod: <npclist>
<npc name="Waterlow" x="xxx" y="xxx" z="x" dir="2"/>
Niebieski = Położenie Waterlowa - gdzie Waterlow ma się znajdować
|