Ir para conteúdo

Featured Replies

Postado
[26/08/2021 22:32:06] [Error - Npc interface] 
[26/08/2021 22:32:06] data/npc/scripts/reseter.lua:onCreatureSay
[26/08/2021 22:32:06] Description: 
[26/08/2021 22:32:06] data/npc/scripts/reseter.lua:20: attempt to call global 'Player' (a nil value)
[26/08/2021 22:32:06] stack traceback:
[26/08/2021 22:32:06] 	data/npc/scripts/reseter.lua:20: in function 'callback'
[26/08/2021 22:32:06] 	data/npc/lib/npcsystem/npchandler.lua:383: in function 'onCreatureSay'
[26/08/2021 22:32:06] 	data/npc/scripts/reseter.lua:8: in function <data/npc/scripts/reseter.lua:8>

ERRO POR FAVORME AJUDA eu falo hi 'reset' não funciona e nem 'quanty'

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)
config = {


minlevel = 1, --- Level inical para resetar
price = 100000, --- Preço inicial para resetar
newlevel = 1, --- Level após reset
priceByReset = 0, --- Preço acrescentado por reset
percent = 0, ---- Porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
maxresets = 100, ---- Maximo de resets
levelbyreset = 717217 --- Quanto de level vai precisar a mais no próximo reset 


}


function addReset(cid)
player = Player(cid)
resets = getResets(cid)
hp = player:getMaxHealth()
resethp = hp*(config.percent/100)
player:setMaxHealth(resethp)
mana = player:getMaxMana()
resetmana = mana*(config.percent/100)
player:setMaxMana(resetmana)
playerid = player:getGuid()
    player:remove() 
db.query("UPDATE `players` SET `resets`= ".. (resets+1) ..",`experience`= 0 WHERE `players`.`id`= "..playerid)
db.query("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."")
    return true
end 


local newPrice = config.price + (getResets(cid) * config.priceByReset)
local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset)


if msgcontains(msg, 'reset') then
if getResets(cid) < config.maxresets then
npcHandler:say('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
npcHandler.topic[cid] = 1
else
npcHandler:say('You already reached the maximum reset level!', cid)
end
elseif msgcontains(msg, 'yes') and npcHandler.topic[cid] == 1 then
if player:getLevel() > newminlevel then
if player:removeMoney(newPrice) then
addEvent(function()
if isPlayer(cid) then
addReset(cid)
end
end, 3000)
local number = getResets(cid)+1
local msg ="---[Reset: "..number.."]-- You have reseted!  You'll be disconnected in 3 seconds."
player:popupFYI(msg) 
npcHandler.topic[cid] = 0
npcHandler:releaseFocus(cid)
else
npcHandler:say('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
npcHandler.topic[cid] = 0
end
else
npcHandler:say('The minimum level for reseting is '..newminlevel..'!', cid)
npcHandler.topic[cid] = 0
end
elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then
npcHandler.topic[cid] = 0
npcHandler:releaseFocus(cid)
npcHandler:say('Ok.', cid)
elseif msgcontains(msg, 'quantity') then
npcHandler:say('You have a total of '..getResets(cid)..' reset(s).', cid)
npcHandler.topic[cid] = 0
end
return true
end


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

 

Resolvido por Rogex Joyz

Ir para solução
  • Respostas 23
  • Visualizações 625
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

Postado

testa assim, troca por este: 

  Citar

local config = {
    minlevel = 1, --- level inical para resetar
    price = 10000, --- preço inicial para resetar
    newlevel = 1, --- level após reset
    priceByReset = 0, --- preço acrescentado por reset
    percent = 0, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
    maxresets = 100,
    levelbyreset = 717217 --- quanto de level vai precisar a mais no próximo reset
}
--- end config

function getResets(uid)
    resets = getPlayerStorageValue(uid, 378378)
    if resets < 0 then
        resets = 0
    end
    return resets
end

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

    function addReset(cid)
        if(npcHandler:isFocused(cid)) then
            npcHandler:releaseFocus(cid)
        end
        
        talkState[talkUser] = 0
        resets = getResets(cid)
        setPlayerStorageValue(cid, 378378, resets+1) 
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        local hp = getCreatureMaxHealth(cid)
        local resethp = hp*(config.percent/100)
        setCreatureMaxHealth(cid, resethp)
        local differencehp = (hp - resethp)
        doCreatureAddHealth(cid, -differencehp)
        local mana = getCreatureMaxMana(cid)
        local resetmana = mana*(config.percent/100)
        setCreatureMaxMana(cid, resetmana)
        local differencemana = (mana - resetmana)
        doCreatureAddMana(cid, -differencemana)
                doRemoveCreature(cid)        
        local description = resets+1
        db.query("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
        db.query("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0,`cap`= 200 WHERE `players`.`id`= ".. playerid .."")
        return true
    end
    
    local newPrice = config.price + (getResets(cid) * config.priceByReset)
    local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset)

    if msgcontains(msg, 'poder') then
        if getResets(cid) < config.maxresets then
            selfSay('sim eu desenvolvi uma tecnica que concentra seu poder em sua alma possibilitando o acumulo de mais poder que seu corpo fisico n suportaria. eu te ensinarei isso por '..newPrice..' gp\'s!', cid)
            talkState[talkUser] = 1
        else
            selfSay('eu ja te ensinei tudo que sei, mais um reset poderia destruir seu fragil e instavel corpo mortal!', cid)
        end
        
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerMoney(cid) < newPrice then
            selfSay('voce precisa de '..newPrice..' gp\'s para que eu possa te treinar!', cid)
        elseif getPlayerLevel(cid) < newminlevel then
            selfSay('Ainda esta cedo para isso.. Voce so podera repetir essa tecnica no nivel '..newminlevel..'!', cid)
        else
            doPlayerRemoveMoney(cid,newPrice)
            playerid = getPlayerGUID(cid)
            addEvent(function()
                if isPlayer(cid) then
                    addReset(cid)
                        selfSay('Voce resetou!, pergunte por "resets para saber quantos resets tem!', cid)
                end
            end, 3000)
            local number = getResets(cid)+1
            local msg ="---[Reset: "..number.."]-- voce resetou!  desperte bravo guerreiro, a jornada ainda não terminou..."
            doPlayerPopupFYI(cid, msg) 
            talkState[talkUser] = 0
            npcHandler:releaseFocus(cid)
        end
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then
        talkState[talkUser] = 0
        npcHandler:releaseFocus(cid)
        selfSay('Ok.', cid)
    elseif msgcontains(msg, 'resets') then
        selfSay('voce tem um total de '..getResets(cid)..' reset(s).', cid)
        talkState[talkUser] = 0
    end
    return true
end

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

 

Postado
  • Autor

00:28 Boosted/item: Ola Lord'Paulistinha. Eu Vendo Ferramenta Pra Aprimora seu item.
00:28 Reseter: Hello Lord'Paulistinha.I've been waiting for you to come.. Say 'reset' or 'quantity'

e não sai disso ja tentei reset resetar quantity quantidade e nada me ajuda por favor

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.

Conteúdo Similar

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo