Ariantede
Active User
- Joined
- Apr 21, 2008
- Messages
- 131
- Reaction score
- 0
- Age
- 29
Witam mam pewnien problem gdyz zrobilem pare npc addonerow daje im dane itemy a oni mi addon dzialo akurat to ale np.mam juz addon oriental i chce isc do npc ktory daje addon noblemana(ale nie mam go) to pisze mi "You Already This Addon!" ale go nie mam. tutaj przyklad scriptu npc knighta co mam zrobic zmienic cos,gdzies zeby mozna bylo dowolnie brac rozne addony czy jak juz sam nie wiem prosze o pomoc z gory dzieki i reput...
PROSZE O POMOC
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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
npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. Hello, can a help you?.")
function playerBuyAddonNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if (parameters.confirm ~= true) and (parameters.decline ~= true) then
if(getPlayerPremiumDays(cid) == 0) and (parameters.premium == true) then
npcHandler:say('Sorry, but this addon is only for premium players!', cid)
npcHandler:resetNpc()
return true
end
if (getPlayerStorageValue(cid, parameters.storageID) ~= -20) then
npcHandler:say('You already have this addon!', cid)
npcHandler:resetNpc()
return true
end
local itemsTable = parameters.items
local items_list = ''
if table.maxn(itemsTable) > 0 then
for i = 1, table.maxn(itemsTable) do
local item = itemsTable[i]
items_list = items_list .. item[2] .. ' ' .. getItemName(item[1])
if i ~= table.maxn(itemsTable) then
items_list = items_list .. ', '
end
end
end
local text = ''
if (parameters.cost > 0) and #parameters.items > 0 then
text = items_list .. ' and ' .. parameters.cost .. ' gp'
elseif (parameters.cost > 0) then
text = parameters.cost .. ' gp'
elseif #parameters.items > 0 then
text = items_list
end
npcHandler:say('Did you bring me ' .. text .. ' for ' .. keywords[1] .. '?', cid)
return true
elseif (parameters.confirm == true) then
local addonNode = node:getParent()
local addoninfo = addonNode:getParameters()
local items_number = 0
if #addoninfo.items > 0 then
for i = 1, #addoninfo.items do
local item = addoninfo.items[i]
if (getPlayerItemCount(cid,item[1]) >= item[2]) then
items_number = items_number + 1
end
end
end
if(getPlayerMoney(cid) >= addoninfo.cost) and (items_number == #addoninfo.items) then
doPlayerRemoveMoney(cid, addoninfo.cost)
if table.maxn(addoninfo.items) > 0 then
for i = 1, table.maxn(addoninfo.items) do
local item = addoninfo.items[i]
doPlayerRemoveItem(cid,item[1],item[2])
end
end
doPlayerAddOutfit(cid, addoninfo.outfit_male, addoninfo.addon)
doPlayerAddOutfit(cid, addoninfo.outfit_female, addoninfo.addon)
setPlayerStorageValue(cid,addoninfo.storageID,1)
npcHandler:say('Here you are.', cid)
else
npcHandler:say('You do not have needed items or cash!', cid)
end
npcHandler:resetNpc()
return true
elseif (parameters.decline == true) then
npcHandler:say('Not interested? Bye', cid)
npcHandler:resetNpc()
return true
end
return false
end
local noNode = KeywordNode:new({'no'}, playerBuyAddonNPC, {decline = true})
local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})
local outfit_node = keywordHandler:addKeyword({'first knight addon'}, playerBuyAddonNPC, {premium = true, cost = 0, items = {{5741,1}, {6540,2}, {2328,6}}, outfit_female = 139, outfit_male = 131, addon = 1, storageID = 10001})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second knight addon'}, playerBuyAddonNPC, {premium = true, cost = 10000, items = {{6096,5}, {6500,20}, {5880,150}, {5902,20}}, outfit_female = 139, outfit_male = 131, addon = 2, storageID = 10002})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
npcHandler:addModule(FocusModule:new())
PROSZE O POMOC