Witam. Potrzebuje npc ktory za 2 itemy daje mi 1 np za "spell book" oraz "bone shield" otrzymuje "tear of daraman". Bawilem sie z tym skryptem ale nie sprawdza czy gracz ma 2 itemy i wystarczy jedna z wyzej wymienionych by npc oddal "tear". Zamieszczam kod mam nadzieje ze ktos bedzie w stanie wskazac gdzie poplenilem b?ad.
z Gory dziekuje.
Kod:
focus = 0
talk_start = 0
target = 0
following = false
attacking = false
talk_state = 0
cname = ''
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('.')
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 (msgcontains(msg, 'aqua vitae') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('...' .. creatureGetName(cid) .. '!...')
talk_state = 0
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'aqua vitae') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('...')
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('...')
talk_state = 0
focus = 0
talk_start = 0
elseif focus == cid then
talk_start = os.clock()
if talk_state == 0 then
if msgcontains(msg, 'firmo') then
itemstatus = doPlayerRemoveItem(cid,2175)
itemstatus2 = doPlayerRemoveItem(cid,2541)
if itemstatus and itemstatus2 == -1 then
selfSay('...')
else
buy(cid,2346,1,0)
selfSay('renovatio!')
end
elseif msgcontains(msg, 'redhibeo') then
selfSay('/send ' .. creatureGetName(cid) .. ', 1868 716 7')
else
selfSay('.')
talk_state = 0
end
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('...')
focus = 0
end
end
end

