Ir para conteúdo
  • Cadastre-se

arrumar esse script de addon


Posts Recomendados

gostaria de deixar esse script para quando player falar first addon comprar todas primeiras addon por 500k e quando falar second addon comprar todas segundas  addon por 1kk alguém ajuda pf?

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, "Olá |PLAYERNAME|. para ver as addon fale {addons} para comprar primeira addon fale, first mage addon, para compra segunda addon fale second mage addon.")

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) ~= -1) 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] .. ' ' .. getItemNameById(item[1])
if i ~= table.maxn(itemsTable) then
items_list = items_list .. ', '
end
end
end
local text = ''
if (parameters.cost > 0) and table.maxn(parameters.items) then
text = items_list .. ' and ' .. parameters.cost .. ' gp'
elseif (parameters.cost > 0) then
text = parameters.cost .. ' gp'
elseif table.maxn(parameters.items) 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 table.maxn(addoninfo.items) > 0 then
for i = 1, table.maxn(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 == table.maxn(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 cash!', cid)
end
npcHandler:resetNpc()
return true
elseif (parameters.decline == true) then
npcHandler:say('Not interested? Maybe another addon?', 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})

-- citizen (done)
local outfit_node = keywordHandler:addKeyword({'first addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, items = {}, outfit_female = 136, outfit_male = 128, addon = 1, storageID = 10001})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second citizen addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 136, outfit_male = 128, addon = 2, storageID = 10002})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- hunter (done)
local outfit_node = keywordHandler:addKeyword({'first hunter addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 137, outfit_male = 129, addon = 1, storageID = 10003})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second hunter addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 137, outfit_male = 129, addon = 2, storageID = 10004})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- knight (done)
local outfit_node = keywordHandler:addKeyword({'first knight addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 139, outfit_male = 131, addon = 1, storageID = 10005})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second knight addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 139, outfit_male = 131, addon = 2, storageID = 10006})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- mage (done)
local outfit_node = keywordHandler:addKeyword({'first mage addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 138, outfit_male = 130, addon = 1, storageID = 10007})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second mage addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 138, outfit_male = 130, addon = 2, storageID = 10008})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)


-- summoner (done)
local outfit_node = keywordHandler:addKeyword({'first summoner addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 141, outfit_male = 133, addon = 1, storageID = 10009})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second summoner addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 141, outfit_male = 133, addon = 2, storageID = 10010})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)


-- barbarian (done)
local outfit_node = keywordHandler:addKeyword({'first barbarian addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 147, outfit_male = 143, addon = 1, storageID = 10011})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second barbarian addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 147, outfit_male = 143, addon = 2, storageID = 10012})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- druid (done)
local outfit_node = keywordHandler:addKeyword({'first druid addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 148, outfit_male = 144, addon = 1, storageID = 10013})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second druid addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 148, outfit_male = 144, addon = 2, storageID = 10014})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- nobleman (done)
local outfit_node = keywordHandler:addKeyword({'first nobleman addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, items = {}, outfit_female = 140, outfit_male = 132, addon = 1, storageID = 10015})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second nobleman addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, items = {}, outfit_female = 140, outfit_male = 132, addon = 2, storageID = 10016})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- oriental (done)
local outfit_node = keywordHandler:addKeyword({'first oriental addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 150, outfit_male = 146, addon = 1, storageID = 10017})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second oriental addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 150, outfit_male = 146, addon = 2, storageID = 10018})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- warrior (done)
local outfit_node = keywordHandler:addKeyword({'first warrior addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 142, outfit_male = 134, addon = 1, storageID = 10019})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second warrior addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 142, outfit_male = 134, addon = 2, storageID = 10020})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- wizard (done)
local outfit_node = keywordHandler:addKeyword({'first wizard addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 149, outfit_male = 145, addon = 1, storageID = 10021})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second wizard addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 149, outfit_male = 145, addon = 2, storageID = 10022})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- assassin (done)
local outfit_node = keywordHandler:addKeyword({'first assassin addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 156, outfit_male = 152, addon = 1, storageID = 10023})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second assassin addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 156, outfit_male = 152, addon = 2, storageID = 10024})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- beggar (done)
local outfit_node = keywordHandler:addKeyword({'first beggar addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 157, outfit_male = 153, addon = 1, storageID = 10025})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second beggar addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 157, outfit_male = 153, addon = 2, storageID = 10026})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- pirate (done)
local outfit_node = keywordHandler:addKeyword({'first pirate addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 155, outfit_male = 151, addon = 1, storageID = 10027})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second pirate addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 155, outfit_male = 151, addon = 2, storageID = 10028})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- shaman (done)
local outfit_node = keywordHandler:addKeyword({'first shaman addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 158, outfit_male = 154, addon = 1, storageID = 10029})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second shaman addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 158, outfit_male = 154, addon = 2, storageID = 10030})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- norseman (done)
local outfit_node = keywordHandler:addKeyword({'first norseman addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 252, outfit_male = 251, addon = 1, storageID = 10031})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second norseman addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 252, outfit_male = 251, addon = 2, storageID = 10032})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- jester (done)(custom)
local outfit_node = keywordHandler:addKeyword({'first jester addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 270, outfit_male = 273, addon = 1, storageID = 10033})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second jester addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 270, outfit_male = 273, addon = 2, storageID = 10034})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- demonhunter (done)(custom)
local outfit_node = keywordHandler:addKeyword({'first demonhunter addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 288, outfit_male = 289, addon = 1, storageID = 10035})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second demonhunter addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 288, outfit_male = 289, addon = 2, storageID = 10036})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- nightmare (done)(custom)
local outfit_node = keywordHandler:addKeyword({'first nightmare addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 269, outfit_male = 268, addon = 1, storageID = 10037})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second nightmare addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 269, outfit_male = 268, addon = 2, storageID = 10038})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- brotherhood (done)(custom)
local outfit_node = keywordHandler:addKeyword({'first brotherhood addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 279, outfit_male = 278, addon = 1, storageID = 10039})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second brotherhood addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 279, outfit_male = 278, addon = 2, storageID = 10040})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- yalaharian (done)(custom)
local outfit_node = keywordHandler:addKeyword({'first yalaharian addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 324, outfit_male = 325, addon = 1, storageID = 10041})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second yalaharian addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 324, outfit_male = 325, addon = 2, storageID = 10042})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- Warmaster (done)(custom)
local outfit_node = keywordHandler:addKeyword({'first warmaster addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 336, outfit_male = 335, addon = 1, storageID = 10043})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second warmaster addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 336, outfit_male = 335, addon = 2, storageID = 10044})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

-- Wayfarer (done)(custom)
local outfit_node = keywordHandler:addKeyword({'first Wayfarer addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 366, outfit_male = 367, addon = 1, storageID = 10045})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
local outfit_node = keywordHandler:addKeyword({'second Wayfarer addon'}, playerBuyAddonNPC, {premium = false, cost = 100000, items = {}, outfit_female = 366, outfit_male = 367, addon = 2, storageID = 10046})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)


keywordHandler:addKeyword({'addons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can give you citizen, hunter, knight, mage, nobleman, summoner, warrior, barbarian, druid, wizard, oriental, pirate, assassin, beggar, shaman, norseman, nighmare, jester, yalaharian, brotherhood, warmaster and wayfarer addons.'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To buy the first addon say \'first NAME addon\', for the second addon say \'second NAME addon\'.'})

npcHandler:addModule(FocusModule:new())

I like

Link para o post
Compartilhar em outros sites

addoner.lua (data/npc/scripts):

local tab = {
prices = {500000, 1000000} -- {first, second}
}

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

function buyAddons(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

        local addon = parameters.addon
        local cost = parameters.cost
        local premium = (parameters.premium ~= nil and parameters.premium)
        if isPlayerPremiumCallback == nil or (isPlayerPremiumCallback(cid) and premium) then
            if doPlayerRemoveMoney(cid, cost) == true then
                doPlayerAddAddons(cid, addon)
                npcHandler:say('There, you are now able to use all addons!', cid)
            else
                npcHandler:say('Sorry, you do not have enough money.', cid)
            end
        else
            npcHandler:say('I only serve customers with premium accounts.', cid)
        end

    keywordHandler:moveUp(1)
    return true
end

local node1 = keywordHandler:addKeyword({'first addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first addons set for '..tab.prices[1]..' gold coins?'})
    node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = tab.prices[1], premium = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for '..tab.prices[2]..' gold coins?'})
    node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = tab.prices[2], premium = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell the first addons set for '..tab.prices[1]..' gold coins and the second addons set for '..tab.prices[2]..' gold coins.'})

npcHandler:addModule(FocusModule:new())




Addoner.xml (data/npc):

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Addoner" script="data/npc/scripts/addoner.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
</npc>
Editado por Suicide (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

Link para o post
Compartilhar em outros sites

 

addoner.lua (data/npc/scripts):

local tab = {
prices = {500000, 1000000} -- {first, second}
}

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

function buyAddons(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
        return false
    end

        local addon = parameters.addon
        local cost = parameters.cost
        local premium = (parameters.premium ~= nil and parameters.premium)
        if isPlayerPremiumCallback == nil or (isPlayerPremiumCallback(cid) and premium) then
            if doPlayerRemoveMoney(cid, cost) == true then
                doPlayerAddAddons(cid, addon)
                npcHandler:say('There, you are now able to use all addons!', cid)
            else
                npcHandler:say('Sorry, you do not have enough money.', cid)
            end
        else
            npcHandler:say('I only serve customers with premium accounts.', cid)
        end

    keywordHandler:moveUp(1)
    return true
end

local node1 = keywordHandler:addKeyword({'first addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first addons set for '..tab.prices[1]..' gold coins?'})
    node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = tab.prices[1], premium = true})
    node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for '..tab.prices[2]..' gold coins?'})
    node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = tab.prices[2], premium = true})
    node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})

keywordHandler:addKeyword({'addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell the first addons set for '..tab.prices[1]..' gold coins and the second addons set for '..tab.prices[2]..' gold coins.'})

npcHandler:addModule(FocusModule:new())

Addoner.xml (data/npc):

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Addoner" script="data/npc/scripts/addoner.lua" walkinterval="2000" floorchange="0">
	<health now="100" max="100"/>
	<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
</npc>

ta bugado eu compro todas primeiras addon dinheiro some mais n da os addon :(

I like

Link para o post
Compartilhar em outros sites

Mesmo Processo acima, em crie um arquivo chamado addons.lua cole isto (data/npc/scripts):

 

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
 
function buyAddons(cid, message, keywords, parameters, node)
--TODO: buyAddons function in modules.lua
if(not npcHandler:isFocused(cid)) then
return false
end
 
local addon = parameters.addon
local cost = parameters.cost
local premium = (parameters.premium ~= nil and parameters.premium)
 
if isPlayerPremiumCallback == nil or (isPlayerPremiumCallback(cid) and premium) then
if doPlayerRemoveMoney(cid, cost) == TRUE then
doPlayerAddAddons(cid, addon)
npcHandler:say('There, you are now able to use all addons!', cid)
else
npcHandler:say('Sorry, you do not have enough money.', cid)
end
else
npcHandler:say('I only serve customers with premium accounts.', cid)
end
 
keywordHandler:moveUp(1)
return true
end
 
local node1 = keywordHandler:addKeyword({'first addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to buy the first addons set for 500000 gold coins?'})
node1:addChildKeyword({'yes'}, buyAddons, {addon = 1, cost = 500000, premium = true})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})
 
local node2 = keywordHandler:addKeyword({'second addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Would you like to buy the second addons set for 1000000 gold coins?'})
node2:addChildKeyword({'yes'}, buyAddons, {addon = 2, cost = 1000000, premium = true})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Too expensive, eh?'})
 
keywordHandler:addKeyword({'addon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell the first addons set for 500000 gold coins and the second addons set for 1000000 gold coins.'})
 
npcHandler:addModule(FocusModule:new())
 
Crie um arquivo chamado Addon Seller.xml (data/npc):

 

<?xml version="1.0" encoding="UTF-8"?>

<npc name="Addon Seller" script="data/npc/scripts/addons.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
</npc>
Editado por eviltox (veja o histórico de edições)

                                                                                                230x230.jpg

 

Link para o post
Compartilhar em outros sites

Mesmo Processo acima, em addons.lua cole isto:

Amigo, você postou um script quase exatamente igual ao meu, além de que nem fez questão de modificar os valores do custo de cada parâmetro do NPC. Como acha que vai mudar o resultado?

 

ta bugado eu compro todas primeiras addon dinheiro some mais n da os addon :(

Está tudo certo. Fiz outro:

local tab = {
prices = {500000, 1000000} -- {first, second}
}

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

function creatureSayCallback(cid, type, msg)
    if (not npcHandler:isFocused(cid)) then
        return false
    end
	
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

npcHandler:setMessage(MESSAGE_GREET, 'Hi |PLAYERNAME|. I sell the {first addons} set for '..tab.prices[1]..' gold coins and the {second addons} set for '..tab.prices[2]..' gold coins.')

	if (msgcontains(msg, 'first addons')) then
		talkState[talkUser] = 1
		selfSay('Are you sure?', cid)
	elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if (doPlayerRemoveMoney(cid, tab.prices[1]) == true) then
			talkState[talkUser] = 0
			doPlayerAddAddons(cid, 1)
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			selfSay('Here you are.', cid)
		else
			talkState[talkUser] = 0
			selfSay('Sorry, you do not have enough money.', cid)
		end
	elseif (msgcontains(msg, 'second addons')) then
		talkState[talkUser] = 2
		selfSay('Are you sure?', cid)
	elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
		if (doPlayerRemoveMoney(cid, tab.prices[2]) == true) then
			talkState[talkUser] = 0
			doPlayerAddAddons(cid, 2)
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			selfSay('Here you are.', cid)
		else
			talkState[talkUser] = 0
			selfSay('Sorry, you do not have enough money.', cid)
		end
	elseif (msgcontains(msg, 'no')) then
		talkState[talkUser] = 0
		selfSay('Okay, goodbye!', cid)
	end
		
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Se ainda não der certo enquanto ao player receber os addons, verifique se você tem a função doPlayerAddAddons em sua 050-function.lua. É uma possibilidade pra esse problema, e não se esqueça de reportar erros no distro (caso tenha).

Editado por Suicide (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

Link para o post
Compartilhar em outros sites

Pronto cara, sem perder a calma kkkkkk, só quis ajudar. 

Enfim, eu Editei o post, e não eu não copiei ou aproveitei nada do seu script '-' 

                                                                                                230x230.jpg

 

Link para o post
Compartilhar em outros sites

@eviltox
Relaxa, eu estou calmo. Só quero dizer que não vejo mudança alguma no resultado do script que você postou, por ter as funções praticamente idênticas as do meu, que não deu certo no servidor dele.

The corrupt fear us.

The honest support us.

The heroic join us.

Link para o post
Compartilhar em outros sites

Amigo, você postou um script quase exatamente igual ao meu, além de que nem fez questão de modificar os valores do custo de cada parâmetro do NPC. Como acha que vai mudar o resultado?

 

Está tudo certo. Fiz outro:

local tab = {
prices = {500000, 1000000} -- {first, second}
}

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

function creatureSayCallback(cid, type, msg)
    if (not npcHandler:isFocused(cid)) then
        return false
    end
	
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

npcHandler:setMessage(MESSAGE_GREET, 'Hi |PLAYERNAME|. I sell the {first addons} set for '..tab.prices[1]..' gold coins and the {second addons} set for '..tab.prices[2]..' gold coins.')

	if (msgcontains(msg, 'first addons')) then
		talkState[talkUser] = 1
		selfSay('Are you sure?', cid)
	elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if (doPlayerRemoveMoney(cid, tab.prices[1]) == true) then
			talkState[talkUser] = 0
			doPlayerAddAddons(cid, 1)
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			selfSay('Here you are.', cid)
		else
			talkState[talkUser] = 0
			selfSay('Sorry, you do not have enough money.', cid)
		end
	elseif (msgcontains(msg, 'second addons')) then
		talkState[talkUser] = 2
		selfSay('Are you sure?', cid)
	elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
		if (doPlayerRemoveMoney(cid, tab.prices[2]) == true) then
			talkState[talkUser] = 0
			doPlayerAddAddons(cid, 2)
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			selfSay('Here you are.', cid)
		else
			talkState[talkUser] = 0
			selfSay('Sorry, you do not have enough money.', cid)
		end
	elseif (msgcontains(msg, 'no') then
		talkState[talkUser] = 0
		selfSay('Okay, goodbye!', cid)
	end
		
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Se ainda não der certo enquanto ao player receber os addons, verifique se você tem a função doPlayerAddAddons em sua 050-function.lua. É uma possibilidade pra esse problema, e não se esqueça de reportar erros no distro (caso tenha).

[Error - LuaInterface::loadFile] data/npc/scripts/addons.lua:50: ')' expected near 'then'

deu esse erro amigo

I like

Link para o post
Compartilhar em outros sites

E o que eu postei? Deu algum erro?

                                                                                                230x230.jpg

 

Link para o post
Compartilhar em outros sites

[Error - LuaInterface::loadFile] data/npc/scripts/addons.lua:50: ')' expected near 'then'


Uma desatenção minha, desculpe:
 
local tab = {
prices = {500000, 1000000} -- {first, second}
}

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

function creatureSayCallback(cid, type, msg)
    if (not npcHandler:isFocused(cid)) then
        return false
    end
	
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

npcHandler:setMessage(MESSAGE_GREET, 'Hi |PLAYERNAME|. I sell the {first addons} set for '..tab.prices[1]..' gold coins and the {second addons} set for '..tab.prices[2]..' gold coins.')

	if(msgcontains(msg, 'first addons')) then
		talkState[talkUser] = 1
		selfSay('Are you sure?', cid)
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(doPlayerRemoveMoney(cid, tab.prices[1]) == true) then
			talkState[talkUser] = 0
			doPlayerAddAddons(cid, 1)
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			selfSay('Here you are.', cid)
		else
			talkState[talkUser] = 0
			selfSay('Sorry, you do not have enough money.', cid)
		end
	elseif(msgcontains(msg, 'second addons')) then
		talkState[talkUser] = 2
		selfSay('Are you sure?', cid)
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
		if(doPlayerRemoveMoney(cid, tab.prices[2]) == true) then
			talkState[talkUser] = 0
			doPlayerAddAddons(cid, 2)
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			selfSay('Here you are.', cid)
		else
			talkState[talkUser] = 0
			selfSay('Sorry, you do not have enough money.', cid)
		end
	elseif(msgcontains(msg, 'no')) then
		talkState[talkUser] = 0
		selfSay('Okay, goodbye!', cid)
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

The corrupt fear us.

The honest support us.

The heroic join us.

Link para o post
Compartilhar em outros sites

Uma desatenção minha, desculpe:

 

local tab = {
prices = {500000, 1000000} -- {first, second}
}

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

function creatureSayCallback(cid, type, msg)
    if (not npcHandler:isFocused(cid)) then
        return false
    end
	
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

npcHandler:setMessage(MESSAGE_GREET, 'Hi |PLAYERNAME|. I sell the {first addons} set for '..tab.prices[1]..' gold coins and the {second addons} set for '..tab.prices[2]..' gold coins.')

	if(msgcontains(msg, 'first addons')) then
		talkState[talkUser] = 1
		selfSay('Are you sure?', cid)
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(doPlayerRemoveMoney(cid, tab.prices[1]) == true) then
			talkState[talkUser] = 0
			doPlayerAddAddons(cid, 1)
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			selfSay('Here you are.', cid)
		else
			talkState[talkUser] = 0
			selfSay('Sorry, you do not have enough money.', cid)
		end
	elseif(msgcontains(msg, 'second addons')) then
		talkState[talkUser] = 2
		selfSay('Are you sure?', cid)
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
		if(doPlayerRemoveMoney(cid, tab.prices[2]) == true) then
			talkState[talkUser] = 0
			doPlayerAddAddons(cid, 2)
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			selfSay('Here you are.', cid)
		else
			talkState[talkUser] = 0
			selfSay('Sorry, you do not have enough money.', cid)
		end
	elseif(msgcontains(msg, 'no')) then
		talkState[talkUser] = 0
		selfSay('Okay, goodbye!', cid)
	end
	return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

dinheiro some mais n aparece as addon :(

eu olhei aqui nas libs que tinha tag doPlayerAddAddons em  050-function.lua olhei na source, unico script que funfa e aquele primeiro que postei quero modificar ele para ficar como fist todas as primeiras addons second para todas segundas..

jW9uuTV.png

Editado por loreal (veja o histórico de edições)

I like

Link para o post
Compartilhar em outros sites

Certo..

addoner.lua
[script removido]

Editado por Suicide (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

Link para o post
Compartilhar em outros sites

 

Certo..

addoner.lua

local tab = {
prices = {500000, 1000000} -- {first, second}
}

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

function creatureSayCallback(cid, type, msg)
    if (not npcHandler:isFocused(cid)) then
        return false
    end
    
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

npcHandler:setMessage(MESSAGE_GREET, 'Hi |PLAYERNAME|. I sell the {first addons} set for '..tab.prices[1]..' gold coins and the {second addons} set for '..tab.prices[2]..' gold coins.')

    local outfits = {
        [0] = {136, 137, 138, 139, 140, 141, 142, 147, 148, 149, 150, 155, 156, 157, 158, 252, 269, 270, 279, 288, 324, 336, 366},
        [1] = {128, 129, 130, 131, 132, 133, 134, 143, 144, 145, 146, 151, 152, 153, 154, 251, 268, 273, 278, 289, 325, 335, 367}
    }
    
    for x = 1, table.maxn(tab[getPlayerSex(cid)]) do
        if(msgcontains(msg, 'first addons')) then
            talkState[talkUser] = 1
            selfSay('Are you sure?', cid)
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
            if(doPlayerRemoveMoney(cid, tab.prices[1]) == true) then
                talkState[talkUser] = 0
                doPlayerAddOutfit(cid, outfits[getPlayerSex][x], 1)
                doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
                selfSay('Here you are.', cid)
            else
                talkState[talkUser] = 0
                selfSay('Sorry, you do not have enough money.', cid)
            end
        elseif(msgcontains(msg, 'second addons')) then
            talkState[talkUser] = 2
            selfSay('Are you sure?', cid)
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
            if(doPlayerRemoveMoney(cid, tab.prices[2]) == true) then
                talkState[talkUser] = 0
                doPlayerAddOutfit(cid, outfits[getPlayerSex][x], 2)
                doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
                selfSay('Here you are.', cid)
            else
                talkState[talkUser] = 0
                selfSay('Sorry, you do not have enough money.', cid)
            end
        elseif(msgcontains(msg, 'no')) then
            talkState[talkUser] = 0
            selfSay('Okay, goodbye!', cid)
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
[Error - NpcScript Interface]
data/npc/scripts/addons.lua:onCreatureSay
Description:
data/npc/scripts/addons.lua:29: bad argument #1 to 'maxn' (table expected, got nil)
stack traceback:
        [C]: in function 'maxn'
        data/npc/scripts/addons.lua:29: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:456: in function 'onCreatureSay'
        data/npc/scripts/addons.lua:12: in function <data/npc/scripts/addons.lua:12>

I like

Link para o post
Compartilhar em outros sites

Não precisa ficar fazendo quote do meu post, vai prolongar demais o tópico ;s
Mas enfim, coloquei o nome da tabela errada..falta de atenção minha:
[script removido]

Editado por Suicide (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

Link para o post
Compartilhar em outros sites

 

Não precisa ficar fazendo quote do meu post, vai prolongar demais o tópico ;s

Mas enfim, coloquei o nome da tabela errada..falta de atenção minha:

local tab = {
prices = {500000, 1000000} -- {first, second}
}

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

function creatureSayCallback(cid, type, msg)
    if (not npcHandler:isFocused(cid)) then
        return false
    end
    
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

npcHandler:setMessage(MESSAGE_GREET, 'Hi |PLAYERNAME|. I sell the {first addons} set for '..tab.prices[1]..' gold coins and the {second addons} set for '..tab.prices[2]..' gold coins.')

    local outfits = {
        [0] = {136, 137, 138, 139, 140, 141, 142, 147, 148, 149, 150, 155, 156, 157, 158, 252, 269, 270, 279, 288, 324, 336, 366},
        [1] = {128, 129, 130, 131, 132, 133, 134, 143, 144, 145, 146, 151, 152, 153, 154, 251, 268, 273, 278, 289, 325, 335, 367}
    }
    
    for x = 1, table.maxn(outfits[getPlayerSex(cid)]) do
        if(msgcontains(msg, 'first addons')) then
            talkState[talkUser] = 1
            selfSay('Are you sure?', cid)
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
            if(doPlayerRemoveMoney(cid, tab.prices[1]) == true) then
                talkState[talkUser] = 0
                doPlayerAddOutfit(cid, outfits[getPlayerSex][x], 1)
                doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
                selfSay('Here you are.', cid)
            else
                talkState[talkUser] = 0
                selfSay('Sorry, you do not have enough money.', cid)
            end
        elseif(msgcontains(msg, 'second addons')) then
            talkState[talkUser] = 2
            selfSay('Are you sure?', cid)
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
            if(doPlayerRemoveMoney(cid, tab.prices[2]) == true) then
                talkState[talkUser] = 0
                doPlayerAddOutfit(cid, outfits[getPlayerSex][x], 2)
                doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
                selfSay('Here you are.', cid)
            else
                talkState[talkUser] = 0
                selfSay('Sorry, you do not have enough money.', cid)
            end
        elseif(msgcontains(msg, 'no')) then
            talkState[talkUser] = 0
            selfSay('Okay, goodbye!', cid)
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

deu esse erro 

HcYmVgI.png

I like

Link para o post
Compartilhar em outros sites
deu esse erro HcYmVgI.png

Cada erro ridículo que estou fazendo.

Falta de atenção minha, fiz esse script as 05 da manhã.

Enfim, agora deve dar certo:

[script removido]

 

Desculpa pela falta de atenção.

Muito sono..

Editado por Suicide (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

Link para o post
Compartilhar em outros sites

Cada erro ridículo que estou fazendo.

Falta de atenção minha, fiz esse script as 05 da manhã.

Enfim, agora deve dar certo:

local tab = {
prices = {500000, 1000000} -- {first, second}
}

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

function creatureSayCallback(cid, type, msg)
    if (not npcHandler:isFocused(cid)) then
        return false
    end
    
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid

npcHandler:setMessage(MESSAGE_GREET, 'Hi |PLAYERNAME|. I sell the {first addons} set for '..tab.prices[1]..' gold coins and the {second addons} set for '..tab.prices[2]..' gold coins.')

    local outfits = {
        [0] = {136, 137, 138, 139, 140, 141, 142, 147, 148, 149, 150, 155, 156, 157, 158, 252, 269, 270, 279, 288, 324, 336, 366},
        [1] = {128, 129, 130, 131, 132, 133, 134, 143, 144, 145, 146, 151, 152, 153, 154, 251, 268, 273, 278, 289, 325, 335, 367}
    }
    
    for x = 1, table.maxn(outfits[getPlayerSex(cid)]) do
        if(msgcontains(msg, 'first addons')) then
            talkState[talkUser] = 1
            selfSay('Are you sure?', cid)
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
            if(doPlayerRemoveMoney(cid, tab.prices[1]) == true) then
                talkState[talkUser] = 0
                doPlayerAddOutfit(cid, outfits[getPlayerSex(cid)][x], 1)
                doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
                selfSay('Here you are.', cid)
            else
                talkState[talkUser] = 0
                selfSay('Sorry, you do not have enough money.', cid)
            end
        elseif(msgcontains(msg, 'second addons')) then
            talkState[talkUser] = 2
            selfSay('Are you sure?', cid)
        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
            if(doPlayerRemoveMoney(cid, tab.prices[2]) == true) then
                talkState[talkUser] = 0
                doPlayerAddOutfit(cid, outfits[getPlayerSex(cid)][x], 2)
                doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
                selfSay('Here you are.', cid)
            else
                talkState[talkUser] = 0
                selfSay('Sorry, you do not have enough money.', cid)
            end
        elseif(msgcontains(msg, 'no')) then
            talkState[talkUser] = 0
            selfSay('Okay, goodbye!', cid)
        end
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Desculpa pela falta de atenção.

Muito sono..

 

agora funfo so tem um problema so deu a citizen as outras n 

 

Im9eIPO.png

 

------------------------------------------------------------------------------------------------------------------------------------

ydsC7ws.png

I like

Link para o post
Compartilhar em outros sites

É, esse script que eu fiz de madrugada não foi muito lógico.
Refiz tudo agora:

addoner.lua

local prices = {500000, 1000000} -- {first, second}

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

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 outfits = {
        [0] = {136, 137, 138, 139, 140, 141, 142, 147, 148, 149, 150, 155, 156, 157, 158, 252, 269, 270, 279, 288, 324, 336, 366},
        [1] = {128, 129, 130, 131, 132, 133, 134, 143, 144, 145, 146, 151, 152, 153, 154, 251, 268, 273, 278, 289, 325, 335, 367}
    }
    
    if(msgcontains(msg, 'first addons')) then
        talkState[talkUser] = 1
        selfSay('Are you sure?', cid)
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if(doPlayerRemoveMoney(cid, prices[1]) == true) then
            for x = 1, (#outfits[getPlayerSex(cid)]) do
                talkState[talkUser] = 0
                doPlayerAddOutfit(cid, outfits[getPlayerSex(cid)][x], 1)
                doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
            end
            selfSay('Here you are.', cid)
        else
            talkState[talkUser] = 0
            selfSay('Sorry, you need '..prices[1]..' gold coins to buy this addons.', cid)
        end
    elseif(msgcontains(msg, 'second addons')) then
        talkState[talkUser] = 2
        selfSay('Are you sure?', cid)
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2) then
        if(doPlayerRemoveMoney(cid, prices[2]) == true) then
            for x = 1, (#outfits[getPlayerSex(cid)]) do
                talkState[talkUser] = 0
                doPlayerAddOutfit(cid, outfits[getPlayerSex(cid)][x], 2)
                doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
            end
            selfSay('Here you are.', cid)
        else
            talkState[talkUser] = 0
            selfSay('Sorry, you need '..prices[2]..' gold coins to buy this addons.', cid)
        end
    elseif(msgcontains(msg, 'no')) then
            talkState[talkUser] = 0
            selfSay('Okay, goodbye!', cid)
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())




Addoner.xml

<npc name="Addoner" script="data/npc/scripts/addoner.lua" access="5" lookdir="1">
<health now="1000" max="1000"/>
<look type="133" head="39" body="113" legs="38" feet="0" addons="3"/>
	<parameters>
		<parameter key="message_greet" value="Hi |PLAYERNAME|. I sell the {first addons} and the {second addons}." />
	</parameters>
</npc>
Editado por Suicide (veja o histórico de edições)

The corrupt fear us.

The honest support us.

The heroic join us.

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo