Ir para conteúdo

Featured Replies

Postado
  • Autor

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

  • Respostas 17
  • Visualizações 1.4k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • 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á

  • 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..

  • É, 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 np

Postado
  • Autor

 

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

Postado

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.

Postado
  • Autor

 

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

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo