Siema mam ots wodbo i chcialbym zrobic npc ktory odbugowuje lvl. Probowalem go zrobic ale nie dziala. oto skrypt jaki posiadam w tej chwili
Code:
local focus = 0
local talk_start = 0
local target = 0
local days = 0
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Zegnaj, Nastepny.')
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, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
selfSay('Witaj ' .. creatureGetName(cid) .. '! Odbugowuje Lvl.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! Rozmawiam juz z toba minute.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'promotion') or msgcontains(msg, 'promote') then
if getPlayerVocation(cid) > 4 then
selfSay('Sorry, masz juz promotion.')
talk_state = 0
elseif getPlayerLevel(cid) < 8 then
selfSay('Sorry, musisz miec 8lvl by kupic promotion.')
talk_state = 0
elseif not isPremium(cid) then
selfSay('Sorry, musisz miec premium by kupic promotion.')
talk_state = 0
else
selfSay('chcesz kupic promotion za 20k?')
talk_state = 1
end
elseif msgcontains(msg, 'lvl') or msgcontains(msg, 'level') then
selfSay('chcesz kupic level za 400g?')
talk_state = 2
elseif talk_state == 1 then
if msgcontains(msg, 'yes') then
if pay(cid,20000) then
doPlayerSetVocation(cid, getPlayerVocation(cid)+4)
selfSay('Dostales promotion!')
else
selfSay('Sorry, Nie masz tyle kasy.')
end
end
talk_state = 0
elseif talk_state == 2 then
if msgcontains(msg, 'yes') then
if pay(cid,4000000) then
selfSay('/xaddexp '.. creatureGetName(cid) ..'')
selfSay('Dostales 1 level!')
else
selfSay('Sorry, nie masz tyle kaski.')
end
end
talk_state = 0
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Zegnaj, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Nastepny...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Zegnaj, Nastepny.')
focus = 0
end
end
end