na poczatek tworzymy w data\npc\ plik Inwazjer i wpisujemy kod :
Kod:
<npc name="Inwazjer" script="data/npc/scripts/inwazje.lua" access="3" lookdir="2"> <mana now="800" max="800"/> <health now="200" max="200"/> <look type="129" head="0" body="94" legs="94" feet="114"/> </npc>
i potem w data\npc\scripts tworzymy plik inwazje
i kod :
Kod:
focus = 0 talk_start = 0 target = 0 following = false 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 ((string.find(msg, '(%a*)hi(%a*)')) and (focus == 0)) and getDistanceToCreature(cid) < 4 then selfSay('Hello ' .. creatureGetName(cid) .. '! Chcesz inwazji ?? kogo ...: Orc,Dwarf,Minotaur,Elf,Human,Dragon,GS,Demon,Orsh,Orshabaal.') focus = cid talk_start = os.clock() end
if msgcontains(msg, 'demon') and focus == cid then selfSay('/m demon') talk_start = os.clock() end
if msgcontains(msg, 'orshabaal') and focus == cid then selfSay('/m orshabaal') talk_start = os.clock() end
if msgcontains(msg, 'dwarf') and focus == cid then selfSay('/m dwarf') talk_start = os.clock() end
if msgcontains(msg, 'orc') and focus == cid then selfSay('/m inwazja orc') talk_start = os.clock() end
if msgcontains(msg, 'orsh') and focus == cid then selfSay('/m orsh') talk_start = os.clock() end
if msgcontains(msg, 'minotaur') and focus == cid then selfSay('/m minotaur') talk_start = os.clock() end
if msgcontains(msg, 'gs') and focus == cid then selfSay('/m giant spider') talk_start = os.clock() end
if msgcontains(msg, 'elf') and focus == cid then selfSay('/m elf') talk_start = os.clock() end
if msgcontains(msg, 'human') and focus == cid then selfSay('/m human') talk_start = os.clock() end
if msgcontains(msg, 'dragon') and focus == cid then selfSay('/m dragon') talk_start = os.clock() end
if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then selfSay('Good bye, ' .. creatureGetName(cid) .. '!') focus = 0 talk_start = 0 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
|