What's new

Problem z NPC;/

Status
Not open for further replies.

krycha1998

Advanced User
Joined
May 22, 2009
Messages
199
Reaction score
6
Witam,problem z silnikiem ,mianowicie :

1.NPC sprzedaje za du?o ,mp,gmp etc.
*polega to na tym ,je?eli kupimy np.50 mp dostajemy ok.3k;<,tak samo z runami.Wandy/rody dzia?aj? bez problem?w :

o to m?j skrypt
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local trade = {
{id=2187, buy=15000, sell=3000, name="wand of inferno"},
{id=2175, buy=150, sell=10, name="spellbook"},
{id=8704, buy=20, sell=10, name="small healht potion"},
{id=2163, buy=450, sell=10, name="magic lightwand"},
{id=7618, buy=10, sell=10, name="health potion"},
{id=7620, buy=50, sell=10, name="mana potion"},
{id=7588, buy=100, sell=10, name="strong health potion"},
{id=7589, buy=80, sell=10, name="strong mana potion"},
{id=7591, buy=190, sell=10, name="great health potion"},
{id=7590, buy=120, sell=10, name="great mana potion"},
{id=8472, buy=190, sell=10, name="great spirit potion"},
{id=8473, buy=310, sell=10, name="ultimate health potion"},
{id=8474, buy=50, sell=10, name="antidote potion"},
{id=2265, buy=95, sell=10, name="intensive healing rune"},
{id=2273, buy=175, sell=10, name="ultimate healing rune"},
{id=2293, buy=350, sell=10, name="magic wall rune"},
{id=2261, buy=45, sell=10, name="destroy field rune"},
{id=2287, buy=45, sell=10, name="light magic missile rune"},
{id=7635, buy=15, sell=10, name="heavy magic missile rune"},
{id=2304, buy=180, sell=10, name="great fireball rune"},
{id=2313, buy=350, sell=10, name="explosion rune"},
{id=2268, buy=30, sell=10, name="sudden death rune"},
{id=2263, buy=300, sell=10, name="death arrow rune"},
{id=2278, buy=700, sell=10, name="paralyze rune"},
{id=2316, buy=375, sell=10, name="animate dead rune"},
{id=2290, buy=80, sell=10, name="convince creature rune"},
{id=2291, buy=210, sell=10, name="chameleon rune"},
{id=2310, buy=80, sell=10, name="desintegreat rune"},
{id=2190, buy=500, sell=10, name="wand of vortex"},
{id=2191, buy=1000, sell=10, name="wand of dragonbreath"},
{id=2188, buy=5000, sell=10, name="wand of decay"},
{id=9821, buy=7500, sell=10, name="wand of draconia"},
{id=8920, buy=18000, sell=10, name="wand of starstorm"},
{id=8922, buy=22000, sell=10, name="wand of voodoo"},
{id=2182, buy=500, sell=10, name="snakebite rod"},
{id=2186, buy=1000, sell=10, name="moonlight rod"},
{id=2185, buy=5000, sell=10, name="necrotic rod"},
{id=8911, buy=7500, sell=10, name="northwind rod"},
{id=2181, buy=10000, sell=10, name="terra rod"},
{id=2183, buy=15000, sell=10, name="hailstorm rod"},
{id=8912, buy=18000, sell=10, name="springsprout rod"},
{id=8910, buy=22000, sell=10, name="underworld rod"},
{id=2189, buy=10000, sell=2500, name="wand of cosmic energy"}
}






local items = {}
for _, item in ipairs(trade) do
items[item.id] = {storage = item.storage, item_id = item.id, buyPrice = item.buy, sellPrice = item.sell, subType = 0, realName = item.name}
end

local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if items[item].buyPrice ~= 0 then
doPlayerRemoveMoney(cid, amount * items[item].buyPrice)
for i = 1, amount do
doPlayerAddItem(cid, items[item].item_id, amount)
end
doNPCTalkALot(cid, 200, {"You bought "..amount.." "..items[item].realName.." for "..items[item].buyPrice * amount.." gold coins."})
end
end

local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks)
if items[item].sellPrice ~= 0 then
doPlayerAddMoney(cid, items[item].sellPrice * amount)
doPlayerRemoveItem(cid, items[item].item_id, amount)
doNPCTalkALot(cid, 200, {"You sell "..amount.." "..items[item].realName.." for "..items[item].sellPrice * amount.." gold coins."})
end
end

if msgcontains(msg, 'trade') or msgcontains(msg, 'offer') then
openShopWindow(cid, trade, onBuy, onSell)
selfSay("It's my offer.", cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Posiadam silnik TFS 0.4 trunk r.3884

Prosz? o szybk? pomoc !

P.S.w razie problem?w b?d? edytowa? ten dzia? ,wi?c w wolnej chwili zajrzyj tu xDD
 

Jet123

User
Joined
Jul 12, 2011
Messages
41
Reaction score
2
Odp: Problem z NPC;/

a to chodzi o malaka ??
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}

function onCreatureAppear(cid) npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink() npcHandler:eek:nThink() end

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

shopModule:addBuyableItem({'spellbook'}, 2175, 150, 'spellbook')
shopModule:addBuyableItem({'magic lightwand'}, 2163, 400, 'magic lightwand')

shopModule:addBuyableItem({'small health'}, 8704, 20, 1, 'small health potion')
shopModule:addBuyableItem({'health potion'}, 7618, 45, 1, 'health potion')
shopModule:addBuyableItem({'mana potion'}, 7620, 50, 1, 'mana potion')
shopModule:addBuyableItem({'strong health'}, 7588, 100, 1, 'strong health potion')
shopModule:addBuyableItem({'strong mana'}, 7589, 80, 1, 'strong mana potion')
shopModule:addBuyableItem({'great health'}, 7591, 190, 1, 'great health potion')
shopModule:addBuyableItem({'great mana'}, 7590, 120, 1, 'great mana potion')
shopModule:addBuyableItem({'great spirit'}, 8472, 190, 1, 'great spirit potion')
shopModule:addBuyableItem({'ultimate health'}, 8473, 310, 1, 'ultimate health potion')
shopModule:addBuyableItem({'antidote potion'}, 8474, 50, 1, 'antidote potion')

shopModule:addSellableItem({'normal potion flask', 'normal flask'}, 7636, 5, 'empty small potion flask')
shopModule:addSellableItem({'strong potion flask', 'strong flask'}, 7634, 10, 'empty strong potion flask')
shopModule:addSellableItem({'great potion flask', 'great flask'}, 7635, 15, 'empty great potion flask')

shopModule:addBuyableItem({'instense healing'}, 2265, 95, 1, 'intense healing rune')
shopModule:addBuyableItem({'ultimate healing'}, 2273, 175, 1, 'ultimate healing rune')
shopModule:addBuyableItem({'magic wall'}, 2293, 350, 3, 'magic wall rune')
shopModule:addBuyableItem({'destroy field'}, 2261, 45, 3, 'destroy field rune')
shopModule:addBuyableItem({'light magic missile'}, 2287, 40, 10, 'light magic missile rune')
shopModule:addBuyableItem({'heavy magic missile'}, 2311, 120, 10, 'heavy magic missile rune')
shopModule:addBuyableItem({'great fireball'}, 2304, 180, 4, 'great fireball rune')
shopModule:addBuyableItem({'explosion'}, 2313, 250, 6, 'explosion rune')
shopModule:addBuyableItem({'sudden death'}, 2268, 350, 3, 'sudden death rune')
shopModule:addBuyableItem({'death arrow'}, 2263, 300, 3, 'death arrow rune')
shopModule:addBuyableItem({'paralyze'}, 2278, 700, 1, 'paralyze rune')
shopModule:addBuyableItem({'animate dead'}, 2316, 375, 1, 'animate dead rune')
shopModule:addBuyableItem({'convince creature'}, 2290, 80, 1, 'convince creature rune')
shopModule:addBuyableItem({'chameleon'}, 2291, 210, 1, 'chameleon rune')
shopModule:addBuyableItem({'desintegrate'}, 2310, 80, 3, 'desintegreate rune')

shopModule:addBuyableItemContainer({'bp slhp'}, 2000, 8704, 400, 1, 'backpack of small health potions')
shopModule:addBuyableItemContainer({'bp hp'}, 2000, 7618, 900, 1, 'backpack of health potions')
shopModule:addBuyableItemContainer({'bp mp'}, 2001, 7620, 1000, 1, 'backpack of mana potions')
shopModule:addBuyableItemContainer({'bp shp'}, 2000, 7588, 2000, 1, 'backpack of strong health potions')
shopModule:addBuyableItemContainer({'bp smp'}, 2001, 7589, 1600, 1, 'backpack of strong mana potions')
shopModule:addBuyableItemContainer({'bp ghp'}, 2000, 7591, 3800, 1, 'backpack of great health potions')
shopModule:addBuyableItemContainer({'bp gmp'}, 2001, 7590, 2400, 1, 'backpack of great mana potions')
shopModule:addBuyableItemContainer({'bp gsp'}, 1999, 8472, 3800, 1, 'backpack of great spirit potions')
shopModule:addBuyableItemContainer({'bp uhp'}, 2000, 8473, 6200, 1, 'backpack of ultimate health potions')
shopModule:addBuyableItemContainer({'bp ap'}, 2002, 8474, 2000, 1, 'backpack of antidote potions')

shopModule:addBuyableItem({'wand of vortex', 'vortex'}, 2190, 500, 'wand of vortex')
shopModule:addBuyableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 1000, 'wand of dragonbreath')
shopModule:addBuyableItem({'wand of decay', 'decay'}, 2188, 5000, 'wand of decay')
shopModule:addBuyableItem({'wand of draconia', 'draconia'}, 8921, 7500, 'wand of draconia')
shopModule:addBuyableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 10000, 'wand of cosmic energy')
shopModule:addBuyableItem({'wand of inferno', 'inferno'}, 2187, 15000, 'wand of inferno')
shopModule:addBuyableItem({'wand of starstorm', 'starstorm'}, 8920, 18000, 'wand of starstorm')
shopModule:addBuyableItem({'wand of voodoo', 'voodoo'}, 8922, 22000, 'wand of voodoo')

shopModule:addBuyableItem({'snakebite rod', 'snakebite'}, 2182, 500, 'snakebite rod')
shopModule:addBuyableItem({'moonlight rod', 'moonlight'}, 2186, 1000, 'moonlight rod')
shopModule:addBuyableItem({'necrotic rod', 'necrotic'}, 2185, 5000, 'necrotic rod')
shopModule:addBuyableItem({'northwind rod', 'northwind'}, 8911, 7500, 'northwind rod')
shopModule:addBuyableItem({'terra rod', 'terra'}, 2181, 10000, 'terra rod')
shopModule:addBuyableItem({'hailstorm rod', 'hailstorm'}, 2183, 15000, 'hailstorm rod')
shopModule:addBuyableItem({'springsprout rod', 'springsprout'}, 8912, 18000, 'springsprout rod')
shopModule:addBuyableItem({'underworld rod', 'underworld'}, 8910, 22000, 'underworld rod')

shopModule:addSellableItem({'wand of vortex', 'vortex'}, 2190, 250, 'wand of vortex')
shopModule:addSellableItem({'wand of dragonbreath', 'dragonbreath'}, 2191, 500, 'wand of dragonbreath')
shopModule:addSellableItem({'wand of decay', 'decay'}, 2188, 2500, 'wand of decay')
shopModule:addSellableItem({'wand of draconia', 'draconia'}, 8921, 3750, 'wand of draconia')
shopModule:addSellableItem({'wand of cosmic energy', 'cosmic energy'}, 2189, 5000, 'wand of cosmic energy')
shopModule:addSellableItem({'wand of inferno', 'inferno'},2187, 7500, 'wand of inferno')
shopModule:addSellableItem({'wand of starstorm', 'starstorm'}, 8920, 9000, 'wand of starstorm')
shopModule:addSellableItem({'wand of voodoo', 'voodoo'}, 8922, 11000, 'wand of voodoo')

shopModule:addSellableItem({'snakebite rod', 'snakebite'}, 2182, 250,'snakebite rod')
shopModule:addSellableItem({'moonlight rod', 'moonlight'}, 2186, 500, 'moonlight rod')
shopModule:addSellableItem({'necrotic rod', 'necrotic'}, 2185, 2500, 'necrotic rod')
shopModule:addSellableItem({'northwind rod', 'northwind'}, 8911, 3750, 'northwind rod')
shopModule:addSellableItem({'terra rod', 'terra'}, 2181, 5000, 'terra rod')
shopModule:addSellableItem({'hailstorm rod', 'hailstorm'}, 2183, 7500, 'hailstorm rod')
shopModule:addSellableItem({'springsprout rod', 'springsprout'}, 8912, 9000, 'springsprout rod')
shopModule:addSellableItem({'underworld rod', 'underworld'}, 8910, 11000, 'underworld rod')

local items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then
if(isSorcerer(cid) or isDruid(cid)) then
if(getPlayerStorageValue(cid, 30002) <= 0) then
selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)
talkState[talkUser] = 1
else
selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)
end
else
selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
end
elseif(msgcontains(msg, 'yes')) then
if(talkState[talkUser] == 1) then
doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)
selfSay('Here you are young adept, take care yourself.', cid)
setPlayerStorageValue(cid, 30002, 1)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser])) then
selfSay('Ok then.', cid)
talkState[talkUser] = 0
end

return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
a jak nie zr?b sobie d?wigni? i znajd? skrypt na np bp sd mia?em takie co? u siebie na serwerze ;d
 
Last edited:

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: Problem z NPC;/

PHP:
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local talkState = {} 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end 
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end 
local keywordHandler = KeywordHandler:new() 
local npcHandler = NpcHandler:new(keywordHandler) 
NpcSystem.parseParameters(npcHandler) 
local talkState = {} 
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 
local trade = { 
				{id=2187, buy=15000, sell=3000, name="wand of inferno"},
				{id=2175, buy=150, sell=10, name="spellbook"},
				{id=8704, buy=20, sell=10, name="small healht potion"},
				{id=2163, buy=450, sell=10, name="magic lightwand"},
				{id=7618, buy=10, sell=10, name="health potion"},
				{id=7620, buy=50, sell=10, name="mana potion"},
				{id=7588, buy=100, sell=10, name="strong health potion"},
				{id=7589, buy=80, sell=10, name="strong mana potion"},
				{id=7591, buy=190, sell=10, name="great health potion"},
				{id=7590, buy=120, sell=10, name="great mana potion"},
				{id=8472, buy=190, sell=10, name="great spirit potion"},
				{id=8473, buy=310, sell=10, name="ultimate health potion"},
				{id=8474, buy=50, sell=10, name="antidote potion"},
				{id=2265, buy=95, sell=10, name="intensive healing rune"},
				{id=2273, buy=175, sell=10, name="ultimate healing rune"},
				{id=2293, buy=350, sell=10, name="magic wall rune"},
				{id=2261, buy=45, sell=10, name="destroy field rune"},
				{id=2287, buy=45, sell=10, name="light magic missile rune"},
				{id=7635, buy=15, sell=10, name="heavy magic missile rune"},
				{id=2304, buy=180, sell=10, name="great fireball rune"},
				{id=2313, buy=350, sell=10, name="explosion rune"},
				{id=2268, buy=30, sell=10, name="sudden death rune"},
				{id=2263, buy=300, sell=10, name="death arrow rune"},
				{id=2278, buy=700, sell=10, name="paralyze rune"},
				{id=2316, buy=375, sell=10, name="animate dead rune"},
				{id=2290, buy=80, sell=10, name="convince creature rune"},
				{id=2291, buy=210, sell=10, name="chameleon rune"},
				{id=2310, buy=80, sell=10, name="desintegreat rune"},
				{id=2190, buy=500, sell=10, name="wand of vortex"},
				{id=2191, buy=1000, sell=10, name="wand of dragonbreath"},
				{id=2188, buy=5000, sell=10, name="wand of decay"},
				{id=9821, buy=7500, sell=10, name="wand of draconia"},
				{id=8920, buy=18000, sell=10, name="wand of starstorm"},
				{id=8922, buy=22000, sell=10, name="wand of voodoo"},
				{id=2182, buy=500, sell=10, name="snakebite rod"},
				{id=2186, buy=1000, sell=10, name="moonlight rod"},
				{id=2185, buy=5000, sell=10, name="necrotic rod"},
				{id=8911, buy=7500, sell=10, name="northwind rod"},
				{id=2181, buy=10000, sell=10, name="terra rod"},
				{id=2183, buy=15000, sell=10, name="hailstorm rod"},
				{id=8912, buy=18000, sell=10, name="springsprout rod"},
				{id=8910, buy=22000, sell=10, name="underworld rod"},
				{id=2189, buy=10000, sell=2500, name="wand of cosmic energy"} 
				} 

function creatureSayCallback(cid, type, msg) 
if(not npcHandler:isFocused(cid)) then 
return false 
end 
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid 
local items = {} 
for _, item in ipairs(trade) do 
items[item.id] = {storage = item.storage, item_id = item.id, buyPrice = item.buy, sellPrice = item.sell, subType = 0, realName = item.name} 
end
local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) 
	if doPlayerRemoveMoney(cid, amount * items[item].buyPrice) then
		for i = 1, amount do 
			doPlayerAddItem(cid, items[item].item_id, 1) 
		end 
		return doNPCTalkALot(cid, 200, {"You bought "..amount.." "..items[item].realName.." for "..items[item].buyPrice * amount.." gold coins."}) 
	end 
return true
end 
local onSell = function(cid, item, subType, amount, ignoreCap, inBackpacks) 
	if doPlayerRemoveItem(cid, items[item].item_id, amount) then 
		doPlayerAddMoney(cid, items[item].sellPrice * amount) 
		return doNPCTalkALot(cid, 200, {"You sell "..amount.." "..items[item].realName.." for "..items[item].sellPrice * amount.." gold coins."}) 
	end 
return true
end 

if msgcontains(msg, 'trade') or msgcontains(msg, 'offer') then 
	openShopWindow(cid, trade, onBuy, onSell) 
	return selfSay("It's my offer.", cid) 
end 
return true 
end 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
 
Status
Not open for further replies.
Top