EM
pedido scripts

(Ajuda) Arruma esse script

Por Emooooo, 22 de ago. de 2018 em Scripts

7
2.6k
EmoooooE
22 de agosto de 2018 às 10:54

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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local player = Player(cid)
 
    if player:getLevel() < 30 then
        blessprize = 2000*6
    elseif player:getLevel() >= 30 and player:getLevel() <= 120 then
        blessprize = (((player:getLevel()-30)*200)+2000)*6
    elseif player:getLevel() > 120 then
        blessprize = 20000*6
    end
 
 
    if(msgcontains(msg, "blessing") or msgcontains(msg, "bless")) then
            npcHandler:say("Do you want to receive all blessings for "..blessprize.." gold?", cid)
            npcHandler.topic[cid] = 1
    end
    if(msgcontains(msg, "yes")) then
        if(npcHandler.topic[cid] == 1) then
            if player:hasBlessing(1) or player:hasBlessing(2) or player:hasBlessing(3) or player:hasBlessing(4) or player:hasBlessing(5) or player:hasBlessing(6) then
                npcHandler:say("You already have been blessed!", cid)
            else
                if player:removeMoney(blessprize) then
                    npcHandler:say("You have been blessed by all of six gods!, " .. player:getName() .. ".", cid)
                    player:addBlessing(1)
                    player:addBlessing(2)
                    player:addBlessing(3)
                    player:addBlessing(4)
                    player:addBlessing(5)
                    player:addBlessing(6)
                    player:getPosition():sendMagicEffect(CONST_ME_HOLYAREA)
                    npcHandler.topic[cid] = 0
                else
                    npcHandler:say("Come back when you have enough money.", cid)
                    npcHandler.topic[cid] = 0
                end
            end
        end
    end
    if(msgcontains(msg, "no")) then
        if(npcHandler.topic[cid] == 1) then
            npcHandler:say("Then no.", cid)
            npcHandler.topic[cid] = 0
        end
    end
    if msgcontains(msg, "heal") then
        npcHandler:say("Do you need the healing now?", cid)
        npcHandler.topic[cid] = 2
    elseif(npcHandler.topic[cid] == 2) then
        if msgcontains(msg, "no") then
            npcHandler:say("As you wish.", cid)
            npcHandler.topic[cid] = 0
        elseif msgcontains(msg, "yes") then
            npcHandler:say("So be healed!", cid)
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
            doSendMagicEffect(getNpcPos(), CONST_ME_MAGIC_BLUE)
            npcHandler.topic[cid] = 0
        end
    end
    return true
end
 
npcHandler:setMessage(MESSAGE_GREET, "Greetings, fellow believer |PLAYERNAME|. I can offer you {blessings} or a free {heal}!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Always be on guard, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "This ungraceful haste is most suspicious!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

 

<< ta dando esse erro >>

 

 

[22/8/2018 10:51:5] [Error - NpcScript Interface] 
[22/8/2018 10:51:5] data/npc/scripts/alia.lua:onCreatureSay
[22/8/2018 10:51:5] Description: 
[22/8/2018 10:51:5] data/npc/scripts/alia.lua:14: attempt to call global 'Player' (a nil value)
[22/8/2018 10:51:5] stack traceback:
[22/8/2018 10:51:5]     data/npc/scripts/alia.lua:14: in function 'callback'
[22/8/2018 10:51:5]     data/npc/lib/npcsystem/npchandler.lua:456: in function 'onCreatureSay'
[22/8/2018 10:51:5]     data/npc/scripts/alia.lua:7: in function <data/npc/scripts/alia.lua:7>

 

 

GengoG
22 de agosto de 2018 às 12:43

Mano seu código não esta errado, é sua versão de tfs, o script está na versão 1.x+ e sua tfs deve ser inferior.

EmoooooE
22 de agosto de 2018 às 14:27
1 hora atrás, luis700 disse:

Mano seu código não esta errado, é sua versão de tfs, o script está na versão 1.x+ e sua tfs deve ser inferior.

tem como fazer uma assim pro meu tfs?

GengoG
22 de agosto de 2018 às 15:13
Spoiler
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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    if getPlayerLevel(cid) < 30 then
        blessprize = 2000*6
    elseif getPlayerLevel(cid) >= 30 and getPlayerLevel(cid) <= 120 then
        blessprize = (((getPlayerLevel(cid)-30)*200)+2000)*6
    elseif getPlayerLevel(cid) > 120 then
        blessprize = 20000*6
    end
 
 
    if(msgcontains(msg, "blessing") or msgcontains(msg, "bless")) then
            npcHandler:say("Do you want to receive all blessings for "..blessprize.." gold?", cid)
            npcHandler.topic[cid] = 1
    end
    if(msgcontains(msg, "yes")) then
        if(npcHandler.topic[cid] == 1) then
            if getPlayerBlessing(cid, 1) or getPlayerBlessing(cid, 2) or getPlayerBlessing(cid, 3) or getPlayerBlessing(cid, 4) or getPlayerBlessing(cid, 5) or getPlayerBlessing(cid, 6) then
                npcHandler:say("You already have been blessed!", cid)
            else
                if doPlayerRemoveMoney(cid, blessprize) then
                    npcHandler:say("You have been blessed by all of six gods!, " .. getPlayerName(cid) .. ".", cid)
                    getPlayerBlessing(cid, 1)
                    getPlayerBlessing(cid, 2)
                    getPlayerBlessing(cid, 3)
                    getPlayerBlessing(cid, 4)
                    getPlayerBlessing(cid, 5)
                    getPlayerBlessing(cid, 6)
					doSendMagicEffect(getPlayerPosition(cid),CONST_ME_HOLYAREA)
                    npcHandler.topic[cid] = 0
                else
                    npcHandler:say("Come back when you have enough money.", cid)
                    npcHandler.topic[cid] = 0
                end
            end
        end
    end
    if(msgcontains(msg, "no")) then
        if(npcHandler.topic[cid] == 1) then
            npcHandler:say("Then no.", cid)
            npcHandler.topic[cid] = 0
        end
    end
    if msgcontains(msg, "heal") then
        npcHandler:say("Do you need the healing now?", cid)
        npcHandler.topic[cid] = 2
    elseif(npcHandler.topic[cid] == 2) then
        if msgcontains(msg, "no") then
            npcHandler:say("As you wish.", cid)
            npcHandler.topic[cid] = 0
        elseif msgcontains(msg, "yes") then
            npcHandler:say("So be healed!", cid)
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
            doSendMagicEffect(getNpcPos(), CONST_ME_MAGIC_BLUE)
            npcHandler.topic[cid] = 0
        end
    end
    return true
end
 
npcHandler:setMessage(MESSAGE_GREET, "Greetings, fellow believer |PLAYERNAME|. I can offer you {blessings} or a free {heal}!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Always be on guard, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "This ungraceful haste is most suspicious!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Qualquer erro no código é só falar.

EmoooooE
22 de agosto de 2018 às 19:12
3 horas atrás, luis700 disse:
  Ocultar conteúdo

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 creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
 
    if getPlayerLevel(cid) < 30 then
        blessprize = 2000*6
    elseif getPlayerLevel(cid) >= 30 and getPlayerLevel(cid) <= 120 then
        blessprize = (((getPlayerLevel(cid)-30)*200)+2000)*6
    elseif getPlayerLevel(cid) > 120 then
        blessprize = 20000*6
    end
 
 
    if(msgcontains(msg, "blessing") or msgcontains(msg, "bless")) then
            npcHandler:say("Do you want to receive all blessings for "..blessprize.." gold?", cid)
            npcHandler.topic[cid] = 1
    end
    if(msgcontains(msg, "yes")) then
        if(npcHandler.topic[cid] == 1) then
            if getPlayerBlessing(cid, 1) or getPlayerBlessing(cid, 2) or getPlayerBlessing(cid, 3) or getPlayerBlessing(cid, 4) or getPlayerBlessing(cid, 5) or getPlayerBlessing(cid, 6) then
                npcHandler:say("You already have been blessed!", cid)
            else
                if doPlayerRemoveMoney(cid, blessprize) then
                    npcHandler:say("You have been blessed by all of six gods!, " .. getPlayerName(cid) .. ".", cid)
                    getPlayerBlessing(cid, 1)
                    getPlayerBlessing(cid, 2)
                    getPlayerBlessing(cid, 3)
                    getPlayerBlessing(cid, 4)
                    getPlayerBlessing(cid, 5)
                    getPlayerBlessing(cid, 6)
					doSendMagicEffect(getPlayerPosition(cid),CONST_ME_HOLYAREA)
                    npcHandler.topic[cid] = 0
                else
                    npcHandler:say("Come back when you have enough money.", cid)
                    npcHandler.topic[cid] = 0
                end
            end
        end
    end
    if(msgcontains(msg, "no")) then
        if(npcHandler.topic[cid] == 1) then
            npcHandler:say("Then no.", cid)
            npcHandler.topic[cid] = 0
        end
    end
    if msgcontains(msg, "heal") then
        npcHandler:say("Do you need the healing now?", cid)
        npcHandler.topic[cid] = 2
    elseif(npcHandler.topic[cid] == 2) then
        if msgcontains(msg, "no") then
            npcHandler:say("As you wish.", cid)
            npcHandler.topic[cid] = 0
        elseif msgcontains(msg, "yes") then
            npcHandler:say("So be healed!", cid)
            doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
            doSendMagicEffect(getNpcPos(), CONST_ME_MAGIC_BLUE)
            npcHandler.topic[cid] = 0
        end
    end
    return true
end
 
npcHandler:setMessage(MESSAGE_GREET, "Greetings, fellow believer |PLAYERNAME|. I can offer you {blessings} or a free {heal}!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Always be on guard, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "This ungraceful haste is most suspicious!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Qualquer erro no código é só falar.

[22/8/2018 19:11:18] [Error - NpcScript Interface] 
[22/8/2018 19:11:18] data/npc/scripts/alia.lua:onCreatureSay
[22/8/2018 19:11:18] Description: 
[22/8/2018 19:11:18] data/npc/scripts/alia.lua:26: attempt to index field 'topic' (a nil value)
[22/8/2018 19:11:18] stack traceback:
[22/8/2018 19:11:18]     data/npc/scripts/alia.lua:26: in function 'callback'
[22/8/2018 19:11:18]     data/npc/lib/npcsystem/npchandler.lua:456: in function 'onCreatureSay'
[22/8/2018 19:11:18]     data/npc/scripts/alia.lua:7: in function <data/npc/scripts/alia.lua:7>

[22/8/2018 19:11:26] [Error - NpcScript Interface] 
[22/8/2018 19:11:26] data/npc/scripts/alia.lua:onCreatureSay
[22/8/2018 19:11:26] Description: 
[22/8/2018 19:11:26] data/npc/scripts/alia.lua:29: attempt to index field 'topic' (a nil value)
[22/8/2018 19:11:26] stack traceback:
[22/8/2018 19:11:26]     data/npc/scripts/alia.lua:29: in function 'callback'
[22/8/2018 19:11:26]     data/npc/lib/npcsystem/npchandler.lua:456: in function 'onCreatureSay'
[22/8/2018 19:11:26]     data/npc/scripts/alia.lua:7: in function <data/npc/scripts/alia.lua:7>
 

 

deu isso ae

GengoG
23 de agosto de 2018 às 10:06
14 horas atrás, Emooooo disse:

[22/8/2018 19:11:18] [Error - NpcScript Interface] 
[22/8/2018 19:11:18] data/npc/scripts/alia.lua:onCreatureSay
[22/8/2018 19:11:18] Description: 
[22/8/2018 19:11:18] data/npc/scripts/alia.lua:26: attempt to index field 'topic' (a nil value)
[22/8/2018 19:11:18] stack traceback:
[22/8/2018 19:11:18]     data/npc/scripts/alia.lua:26: in function 'callback'
[22/8/2018 19:11:18]     data/npc/lib/npcsystem/npchandler.lua:456: in function 'onCreatureSay'
[22/8/2018 19:11:18]     data/npc/scripts/alia.lua:7: in function <data/npc/scripts/alia.lua:7>

[22/8/2018 19:11:26] [Error - NpcScript Interface] 
[22/8/2018 19:11:26] data/npc/scripts/alia.lua:onCreatureSay
[22/8/2018 19:11:26] Description: 
[22/8/2018 19:11:26] data/npc/scripts/alia.lua:29: attempt to index field 'topic' (a nil value)
[22/8/2018 19:11:26] stack traceback:
[22/8/2018 19:11:26]     data/npc/scripts/alia.lua:29: in function 'callback'
[22/8/2018 19:11:26]     data/npc/lib/npcsystem/npchandler.lua:456: in function 'onCreatureSay'
[22/8/2018 19:11:26]     data/npc/scripts/alia.lua:7: in function <data/npc/scripts/alia.lua:7>
 

 

deu isso ae

Seu arquivo npcHandler.lua não tem esse topic, vou passar o meu npcHandler.lua ai você procura onde tem essa variavel topic e adiciona no seu.

 

Abra o arquivo no seu servidor data/npc/lib/ npchandler.lua e depois abra o arquivo que vou te passar e veja onde se encontra a variavel topic para que você adicione no seu arquivo, lembrando que não adianta você copiar tudo e colar no seu, pois como se trata de uma versão de tfs superior ao seu, copiando e colando tudo que há no arquivo não ira funcionar no seu, apenas veja se da certo no seu colocando esta variavel citada no seus devido lugar.

 

Meu arquivo para você comparar:  npchandler.lua

 

Se não resolver ai não vou conseguir te ajudar, não entendo muito as funcionalidades dos npc's

 

 

 

 

EmoooooE
23 de agosto de 2018 às 12:35

ok vo testa aqui obrigado