What's new

Kolejny problem - NPC

Mizuno

User
Joined
Sep 14, 2009
Messages
11
Reaction score
0
Nie wiem, kt?ry to ju? z rz?du temat z moim problemem, ale co poradzi?. :p
Zmieni?em niedawno silnik, pono? najlepszy pod 7.92. Jedyny problem, jaki posiadam z nim, to NPC.

nzm2z9.jpg

Sprawdza?em wszystkie skrypty, wszystkie NPC s? dobrze ustawione. Dzia?aj? jedynie Frodo, Johnny i Guild Master. Zauwa?y?em, ?e pozosta?e, nie dzia?aj?ce NPC, s? skryptowane tak jak w innych silnikach, a te NPC kt?re dzia?aj? maj? w?asne skryptowanie.

Frodo:
PHP:
local focus = 0
local talk_start = 0
local target = 0
local following = false
local 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 (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 then
  		selfSay('Elo, ' .. creatureGetName(cid) .. '! Ja sprzedaje ropes (50gp), shovels (20gp), backpacks (10gp), manafluids (100gp), Blessed Wooden Stake (6k), Obsidian Knife (10k), aol (10k),I SPRZEDAJE KURWA | BP MANAFLUIDS |(1k). Kupie vials (10gp).')
  		focus = cid
  		talk_start = os.clock()

  	elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
  		selfSay('Przepraszam, ' .. creatureGetName(cid) .. '! Rozmiawiam z toba juz minute.')

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

		if msgcontains(msg, 'shovel') then
			buy(cid,2554,getCount(msg),20)
		elseif msgcontains(msg, 'backpack') then
			buy(cid,1988,getCount(msg),10)
		elseif msgcontains(msg, 'bp manafluids') then
			buyContainer(cid, 2001, 2006, 7, 2000)
		elseif msgcontains(msg, 'manafluid') or msgcontains(msg, 'mana fluid') then
			buyFluidContainer(cid,2006,getCount(msg),100,7)
		elseif msgcontains(msg, 'lifefluid') or msgcontains(msg, 'life fluid') then
			buyFluidContainer(cid,2006,getCount(msg),60,10)
		elseif msgcontains(msg, 'fishing rod') then
			buy(cid,2580,getCount(msg),100)
		elseif msgcontains(msg, 'torch') then
			buy(cid,2050,getCount(msg),2)
		elseif msgcontains(msg, 'rope') then
			buy(cid,2120,getCount(msg),50)
		elseif msgcontains(msg, 'aol') then
			buy(cid,2173,getCount(msg),10000)	
		elseif msgcontains(msg, 'vial') or msgcontains(msg, 'flask') then
			sell(cid,2006,getCount(msg),10)
		elseif msgcontains(msg, 'obsidian knife') or msgcontains(msg, 'knife') then
			sell(cid,5908,getCount(msg),10000)
		elseif msgcontains(msg, 'blessed wooden stake') or msgcontains(msg, 'blessed wooden stake') then
			sell(cid,5942,getCount(msg),6000)

		elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
			selfSay('SPIERDALAJ LAMUSIE NA DRZEWO PROSTOWAC BANANY, ' .. 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('Nastepny kurwa...')
  		end
  			focus = 0
  	end
 	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
 			selfSay('Ok to spierdalaj.')
 			focus = 0
 		end
 	end
end

Malak:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)



-- OTServ event handling functions start
function onCreatureAppear(cid)				npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) 			npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) 	npcHandler:onCreatureSay(cid, type, msg) end
function onThink() 						npcHandler:onThink() end
-- OTServ event handling functions end

local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)

shopModule:addBuyableItem({'light wand', 'lightwand'}, 					2163, 500, 		'magic light wand')
shopModule:addBuyableItem({'mana fluid', 'manafluid'}, 					2006, 100, 	7, 	'mana fluid')
shopModule:addBuyableItem({'life fluid', 'lifefluid'}, 					2006, 80, 	10,	'life fluid')

shopModule:addBuyableItem({'heavy magic missile', 'hmm'}, 					2311, 3000, 100,	'heavy magic missile rune')
shopModule:addBuyableItem({'great fireball', 'gfb'}, 						2304, 1500, 100, 	'great fireball rune')
shopModule:addBuyableItem({'explo', 'xpl'}, 							2313, 2500, 100, 	'explosion rune')
shopModule:addBuyableItem({'ultimate healing', 'uh'}, 					2273, 4000, 100, 	'ultimate healing rune')
shopModule:addBuyableItem({'sudden death', 'sd'}, 						2268, 8000, 100,	'sudden death rune')
shopModule:addBuyableItem({'blank', 'rume'}, 							2260, 1, 		'blank rume')
shopModule:addBuyableItem({'manarune', 'mr'}, 							2275, 15000, 10,  'manarune rune')


shopModule:addBuyableItem({'wand of inferno', 'inferno'}, 				2187, 15000, 	'wand of inferno')
shopModule:addBuyableItem({'wand of plague', 'plague'}, 				2188, 5000, 	'wand of plague')
shopModule:addBuyableItem({'wand of cosmic energy', 'cosmic energy'}, 	2189, 10000, 	'explosion rune')
shopModule:addBuyableItem({'wand of vortex', 'vortex'}, 				2190, 500, 	 	'wand of cosmic energy')
shopModule:addBuyableItem({'wand of dragonbreath', 'dragonbreath'}, 	2191, 1000, 	'wand of dragonbreath')

shopModule:addBuyableItem({'quagmire rod', 'quagmire'}, 				2181, 10000, 	'quagmire rod')
shopModule:addBuyableItem({'snakebite rod', 'snakebite'}, 				2182, 500, 	 	'snakebite rod')
shopModule:addBuyableItem({'tempest rod', 'tempest'}, 				2183, 15000, 	'tempest rod')
shopModule:addBuyableItem({'volcanic rod', 'volcanic'}, 				2185, 3000, 	'volcanic rod')
shopModule:addBuyableItem({'moonlight rod', 'moonlight'}, 				2186, 500,   	'moonlight rod')

npcHandler:addModule(FocusModule:new())
 

Mizuno

User
Joined
Sep 14, 2009
Messages
11
Reaction score
0
Odp: Kolejny problem - NPC

Od?wie?am. Prosz? o pomooc.
 
Top