What's new

NPC Npc BP

Status
Not open for further replies.

Hakeq

Banned
Joined
Mar 23, 2013
Messages
103
Reaction score
6
Autor: Xkono
Witam,dzisiaj mam wam do zaprezentowania Npc kt?ry sprzedaje backpacki[/B]

1.Wchodzimy w : data/npc
2.Robimy plik xml o nazwie BP
3.Otwieramy go i wklejamy :

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

<npc name="BP" script="data/npc/scripts/backpack.lua" access="3" lookdir="1">
	<health now="1" max="1"/>
	<look type="128" head="66" body="46" legs="2" feet="89"/>
</npc>
4.Zapisujemy
5.Teraz otwieramy : data\npc\scripts
6.Tworzymy plik lua o nazwie backpack i wklejamy :

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('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('Siema, ' .. creatureGetName(cid) .. '! Sprzedaje Blue bp (50gps), red bp (50gps), yellow bp (50gps), tiquanda bp (50gps), green bp (50gps) and gray bp (50gps). I kupuje butelki (10gps).')
 		selfLook(cid)
		focus = cid
 		talk_start = os.clock()

 	elseif string.find(msg, '(%a*)hi(%a*)') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
 		selfSay('Zara, ' .. creatureGetName(cid) .. '! Poczekaj Chwile :D.')

 	elseif msgcontains(msg, 'blue backpack') and focus == cid then
 		buy(cid,1999,1,50)
 		talk_start = os.clock()

 	elseif msgcontains(msg, 'red backpack') and focus == cid then
 		buy(cid,1999,1,50)
 		talk_start = os.clock()

 	elseif msgcontains(msg, 'yellow backpack') and focus == cid then
 		buy(cid,1999,1,50)
 		talk_start = os.clock()

 	elseif msgcontains(msg, 'tiquanda backpack') and focus == cid then

 		buy(cid,1999,1,50)
 		talk_start = os.clock()

 	elseif msgcontains(msg, 'green backpack') and focus == cid then

 		buy(cid,1999,1,50)
 		talk_start = os.clock()

 	elseif msgcontains(msg, 'gray backpack') and focus == cid then
 		buy(cid,1999,1,50)
 		talk_start = os.clock()

 	elseif string.find(msg, '(%a*)bye(%a*)') and focus == cid and getDistanceToCreature(cid) < 4 then
 		selfSay('Narazie, ' .. creatureGetName(cid) .. '!')
 		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('Nastepny Prosze...')
  		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 == 0 then
nx = cx + 0
end
if randmove == 0 then
nx = cx - 0
end
if randmove == 0 then
ny = cy + 0
end
if randmove == 0 then
ny = cy - 0
end
if randmove >= 0 then
nx = cx
ny = cy
end
moveToPosition(nx, ny, cz)
--summons = 0
--summons2 = 0
end
end

Po Wklejeniu Zapisujemy

7.Wchodzimy w : data\world i otwieramy npc.xml
8. Wklejamy tam :

Code:
<npc name="backpacks" x="XXX" y="XXX" z="X"/>

W pola XXX,XXX i X trzeba wpisac gdzie ma sie znajdowac npc :)

9.Zapisujemy

10.Mozemy sie cieszyc nowym npc.
 
Status
Not open for further replies.
Top