MA

PREMIAÇAO DE POINTS POR RESET

Por marcelinhok, 19 de jun. de 2019 em Scripts

9
2.3k
marcelinhokM
19 de junho de 2019 às 09:53

Entao galera... eu uso esse system de resets e de p points.

Eu queria que a cada reset o personagem ganhasse 1 p points. alguem pode implementar o system de points no resets PORFAVOR.

 

 

 

local config = {
    minlevel = 1200, --- level inical para resetar
    price = 100000, --- preço inicial para resetar
    newlevel = 50, --- level após reset
    priceByReset = 100000, --- preço acrescentado por reset
    percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
    maxresets = 5000,
    levelbyreset = 250 --- 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/5)
        setCreatureMaxHealth(cid, resethp)
        local differencehp = (hp - resethp)
        doCreatureAddHealth(cid, -differencehp)
        local mana = getCreatureMaxMana(cid)
        local resetmana = mana*(config.percent/5)
        setCreatureMaxMana(cid, resetmana)
        local differencemana = (mana - resetmana)
        doCreatureAddMana(cid, -differencemana)
        doRemoveCreature(cid)        
        local description = resets+1
        db.executeQuery("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
        db.executeQuery("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
            selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
            talkState[talkUser] = 1
        else
            selfSay('You already reached the maximum reset level!', cid)
        end
        
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerMoney(cid) < newPrice then
            selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
        elseif getPlayerLevel(cid) < newminlevel then
            selfSay('The minimum level for reseting is '..newminlevel..'!', cid)
        else
            doPlayerRemoveMoney(cid,newPrice)
            playerid = getPlayerGUID(cid)
            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."
            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, 'quantity') then
        selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
        talkState[talkUser] = 0
    end
    return true
end

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

 

 

 

 

 

E o system de Points de points e esse aqui:

 

 

 

Creio eu que e so adicionar essa função aqui, mas eu nao sei fazer isso...

 

Função: 

 

doPlayerAddPoints(cid, quant)

GengoG
19 de junho de 2019 às 11:35

É como você mesmo disse, é só adicionar essa função doPlayerAddPoints(cid, quant) ao seu script, porem creio que sua duvida seria onde exatamente colocar, pois bem você coloca onde faz o reset na função addReset e toda vez que resetar ela chama essa função e adiciona o pontos, segue o script:

 

Spoiler
local config = {
    minlevel = 1200, --- level inical para resetar
    price = 100000, --- preço inicial para resetar
    newlevel = 50, --- level após reset
    priceByReset = 100000, --- preço acrescentado por reset
    percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
    maxresets = 5000,
    levelbyreset = 250 --- 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/5)
        setCreatureMaxHealth(cid, resethp)
        local differencehp = (hp - resethp)
        doCreatureAddHealth(cid, -differencehp)
        local mana = getCreatureMaxMana(cid)
        local resetmana = mana*(config.percent/5)
        setCreatureMaxMana(cid, resetmana)
        local differencemana = (mana - resetmana)
        doCreatureAddMana(cid, -differencemana)
        doRemoveCreature(cid)        
        local description = resets+1
        doPlayerAddPoints(cid, 1)
        db.executeQuery("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. getPlayerGUID(cid) .."")
        db.executeQuery("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. getPlayerGUID(cid) .."")
        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
            selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
            talkState[talkUser] = 1
        else
            selfSay('You already reached the maximum reset level!', cid)
        end
        
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerMoney(cid) < newPrice then
            selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
        elseif getPlayerLevel(cid) < newminlevel then
            selfSay('The minimum level for reseting is '..newminlevel..'!', cid)
        else
            doPlayerRemoveMoney(cid,newPrice)
            playerid = getPlayerGUID(cid)
            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."
            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, 'quantity') then
        selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
        talkState[talkUser] = 0
    end
    return true
end

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

 

 

Obs: Atente-se ao copiar o código, pois pode haver caracteres especiais vindo do editor de código do fórum, assim como veio pra mim quando eu fui analisar seu script.

marcelinhokM
19 de junho de 2019 às 14:36
3 horas atrás, Gengo disse:

É como você mesmo disse, é só adicionar essa função doPlayerAddPoints(cid, quant) ao seu script, porem creio que sua duvida seria onde exatamente colocar, pois bem você coloca onde faz o reset na função addReset e toda vez que resetar ela chama essa função e adiciona o pontos, segue o script:

 

  Ocultar conteúdo

local config = {
    minlevel = 1200, --- level inical para resetar
    price = 100000, --- preço inicial para resetar
    newlevel = 50, --- level após reset
    priceByReset = 100000, --- preço acrescentado por reset
    percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
    maxresets = 5000,
    levelbyreset = 250 --- 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/5)
        setCreatureMaxHealth(cid, resethp)
        local differencehp = (hp - resethp)
        doCreatureAddHealth(cid, -differencehp)
        local mana = getCreatureMaxMana(cid)
        local resetmana = mana*(config.percent/5)
        setCreatureMaxMana(cid, resetmana)
        local differencemana = (mana - resetmana)
        doCreatureAddMana(cid, -differencemana)
        doRemoveCreature(cid)        
        local description = resets+1
        doPlayerAddPoints(cid, 1)
        db.executeQuery("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. getPlayerGUID(cid) .."")
        db.executeQuery("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. getPlayerGUID(cid) .."")
        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
            selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
            talkState[talkUser] = 1
        else
            selfSay('You already reached the maximum reset level!', cid)
        end
        
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerMoney(cid) < newPrice then
            selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
        elseif getPlayerLevel(cid) < newminlevel then
            selfSay('The minimum level for reseting is '..newminlevel..'!', cid)
        else
            doPlayerRemoveMoney(cid,newPrice)
            playerid = getPlayerGUID(cid)
            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."
            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, 'quantity') then
        selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
        talkState[talkUser] = 0
    end
    return true
end

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

 

 

Obs: Atente-se ao copiar o código, pois pode haver caracteres especiais vindo do editor de código do fórum, assim como veio pra mim quando eu fui analisar seu script.

Voce so fez adicionar a funçao ou mudou alguma coisa ?

 

Pois eu adicionei a funçao onde voce falou, pois nao n funcionou e deu o seguinte erro!

 

22222222222222.png

Editado Junho 19 por marcelinhok

GengoG
19 de junho de 2019 às 16:51
2 horas atrás, marcelinhok disse:

Voce so fez adicionar a funçao ou mudou alguma coisa ?

 

Pois eu adicionei a funçao onde voce falou, pois nao n funcionou e deu o seguinte erro!

 

22222222222222.png

Eu só adicionei a função que você mesmo citou, não fiz nenhuma alteração a mais, agora esse erro ai é relacionado ao sistema de points.

marcelinhokM
20 de junho de 2019 às 09:04

UP

marcelinhokM
24 de junho de 2019 às 12:46
Em 19/06/2019 em 16:51, Gengo disse:

Eu só adicionei a função que você mesmo citou, não fiz nenhuma alteração a mais, agora esse erro ai é relacionado ao sistema de points.

Voce conseguiria botar pra ganhar um item ?

Exp o player reseta e ganha um item: 8300

 

local config = {
    minlevel = 750, --- level inical para resetar
    price = 1000000, --- preço inicial para resetar
    newlevel = 20, --- level após reset
    priceByReset = 1000000, --- preço acrescentado por reset
    percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
    maxresets = 999,
    levelbyreset = 0 --- 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/2)
        setCreatureMaxHealth(cid, resethp)
        local differencehp = (hp - resethp)
        doCreatureAddHealth(cid, -differencehp)
        local mana = getCreatureMaxMana(cid)
        local resetmana = mana*(config.percent/2)
        setCreatureMaxMana(cid, resetmana)
        local differencemana = (mana - resetmana)
        doCreatureAddMana(cid, -differencemana)
        doRemoveCreature(cid)        
        local description = resets+1
        db.executeQuery("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
        db.executeQuery("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
            selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
            talkState[talkUser] = 1
        else
            selfSay('You already reached the maximum reset level!', cid)
        end
        
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerMoney(cid) < newPrice then
            selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
        elseif getPlayerLevel(cid) < newminlevel then
            selfSay('The minimum level for reseting is '..newminlevel..'!', cid)
        else
            doPlayerRemoveMoney(cid,newPrice)
            playerid = getPlayerGUID(cid)
            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."
            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, 'quantity') then
        selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
        talkState[talkUser] = 0
    end
    return true
end

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

GengoG
24 de junho de 2019 às 13:02
13 minutos atrás, marcelinhok disse:

Voce conseguiria botar pra ganhar um item ?

Exp o player reseta e ganha um item: 8300

 

local config = {
    minlevel = 750, --- level inical para resetar
    price = 1000000, --- preço inicial para resetar
    newlevel = 20, --- level após reset
    priceByReset = 1000000, --- preço acrescentado por reset
    percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
    maxresets = 999,
    levelbyreset = 0 --- 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/2)
        setCreatureMaxHealth(cid, resethp)
        local differencehp = (hp - resethp)
        doCreatureAddHealth(cid, -differencehp)
        local mana = getCreatureMaxMana(cid)
        local resetmana = mana*(config.percent/2)
        setCreatureMaxMana(cid, resetmana)
        local differencemana = (mana - resetmana)
        doCreatureAddMana(cid, -differencemana)
        doRemoveCreature(cid)        
        local description = resets+1
        db.executeQuery("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
        db.executeQuery("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
            selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
            talkState[talkUser] = 1
        else
            selfSay('You already reached the maximum reset level!', cid)
        end
        
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerMoney(cid) < newPrice then
            selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
        elseif getPlayerLevel(cid) < newminlevel then
            selfSay('The minimum level for reseting is '..newminlevel..'!', cid)
        else
            doPlayerRemoveMoney(cid,newPrice)
            playerid = getPlayerGUID(cid)
            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."
            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, 'quantity') then
        selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
        talkState[talkUser] = 0
    end
    return true
end

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

Só utilizar a função abaixo para que toda vez que for resetar ele ganhe o item.

doPlayerAddItem(cid, itemId, count)

 

marcelinhokM
24 de junho de 2019 às 13:20
17 minutos atrás, Gengo disse:

Só utilizar a função abaixo para que toda vez que for resetar ele ganhe o item.

doPlayerAddItem(cid, itemId, count)

 

Em que parte eu uso ?

voce poderia botar ele no script pf ???

GengoG
24 de junho de 2019 às 15:05
1 hora atrás, marcelinhok disse:

Em que parte eu uso ?

voce poderia botar ele no script pf ???

Spoiler
ocal config = {
    minlevel = 750, --- level inical para resetar
    price = 1000000, --- preço inicial para resetar
    newlevel = 20, --- level após reset
    priceByReset = 1000000, --- preço acrescentado por reset
    percent = 100, ---- porcentagem da vida/mana que você terá ao resetar (em relação à sua antiga vida total)
    maxresets = 999,
    levelbyreset = 0 --- 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/2)
        setCreatureMaxHealth(cid, resethp)
        local differencehp = (hp - resethp)
        doCreatureAddHealth(cid, -differencehp)
        local mana = getCreatureMaxMana(cid)
        local resetmana = mana*(config.percent/2)
        setCreatureMaxMana(cid, resetmana)
        local differencemana = (mana - resetmana)
        doCreatureAddMana(cid, -differencemana)
        doRemoveCreature(cid)      
        doPlayerAddItem(cid, 8300, 1)
        local description = resets+1
        db.executeQuery("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
        db.executeQuery("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
            selfSay('You want to reset your character? It will cost '..newPrice..' gp\'s!', cid)
            talkState[talkUser] = 1
        else
            selfSay('You already reached the maximum reset level!', cid)
        end
        
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerMoney(cid) < newPrice then
            selfSay('Its necessary to have at least '..newPrice..' gp\'s for reseting!', cid)
        elseif getPlayerLevel(cid) < newminlevel then
            selfSay('The minimum level for reseting is '..newminlevel..'!', cid)
        else
            doPlayerRemoveMoney(cid,newPrice)
            playerid = getPlayerGUID(cid)
            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."
            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, 'quantity') then
        selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
        talkState[talkUser] = 0
    end
    return true
end

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

 


Blz, adicionado.