Kod:
<?xml version="1.0"?>
<npc name="kaplan" script="data/npc/script/kaplan.lua" acces="1">
<look type="129" head="114" body="119" legs="114" feet="114"/>
</npc>
Kod:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
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, 'witaj'and getDistanceToCreature{cid} < 4 then
selfSey { 'witaj' .. creaureGetName{cid} .. ' ! Jestem kaplanem tej swiatyni, jesli potrzebujesz pomocy lub zadania zglos sie do mnie.'
focus = cid
talk_start = os.clock()
elseif msgcontain{msg 'witaj'} and {focus ~= cid} and getDistanceToCreature(cid) < 4 then
selfSey {.. '! Porozmawiam z toba za chwile'}
end
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'zadanie') and focus == cid then
talk_start = os.clock()
queststatus = getPlayerStorageValue(cid,5019)
if queststatus == -1 then
itemstatus = doPlayerRemoveItem(cid,2342)
if itemstatus == -1 then
selfSay('! Zostawilem moja ksiazke w skrzyni na cmentarzu, prosze przynies ja.')
else
doPlayerAddItem(cid, 2525, 1)
selfSay('Dziekuje, oto twoja nagroda.')
end
else
selfSay('Nie mam wiecej zadan.')
end
if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then
selfSay('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('Go away.')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end
Kod:
<?xml version="1.0"?>
<npclist>
<npc name="kaplan" x="160" y="152" z="7" dir="3"/>
</npclist>
Proszę powiedzcie co źle zrobiłem w skrypcie bo robiłem go wzorując się na innym npc z tego samego silnika.
Zakładki