Witajcie,
Jestem tu nowy, ale postanowi?em szybko wzi?? si? do roboty
Dzi? zrobi?em mojego pierwszego NPC i postanowi?em zamie?ci? go tutaj, aby komu? kto poszukuje NPC u?atwi? ?ycie Ostrzegam, to m?j pierwszy NPC, a wi?c otwarty jestem na wszelkie propozycje poprawienia b??d?w.
A wi?c Celly.xml (Lekarz)
Celly.lua
Mam nadziej?, ?e si? uda?
Jestem tu nowy, ale postanowi?em szybko wzi?? si? do roboty
Dzi? zrobi?em mojego pierwszego NPC i postanowi?em zamie?ci? go tutaj, aby komu? kto poszukuje NPC u?atwi? ?ycie Ostrzegam, to m?j pierwszy NPC, a wi?c otwarty jestem na wszelkie propozycje poprawienia b??d?w.
A wi?c Celly.xml (Lekarz)
PHP:
<?xml version="1.0"?>
<npc name="Celly" script="data/npc/scripts/Celly.lua" access="5" lookdir="2" autowalk="0">
<look type="194" head="0" body="0" legs="0" feet="0"/>
</npc>
PHP:
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...')
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
maxhealth = getCreatureMaxHealth(cid)
health = getCreatureHealth(cid)
if health < maxhealth then
selfSay(Sl?abo wygladasz ' .. getCreatureName(cid) .. ', Pozwol, ze Cie uzdrowie')
else
selfSay('Wszystko z toba OK. Nie zawracaj mi nastepnym razem glowy.')
focus = 0
talk_start = 0
end
elseif (msgcontains(msg, 'help') or msgcontains(msg, 'heal')) and getDistanceToCreature(cid) < 4 then
selfSay('Uleczyc?')
elseif (msgcontains(msg, 'tak') or msgcontains(msg, 'yes')) and getDistanceToCreature(cid) < 4 then
doCreatureAddHealth(cid,ammound)
selfSay('Zegnam.')
focus = 0
talk_start = 0
elseif (msgcontains(msg, 'bye') or msgcontains(msg, 'nie')) and getDistanceToCreature(cid) < 4 then
selfSay('Zegnajj')
focus = 0
talk_start = 0
end
end
function onCreatureChangeOutfit(creature)
end
function onThink()
if focus > 0 then
x, y, z = creatureGetPosition(focus)
myx, myy, myz = selfGetPosition()
if ((myy-y==0) and (myx-x<=0 and myx-x>=-4)) then
selfTurn(1)
end
if ((myy-y==0) and (myx-x>=0 and myx-x<=4)) then
selfTurn(3)
end
if ((myx-x==0) and (myy-y<=0 and myy-y>=-4)) then
selfTurn(2)
end
if ((myx-x==0) and (myy-y>=0 and myy-y<=4)) then
selfTurn(0)
end
if ((myy-y==-2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(2)
end
if ((myy-y==2) and (myx-x>=-1 and myx-x<=1)) then
selfTurn(0)
end
if ((myx-x==2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(3)
end
if ((myx-x==-2) and (myy-y>=-1 and myy-y<=1)) then
selfTurn(1)
end
if ((myy-y==-3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(2)
end
if ((myy-y==3) and (myx-x>=-2 and myx-x<=2)) then
selfTurn(0)
end
if ((myx-x==3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(3)
end
if ((myx-x==-3) and (myy-y>=-2 and myy-y<=2)) then
selfTurn(1)
end
if ((myy-y==-4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(2)
end
if ((myy-y==4) and (myx-x>=-3 and myx-x<=3)) then
selfTurn(0)
end
if ((myx-x==4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(3)
end
if ((myx-x==-4) and (myy-y>=-3 and myy-y<=3)) then
selfTurn(1)
end
end
if (os.clock() - talk_start) > 30 then
if focus > 0 then
selfSay('Jestem zajety, nastepnym razem mow szybciej...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Polecam sie na przyslosc.')
focus = 0
end
end
end