Ir para conteúdo
  • 0

ADICIONAR UM DETALHE NO SCRIPT DO NPC BLESS


4233693

Pergunta

Olá utilizo o GLOBR mapa global do tibia versao 8.6, eu estava com um problema na bless do meu server que quando a pessoa comprasse pelo comando !bless e morresse dps sem AOL, ela perdia todos os itens (como se fosse um pk red), entao procurei alguns outros scripts e todos estavam dando a mesma coisa, até q achei dessa pessoa que nao lembro quem foi, a bless desse npc funciona porém ele nao checa se a pessoa ja tem a bless antes de vender, por exemplo: a pessoa consegue comprar a bless varias vezes, eu gostaria que alguem pudesse adicionar uma tipo de checagem para o npc dizer "Sorry, you already have all the blesses". Acima vai estar o codigo dele. Obg

Editado por 4233693
Link para o comentário
Compartilhar em outros sites

4 respostass a esta questão

Posts Recomendados

  • 1
Spoiler

local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end
 
local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end
 
local price = 50000 -- Valor da bless
local haveBless = getPlayerBlessing(cid, parameters.number)
 
function onCreatureSay(cid, type, msg)
    if(not (isFocused(cid)) and (msg == "hi" or msg == "hello")) then
        selfSay("Welcome, ".. getCreatureName(cid) ..". I sell {blessing}.", cid)
        addFocus(cid)
    elseif((isFocused(cid)) and (msg == "bless" or msg == "blessing")) then
        selfSay("Would you like buying blessing per ".. (price) .." gold coins?", cid)
    elseif((isFocused(cid)) and (msg == "yes")) then
        if (haveBless) then
            selfSay("Sorry, you already have all the blesses.", cid)
        elseif((getPlayerMoney(cid) < price))
				selfSay("You don't have enough money.", cid)
			else
			selfSay("Alright.", cid)
            doPlayerRemoveMoney(cid, price)
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doPlayerAddBlessing(cid, 6)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYAREA)
        end
    elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Goodbye!", cid)
        closeShopWindow(cid)
        removeFocus(cid)
    end
end
 
function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Hey, where you going?")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end

 

testa ai e me fala

Editado por Developer Berg
Link para o comentário
Compartilhar em outros sites

  • 0
Em 17/02/2020 em 16:23, Developer Berg disse:
  Mostrar conteúdo oculto


local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end
 
local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end
 
local price = 50000 -- Valor da bless
local haveBless = getPlayerBlessing(cid, parameters.number)
 
function onCreatureSay(cid, type, msg)
    if(not (isFocused(cid)) and (msg == "hi" or msg == "hello")) then
        selfSay("Welcome, ".. getCreatureName(cid) ..". I sell {blessing}.", cid)
        addFocus(cid)
    elseif((isFocused(cid)) and (msg == "bless" or msg == "blessing")) then
        selfSay("Would you like buying blessing per ".. (price) .." gold coins?", cid)
    elseif((isFocused(cid)) and (msg == "yes")) then
        if (haveBless) then
            selfSay("Sorry, you already have all the blesses.", cid)
        elseif((getPlayerMoney(cid) < price))
				selfSay("You don't have enough money.", cid)
			else
			selfSay("Alright.", cid)
            doPlayerRemoveMoney(cid, price)
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doPlayerAddBlessing(cid, 6)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYAREA)
        end
    elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Goodbye!", cid)
        closeShopWindow(cid)
        removeFocus(cid)
    end
end
 
function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Hey, where you going?")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end

 

testa ai e me fala

[19/02/2020 02:28:41] [Error - LuaScriptInterface::loadFile] data/npc/scripts/Blessman.lua:47: 'then' expected near 'selfSay'
[19/02/2020 02:28:41] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Blessman.lua
[19/02/2020 02:28:41] data/npc/scripts/Blessman.lua:47: 'then' expected near 'selfSay'

Link para o comentário
Compartilhar em outros sites

  • 1
3 horas atrás, 4233693 disse:

[19/02/2020 02:28:41] [Error - LuaScriptInterface::loadFile] data/npc/scripts/Blessman.lua:47: 'then' expected near 'selfSay'
[19/02/2020 02:28:41] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Blessman.lua
[19/02/2020 02:28:41] data/npc/scripts/Blessman.lua:47: 'then' expected near 'selfSay'

Spoiler


local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end
 
local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end
 
local price = 50000 -- Valor da bless
local haveBless = getPlayerBlessing(cid, parameters.number)
 
function onCreatureSay(cid, type, msg)
    if(not (isFocused(cid)) and (msg == "hi" or msg == "hello")) then
        selfSay("Welcome, ".. getCreatureName(cid) ..". I sell {blessing}.", cid)
        addFocus(cid)
    elseif((isFocused(cid)) and (msg == "bless" or msg == "blessing")) then
        selfSay("Would you like buying blessing per ".. (price) .." gold coins?", cid)
    elseif((isFocused(cid)) and (msg == "yes")) then
        if (haveBless) then
            selfSay("Sorry, you already have all the blesses.", cid)
        elseif((getPlayerMoney(cid) < price)) then
				selfSay("You don't have enough money.", cid)
			else
			selfSay("Alright.", cid)
            doPlayerRemoveMoney(cid, price)
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doPlayerAddBlessing(cid, 6)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYAREA)
        end
    elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Goodbye!", cid)
        closeShopWindow(cid)
        removeFocus(cid)
    end
end
 
function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Hey, where you going?")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end

 

testa agr, esqueci um negocio.

Link para o comentário
Compartilhar em outros sites

  • 0
12 horas atrás, Developer Berg disse:
  Mostrar conteúdo oculto



local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end
 
local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end
 
local price = 50000 -- Valor da bless
local haveBless = getPlayerBlessing(cid, parameters.number)
 
function onCreatureSay(cid, type, msg)
    if(not (isFocused(cid)) and (msg == "hi" or msg == "hello")) then
        selfSay("Welcome, ".. getCreatureName(cid) ..". I sell {blessing}.", cid)
        addFocus(cid)
    elseif((isFocused(cid)) and (msg == "bless" or msg == "blessing")) then
        selfSay("Would you like buying blessing per ".. (price) .." gold coins?", cid)
    elseif((isFocused(cid)) and (msg == "yes")) then
        if (haveBless) then
            selfSay("Sorry, you already have all the blesses.", cid)
        elseif((getPlayerMoney(cid) < price)) then
				selfSay("You don't have enough money.", cid)
			else
			selfSay("Alright.", cid)
            doPlayerRemoveMoney(cid, price)
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doPlayerAddBlessing(cid, 6)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYAREA)
        end
    elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Goodbye!", cid)
        closeShopWindow(cid)
        removeFocus(cid)
    end
end
 
function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Hey, where you going?")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()
end

 

testa agr, esqueci um negocio.

[19/02/2020 18:12:58] [Error - Npc interface] 
[19/02/2020 18:12:58] data/npc/scripts/Blessman.lua
[19/02/2020 18:12:58] Description: 
[19/02/2020 18:12:58] data/npc/scripts/Blessman.lua:35: attempt to index global 'parameters' (a nil value)
[19/02/2020 18:12:58] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Blessman.lua

4 horas atrás, 4233693 disse:

[19/02/2020 18:12:58] [Error - Npc interface] 
[19/02/2020 18:12:58] data/npc/scripts/Blessman.lua
[19/02/2020 18:12:58] Description: 
[19/02/2020 18:12:58] data/npc/scripts/Blessman.lua:35: attempt to index global 'parameters' (a nil value)
[19/02/2020 18:12:58] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Blessman.lua

Bom, depois ir tentando algumas coisas eu consegui, apos resolver esse parameters, ele acha um erro de "playergetBlessing" player not found. Mas tbm consegui resolver kkkk, msm assim agradeço a ajuda, o codigo ficou assim, coloquei "elseif(getPlayerBlessing(cid, 1)) then" e funcionou, ele consegue identificar as bless.

local focuses = {}
local function isFocused(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            return true
        end
    end
    return false
end
 
local function addFocus(cid)
    if(not isFocused(cid)) then
        table.insert(focuses, cid)
    end
end
local function removeFocus(cid)
    for i, v in pairs(focuses) do
        if(v == cid) then
            table.remove(focuses, i)
            break
        end
    end
end
local function lookAtFocus()
    for i, v in pairs(focuses) do
        if(isPlayer(v)) then
            doNpcSetCreatureFocus(v)
            return
        end
    end
    doNpcSetCreatureFocus(0)
end
 
local price = 50000 -- Valor da bless
 
function onCreatureSay(cid, type, msg)
    if(not (isFocused(cid)) and (msg == "hi" or msg == "hello")) then
        selfSay("Welcome, ".. getCreatureName(cid) ..". I sell {blessing}.", cid)
        addFocus(cid)
    elseif((isFocused(cid)) and (msg == "bless" or msg == "blessing")) then
        selfSay("Would you like buying blessing per ".. (price) .." gold coins?", cid)
    elseif((isFocused(cid)) and (msg == "yes")) then
        if(getPlayerBlessing(cid, 1)) then
            selfSay("Sorry, you already have all the blesses.", cid)
        elseif((getPlayerMoney(cid) < price)) then
                selfSay("You don't have enough money.", cid)
            else
            selfSay("Alright.", cid)
            doPlayerRemoveMoney(cid, price)
            doPlayerAddBlessing(cid, 1)
            doPlayerAddBlessing(cid, 2)
            doPlayerAddBlessing(cid, 3)
            doPlayerAddBlessing(cid, 4)
            doPlayerAddBlessing(cid, 5)
            doPlayerAddBlessing(cid, 6)
            doSendMagicEffect(getPlayerPosition(cid), CONST_ME_HOLYAREA)
        end
    elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
        selfSay("Goodbye!", cid)
        closeShopWindow(cid)
        removeFocus(cid)
    end
end
 
function onThink()
    for i, focus in pairs(focuses) do
        if(not isCreature(focus)) then
            removeFocus(focus)
        else
            local distance = getDistanceTo(focus) or -1
            if((distance > 4) or (distance == -1)) then
                selfSay("Hey, where you going?")
                removeFocus(focus)
            end
        end
    end
    lookAtFocus()

end

Link para o comentário
Compartilhar em outros sites

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...