What's new

Manasor by me

Status
Not open for further replies.

Wina

Advanced User
Joined
Nov 18, 2008
Messages
221
Reaction score
14
Witam.
Zrobi?em dzi? npc kt?ry sprzedaje ziolo i manasory (ziolo jest z tego forum a manasory by me).

A wi?c tak.
Tworzymy plik w data\actions\scripts plik manasor.lua
Otwieramy go i piszemy:
Code:
function onUse(cid, item, frompos, item2, topos)
mag = getPlayerMagLevel(cid)
if mag >= 4 then
doSendMagicEffect(topos,12)
doPlayerSendTextMessage(cid,22,"I jeszcze jeden, i jeszcze raz!:D")
doPlayerAddMana(cid, [color=red]300[/color]) <---- Tu piszemy ilo?? many.
if item.type > 1 then
doChangeTypeItem(item.uid,item.type-1)
end


else
doSendMagicEffect(frompos,2)
doPlayerSendCancel(cid,"Co za duzo to nie zdrowo xP")
end
return 1
end

I tworzymy ziolo.lua (?eby npc chodzi?)
I w ziolo.lua piszemy:
Code:
MAX_FOOD = 500
function onUse(cid, item, frompos, item2, topos)
-- Get food value depending on item.itemid
food = 60
if (getPlayerFood(cid) + food > MAX_FOOD) then
doPlayerSendCancel(cid,"Przecpalem sie...")
return 1
end
doPlayerFeed(cid,food)
doRemoveItem(item.uid,1)
doPlayerAddHealth(cid,-100)
doSendMagicEffect(topos,2)
doPlayerSay(cid,"Pale ziolo, jest wesolo!",1)
return 1
end

Teraz idziemy folder wcze?niej (data\actions) i otwieramy Actions.xml
A w nim piszemy:
<action itemid="2802" script="ziolo.lua" />

-----Scrypt by Wina ^^Manasor^^------
<action itemid="2695" script="manasor.lua" /> --manasor--

O bym zapomnia? jak wejdziecie w actions.xml usu?cie linijke:
<action itemid="2695" script="food.lua" />

Potem wchodzimy w data\npc i tworzymy plik Diler.xml
A w nim:
Code:
<?xml version="1.0"?>
<npc name="Diler" script="data/npc/scripts/ziolko.lua" access="3">
 	<look type="68" head="20" body="30" legs="40" feet="50"/>
</npc>

Po chwili przechodzimy do data\npc\scripts
I tworzymy plik ziolko.lua
A w nim:
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('Nara ZioOm.')
          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, 'witaj') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('Emka ziom. ' .. creatureGetName(cid) .. '! Sprzedam ci Manasora lub Ziolo i bendzie wesolo:D')
  		focus = cid
  		talk_start = os.clock()

  	elseif msgcontains(msg, 'witaj') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Sory ziom ale, ' .. creatureGetName(cid) .. '! Zara z tobo pogadam.')

	elseif focus == cid then
		talk_start = os.clock()

		if msgcontains(msg, 'change platin 1') then
			buy(cid,2148,100,100)
		elseif msgcontains(msg, 'ziolo') then
			buy(cid,2802,50,0)
		elseif msgcontains(msg, 'manasor') then
			buy(cid,2695,50,0)

		elseif msgcontains(msg, 'nara') and getDistanceToCreature(cid) < 4 then
			selfSay('Narq ziom., ' .. 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('Kupujcie or dead.')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Good bye then.')
 			focus = 0
 		end
 	end
end

Dzia?a pod tibie 7.6 (na wszystkich silnikach), nie pr?bowa?em na innych klientach^^
Scrypty 100% by me oprucz zio?ka, prosz? ocenia? (to m?j 1 scrypt z actions)
 
Last edited:
Status
Not open for further replies.
Top