What's new

NPC NPC Sfinks

Status
Not open for further replies.

Hakeq

Banned
Joined
Mar 23, 2013
Messages
103
Reaction score
6
W data/npc stworz Sfinks.xml i dodaj:

Code:
<?xml version="1.0"?>

<npc name="Sfinks" script="data/npc/scripts/pytania.lua" access="3" lookdir="1">
<health now="1" max="1"/>
<look type="41" head="20" body="30" legs="40" feet="50" corpse="4005"/>
</npc>

Pozniej w data/npc/scripts stworz pytania.lua i dodaj:

Code:
focus = 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('Gratulacje ukonczyles test! Nastepnym razem wystraczy, ze odpowiesz mi na jedno pytanie i teleportuje Cie w tajemnicze miejsce!')
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('Witaj, ' .. creatureGetName(cid) .. '! Jezeli odpowiesz na moje pytania przeniose cie do wspanialego miejsca! Powiedz tylko "zadanie".')
focus = cid
talk_start = os.clock()
end


if string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Grrrr, ' .. creatureGetName(cid) .. ' nie widzisz ze rozmawiam?')
end
if msgcontains(msg, 'zadanie') and focus == cid then
selfSay('Pierwsze pytanie!!!')
talk_start = os.clock()
end

if msgcontains(msg, 'Pierwsza odpowiedz!!!') and focus == cid then
talk_start = os.clock()

setPlayerStorageValue(cid,1000,1)

selfSay('Brawo dobrze! Nastepne pytanie brzmi.')
selfSay('Drugie pytanie!!!')

end

if msgcontains(msg, 'Druga odpowiedz!!!') and focus == cid then
talk_start = os.clock()
queststatus = getPlayerStorageValue(cid,1000)

if queststatus == -1 then
selfSay('Pierw odpowiedz na poprzednie pytanie.')
else
selfSay('Trzecie pytanie!!!')
setPlayerStorageValue(cid,1001,1)
end
end

if msgcontains(msg, 'Trzecia odpowiedz!!!') and focus == cid then
talk_start = os.clock()
queststatus = getPlayerStorageValue(cid,1001)

if queststatus == -1 then
selfSay('Pierw odpowiedz na poprzednie pytanie.')
else
selfSay('/send ' .. creatureGetName(cid) .. ', X Y Z')
selfSay('Zapamnietaj ta odpowiedz bym mogl cie teleportowac odrazu innym razem!')
setPlayerStorageValue(cid,1002,1)
end
end



if string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then
selfSay('Dowidzenia!')
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('Nie bede wiecej czekal!')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Sprobuj potem!')
focus = 0
end
end
end
Code:
selfSay('/send ' .. creatureGetName(cid) .. ', x y z')

Miejsce w jakie ma przenie?? gracza po wykonaniu zadania.

Autor: Serafin.
 
Status
Not open for further replies.
Top