
Nie tylko o Tibii i OTS...

A więc mam tutaj NPC Atter sprzedaje on różne dziwne itemy ozdobne typu:
-Głłowa hydry
-kilka kolorów magic sulphur
-Fire bug
i takie inne dziwne
data/npc/scripts
ocus = 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) .. '! I selling obsidian knife,ice cubes,shard,hydra,and sulphur(you can select yellow blue red green and pink),aslo i offer fire bug')
focus = cid
talk_start = os.clock()
if string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
end
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'obsidian') then
buy(cid,5908,1,10000)
elseif msgcontains(msg, 'ice') then
buy(cid,7441,1,500)
elseif msgcontains(msg, 'shard') then
buy(cid,7290,1,3000)
elseif msgcontains(msg, 'hydra') then
buy(cid,7250,1,40000)
elseif msgcontains(msg, 'yellow') then
buy(cid,5904,5,5000)
elseif msgcontains(msg, 'blue') then
buy(cid,5905,5,6000)
elseif msgcontains(msg, 'red') then
buy(cid,5906,5,7000)
elseif msgcontains(msg, 'green') then
buy(cid,7251,5,8000)
elseif msgcontains(msg, 'pink') then
buy(cid,6548,5,8000)
elseif msgcontains(msg, 'fire') then
buy(cid,4568,1,100)
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Bywaj, ' .. creatureGetName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Next plx...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
if focus == 0 then
cx, cy, cz = selfGetPosition()
randmove = math.random(1,20)
if randmove == 1 then
nx = cx + 1
end
if randmove == 2 then
nx = cx - 1
end
if randmove == 3 then
ny = cy + 1
end
if randmove == 4 then
ny = cy - 1
end
if randmove >= 5 then
nx = cx
ny = cy
end
moveToPosition(nx, ny, cz)
--summons = 30
--summons2 = 30
end
end
Teraz tworzymy plik o nazwie Atter.xml w data/npc
a w nim:
<?xml version="1.0"?>
<npc name="Atter" script="data/npc/scripts/rares.lua" access="3" lookdir="1">
<health now="1" max="1"/>
<look type="129" head="95" body="116" legs="121" feet="115"/>
</npc>
Skrypcik nie moj
Testowane jest to na Devlandzie i dziala
Jak by co to prosze o pozytywne ocenkki...
Offline

Offline
e takie sobie 6+/10

Offline

8560857Offline