• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Solved Prestige huge problem, i can pay

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
Hello guys, well i said i can pay because it's a really difficult problem i think. A very skilled friend tried to fix it but he wasn't able, so i will explaint it right now

I have a prestige system, you reach to lvl 500 and you can "rebirth" and get back to lvl 8 with everything of a lvl 8 except skills and mg lvl
Also i have ingame some items that add you mana or hp, so what i need is that if a player uses these items, the mana or hp gained stay with them forever, even if they do prestige...for example

Player lvl 500 (mana 5000 + 500 extra for the item they used before)
do prestige
Player lvl 8 (mana of a lvl 8+ 500 extra for the item they used before)

oh and well, the problem is that when you do prestige, you get kicked and come back at the temple but you die instantly, and again and again :(

I use tfs 0.3 otx 2.52

i'll post the script of the prestige and of the item...if someone could figure this out for free would be awesome, i can also pay with sprites.

Code:
local config = {
       price = 30000, -- Precio del primer rebirth
       priceIncrease = 0, -- el precio + rebirths actuales * precio aumentado.
       rebirthLevel = 500, -- nivel para el primer rebirth.
       rebirthIncrease = 0, -- El numero de rebirth + el actual * Rebirth aumentado.
       maxRebirths = 20, -- maximo numero de rebirth que se pueden llegar.
       level = 8, -- despues del revirth a que nivel te reseteara.
       healthPercent = 0, -- el % de vida despues reset 1.00 = 100%.
       druidhealth  = 100,
       knighthealth = 350,
       sorchealth = 100,
       paladinhealth = 250,
       manaPercent = 0, -- el % de mana despues reset 1.00 = 100%.
       druidmana = 100,
       knightmana = 100,
       sorcmana = 100,
       paladinmana = 100,
       keepSkills = true, -- true si quieren que el nivel de skill se mantenga.
       skillLevel = 10, -- Only used if 'keepSkills' = false.
       magicLevel = 0, -- Only used if 'keepSkills' = false.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       templePos = {x = 1000, y = 1000, z = 7}, -- el lugar al que te enviara despues del reset.
       storage = 85987 -- Player storage rebirth count is kept on.
    }
    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
    function onCreatureDisappear(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          removeFocus(cid)
       end
    end
    function onCreatureSay(cid, type, msg)
       if((msg == "hi") and not (isFocused(cid))) then
          selfSay("Bienvenido, ".. getCreatureName(cid) ..".", cid, true)
          selfSay("I can {prestige} you!", cid)
          addFocus(cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "prestige") and (status == 1)) then
        --selfSay("GET=" .. tostring(getCreatureStorage(cid, config.storage)));
        --selfSay("MAX=" .. tostring(config.maxRebirths));
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            storage = 0
             rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
             if (getPlayerLevel(cid) >= rebirthLevel) then
                money = config.price + (config.priceIncrease * storage)
                if (getPlayerMoney(cid) >= money) then
                   selfSay("Do you want me to prestige you?", cid)
                   status = 2
                else
                   selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                   status = 1
                end
             else
                selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                status = 1
             end
        else
            if (tonumber(getCreatureStorage(cid, config.storage)) < config.maxRebirths) then
                storage = getCreatureStorage(cid, config.storage)
                rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
                if (getPlayerLevel(cid) >= rebirthLevel) then
                    money = config.price + (config.priceIncrease * storage)
                    if (getPlayerMoney(cid) >= money) then
                        selfSay("Do you want me to prestige you?", cid)
                        status = 2
                    else
                        selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                        status = 1
                    end
                else
                    selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                    status = 1
                end
            else
                selfSay("It seems you can not prestige anymore.", cid)
                status = 1
            end
        end
       elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
          selfSay("Ok then i will prestige you.", cid)
          selfSay("You will now be logged out.", cid)
          doPlayerRemoveMoney(cid, money)
          addEvent(doRebirthPlayer, 2000, {cid=cid})
          removeFocus(cid)
       elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
          selfSay("Maybe one day you will wise up and change your mind!", cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
          selfSay("Goodbye!", cid, true)
          removeFocus(cid)
       end
    end
    function onPlayerCloseChannel(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          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("Goodbye.")
                removeFocus(focus)
             end
          end
       end
       lookAtFocus()
    end
    function doRebirthPlayer(cid)
        cid = cid.cid
        if (cid == nil) then
            return true
        end
        local voc = getPlayerVocation(cid)
        local guid = getPlayerGUID(cid)
        if (config.healthPercent > 0) then
            health = getCreatureMaxHealth(cid) * config.healthPercent
        else
            if voc == 1 or voc == 5 then
                health = (config.sorchealth + (getCreatureStorage(cid, "hpstone") * 5000))
            elseif voc == 2 or voc == 6 then
                health = (config.druidhealth + (getCreatureStorage(cid, "hpstone") * 5000))
            elseif voc == 3 or voc == 7 then
                health = (config.paladinhealth + (getCreatureStorage(cid, "hpstone") * 5000))
            elseif voc == 4 or voc == 8 then
                health = (config.knighthealth + (getCreatureStorage(cid, "hpstone") * 5000))
            end
        end
        if (config.manaPercent > 0) then
            mana = getCreatureMaxMana(cid) * config.manaPercent
        else
            if voc == 1 or voc == 5 then
                mana = (config.sorcmana + (getCreatureStorage(cid, "manastone") * 5000))
            elseif voc == 2 or voc == 6 then
                mana = (config.druidmana + (getCreatureStorage(cid, "manastone") * 5000))
            elseif voc == 3 or voc == 7 then
                mana = (config.paladinmana + (getCreatureStorage(cid, "manastone") * 5000))
            elseif voc == 4 or voc == 8 then
                mana = (config.knightmana + (getCreatureStorage(cid, "manastone") * 5000))
            end
        end
        print(mana)
        if (getPlayerTown(cid) > 0) then
            pos = getTownTemplePosition(getPlayerTown(cid))
        else
            pos = config.templePos
        end
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            doCreatureSetStorage(cid, config.storage, 1)
        else
            if (getCreatureStorage(cid, config.storage) == 0) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
        --selfSay("storage1=" .. getCreatureStorage(cid, config.storage))
        --if (getCreatureStorage(cid, config.storage) == 0) then
        --    doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
        --end
        --selfSay("storage2=" .. getCreatureStorage(cid, config.storage))
        doRemoveCreature(cid, true)
         db.query("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
       if (not config.keepSkills) then
          db.query("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
          db.query("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
       end
       return true
    end
--npcHandler:addModule(FocusModule:new())



Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local manastone = getCreatureStorage(cid, "manastone")
    if manastone < 0 then
        manastone = 0
    end
print(manastone)
    doPlayerSetStorageValue(cid, "manastone", manastone + 1)
    setCreatureMaxMana(cid, (getCreatureMaxMana(cid) + 5000))
    doCreatureSay(cid, "You gained 5000 Max Mana now your Mana is ".. getCreatureMaxMana(cid) .."!" ,TALKTYPE_MONSTER_SAY)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_BLUE)
    doRemoveItem(item.uid, 1)
    return TRUE
end
 
Solution
Lines 185 - 191 is probably the problem because if you add 1 + (-1) you get 0
Lua:
        else
            if (getCreatureStorage(cid, config.storage) == 0) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
So it should be
Lua:
        else
            if (getCreatureStorage(cid, config.storage) < 1) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
UMR is the character in my avatar.

Change everywhere that you have stuff like:

Lua:
getCreatureStorage(cid, "XXXstone") * 5000

To:

Lua:
math.max(0, getCreatureStorage(cid, "XXXstone")) * 5000

I can't do it for you cause I'm on cellphone :3
 
UMR is the character in my avatar.

Change everywhere that you have stuff like:

Lua:
getCreatureStorage(cid, "XXXstone") * 5000

To:

Lua:
math.max(0, getCreatureStorage(cid, "XXXstone")) * 5000

I can't do it for you cause I'm on cellphone :3
yeah, ok i'll try it later, can't now, thanks! so you think this would solve players dieing instantly after rebirth and keeping their aditional hp and mana? :)
 
I wouldn't say he is very skilled if he couldn't fix something like this.

I set up a system for you. You need to add two columns in your players table: extra_health, extra_mana

Lib file
Lua:
local config = {
       level = 8, -- despues del revirth a que nivel te reseteara.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       storage = 85987 -- Player storage rebirth count is kept on.
}

local temple_pos = {x = 1000, y = 1000, z = 7}

local vocations = {
SORCERER = {health = 100, mana = 100},
DRUID = {health = 100, mana = 100},
PALADIN = {health = 250, mana = 100},
KNIGHT = {health = 350, mana = 100},
}

local SORC = {1, 5, 9}
local DRUID = {2, 6, 10}
local PALADIN = {3, 7, 11}
local KNIGHT = {4, 8, 12}

local function getPlayerExtraHealth(cid)
    local resultr, ret = db.storeQuery("SELECT `extra_health` FROM `players` WHERE `id` = '" .. getPlayerGUID(cid) .. "';")
    ret = result.getDataString(resultr,'extra_health')
    result.free(resultr)
    return ret
end

local function getPlayerExtraMana(cid)
    local resultr, ret = db.storeQuery("SELECT `extra_mana` FROM `players` WHERE `id` = '" .. getPlayerGUID(cid) .. "';")
    ret = result.getDataString(resultr,'extra_mana')
    result.free(resultr)
    return ret
end

function setPlayerExtraHealth(cid, amount) 
   return db.query("UPDATE `players` SET `extra_health` = extra_health + ".. amount .. " WHERE `id` = '" .. getPlayerGUID(cid) .. "';") 
end

function setPlayerExtraMana(cid, amount) 
   return db.query("UPDATE `players` SET `extra_mana` = extra_mana + ".. amount .. " WHERE `id` = '" .. getPlayerGUID(cid) .. "';") 
end

function addPlayerRebirth(cid, guid, vocid)
    if isInArray(SORC, vocid) then
        VOC = vocations.SORCERER
    elseif isInArray(DRUID, vocid) then
        VOC = vocations.DRUID
    elseif isInArray(DRUID, vocid) then
        VOC = vocations.PALADIN
    elseif isInArray(DRUID, vocid) then
        VOC = vocations.KNIGHT
    end
   
    if not VOC then print("internal error") return false end
   
    extra_health = VOC.health + getPlayerExtraHealth(guid)
    extra_mana = VOC.mana + getPlayerExtraMana(guid)
   
    db.query("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
    db.query("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
    db.query("UPDATE `players` SET health = " .. extra_health .. " WHERE id = " .. guid .. ";")
    db.query("UPDATE `players` SET healthmax = " .. extra_health .. " WHERE id = " .. guid.. ";")
    db.query("UPDATE `players` SET mana = " .. extra_mana .. " WHERE id = " .. guid .. ";")
    db.query("UPDATE `players` SET manamax = " .. extra_mana .. " WHERE id = " .. guid .. ";")
    db.query("UPDATE `players` SET posx = " .. temple_pos.x .. " WHERE id = " .. guid .. ";")
    db.query("UPDATE `players` SET posy = " .. temple_pos.y .. " WHERE id = " .. guid .. ";")
    db.query("UPDATE `players` SET posz = " .. temple_pos.z .. " WHERE id = " .. guid .. ";")
end

NPC
Lua:
local config = {
       price = 30000, -- Precio del primer rebirth
       priceIncrease = 0, -- el precio + rebirths actuales * precio aumentado.
       rebirthLevel = 500, -- nivel para el primer rebirth.
       rebirthIncrease = 0, -- El numero de rebirth + el actual * Rebirth aumentado.
       maxRebirths = 20, -- maximo numero de rebirth que se pueden llegar.
       storage = 85987 -- Player storage rebirth count is kept on.
    }
   
    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
    function onCreatureDisappear(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          removeFocus(cid)
       end
    end
    function onCreatureSay(cid, type, msg)
       if((msg == "hi") and not (isFocused(cid))) then
          selfSay("Bienvenido, ".. getCreatureName(cid) ..".", cid, true)
          selfSay("I can {prestige} you!", cid)
          addFocus(cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "prestige") and (status == 1)) then
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            storage = 0
             rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
             if (getPlayerLevel(cid) >= rebirthLevel) then
                money = config.price + (config.priceIncrease * storage)
                if (getPlayerMoney(cid) >= money) then
                   selfSay("Do you want me to prestige you?", cid)
                   status = 2
                else
                   selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                   status = 1
                end
             else
                selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                status = 1
             end
        else
            if (tonumber(getCreatureStorage(cid, config.storage)) < config.maxRebirths) then
                storage = getCreatureStorage(cid, config.storage)
                rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
                if (getPlayerLevel(cid) >= rebirthLevel) then
                    money = config.price + (config.priceIncrease * storage)
                    if (getPlayerMoney(cid) >= money) then
                        selfSay("Do you want me to prestige you?", cid)
                        status = 2
                    else
                        selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                        status = 1
                    end
                else
                    selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                    status = 1
                end
            else
                selfSay("It seems you can not prestige anymore.", cid)
                status = 1
            end
        end
       elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
          selfSay("Ok then i will prestige you.", cid)
          selfSay("You will now be logged out.", cid)
          doPlayerRemoveMoney(cid, money)
          addEvent(doRebirthPlayer, 2000, {cid=cid})
          removeFocus(cid)
       elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
          selfSay("Maybe one day you will wise up and change your mind!", cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
          selfSay("Goodbye!", cid, true)
          removeFocus(cid)
       end
    end
    function onPlayerCloseChannel(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          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("Goodbye.")
                removeFocus(focus)
             end
          end
       end
       lookAtFocus()
    end
   
    function doRebirthPlayer(cid)
        cid = cid.cid
        if (cid == nil) then
            return true
        end
        player_voc = getPlayerVocation(cid)
        player_guid = getPlayerGUID(cid)
        doRemoveCreature(cid, true)
        addPlayerRebirth(cid, player_guid, player_voc)
       return true
    end

Inside any items you use to give the player extra health or mana you need to add either:
setPlayerExtraHealth(cid, amount)
or
setPlayerExtraMana(cid, amount)
 
Last edited by a moderator:
does tfs 0.3 otx 2.52 has option to create and apply conditions on player?
if yes I don't suggest changing database values, instead store the original healt and mana of player to storage value.
then remove the levels and apply the health and mana with condition.
 
does tfs 0.3 otx 2.52 has option to create and apply conditions on player?
if yes I don't suggest changing database values, instead store the original healt and mana of player to storage value.
then remove the levels and apply the health and mana with condition.
but i dont know how to do this :(
 
why post on my ->tfs 1.2+<- scripting thread, even when you have a support thread about this?
Lua:
local config = {
       price = 30000, -- Precio del primer rebirth
       priceIncrease = 0, -- el precio + rebirths actuales * precio aumentado.
       rebirthLevel = 500, -- nivel para el primer rebirth.
       rebirthIncrease = 0, -- El numero de rebirth + el actual * Rebirth aumentado.
       maxRebirths = 20, -- maximo numero de rebirth que se pueden llegar.
       level = 8, -- despues del revirth a que nivel te reseteara.
       healthPercent = 0, -- el % de vida despues reset 1.00 = 100%.
       druidhealth  = 100,
       knighthealth = 350,
       sorchealth = 100,
       paladinhealth = 250,
       manaPercent = 0, -- el % de mana despues reset 1.00 = 100%.
       druidmana = 100,
       knightmana = 100,
       sorcmana = 100,
       paladinmana = 100,
       keepSkills = true, -- true si quieren que el nivel de skill se mantenga.
       skillLevel = 10, -- Only used if 'keepSkills' = false.
       magicLevel = 0, -- Only used if 'keepSkills' = false.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       templePos = {x = 1000, y = 1000, z = 7}, -- el lugar al que te enviara despues del reset.
       storage = 85987 -- Player storage rebirth count is kept on.
    }
    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
    function onCreatureDisappear(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          removeFocus(cid)
       end
    end
    function onCreatureSay(cid, type, msg)
       if((msg == "hi") and not (isFocused(cid))) then
          selfSay("Bienvenido, ".. getCreatureName(cid) ..".", cid, true)
          selfSay("I can {prestige} you!", cid)
          addFocus(cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "prestige") and (status == 1)) then
        --selfSay("GET=" .. tostring(getCreatureStorage(cid, config.storage)));
        --selfSay("MAX=" .. tostring(config.maxRebirths));
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            storage = 0
             rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
             if (getPlayerLevel(cid) >= rebirthLevel) then
                money = config.price + (config.priceIncrease * storage)
                if (getPlayerMoney(cid) >= money) then
                   selfSay("Do you want me to prestige you?", cid)
                   status = 2
                else
                   selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                   status = 1
                end
             else
                selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                status = 1
             end
        else
            if (tonumber(getCreatureStorage(cid, config.storage)) < config.maxRebirths) then
                storage = getCreatureStorage(cid, config.storage)
                rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
                if (getPlayerLevel(cid) >= rebirthLevel) then
                    money = config.price + (config.priceIncrease * storage)
                    if (getPlayerMoney(cid) >= money) then
                        selfSay("Do you want me to prestige you?", cid)
                        status = 2
                    else
                        selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                        status = 1
                    end
                else
                    selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                    status = 1
                end
            else
                selfSay("It seems you can not prestige anymore.", cid)
                status = 1
            end
        end
       elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
          selfSay("Ok then i will prestige you.", cid)
          selfSay("You will now be logged out.", cid)
          doPlayerRemoveMoney(cid, money)
          addEvent(doRebirthPlayer, 2000, {cid=cid})
          removeFocus(cid)
       elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
          selfSay("Maybe one day you will wise up and change your mind!", cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
          selfSay("Goodbye!", cid, true)
          removeFocus(cid)
       end
    end
    function onPlayerCloseChannel(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          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("Goodbye.")
                removeFocus(focus)
             end
          end
       end
       lookAtFocus()
    end
    function doRebirthPlayer(cid)
        cid = cid.cid
        if (cid == nil) then
            return true
        end
        local voc = getPlayerVocation(cid)
        local guid = getPlayerGUID(cid)
        if (config.healthPercent > 0) then
            health = getCreatureMaxHealth(cid) * config.healthPercent
        else
            if voc == 1 or voc == 5 then
                health = (config.sorchealth + (math.max(0, getCreatureStorage(cid, "hpstone")) * 5000))
            elseif voc == 2 or voc == 6 then
                health = (config.druidhealth + (math.max(0, getCreatureStorage(cid, "hpstone")) * 5000))
            elseif voc == 3 or voc == 7 then
                health = (config.paladinhealth + (math.max(0, getCreatureStorage(cid, "hpstone")) * 5000))
            elseif voc == 4 or voc == 8 then
                health = (config.knighthealth + (math.max(0, getCreatureStorage(cid, "hpstone")) * 5000))
            end
        end
        if (config.manaPercent > 0) then
            mana = getCreatureMaxMana(cid) * config.manaPercent
        else
            if voc == 1 or voc == 5 then
                mana = (config.sorcmana + (math.max(0, getCreatureStorage(cid, "manastone")) * 5000))
            elseif voc == 2 or voc == 6 then
                mana = (config.druidmana + (math.max(0, getCreatureStorage(cid, "manastone")) * 5000))
            elseif voc == 3 or voc == 7 then
                mana = (config.paladinmana + (math.max(0, getCreatureStorage(cid, "manastone")) * 5000))
            elseif voc == 4 or voc == 8 then
                mana = (config.knightmana + (math.max(0, getCreatureStorage(cid, "manastone")) * 5000))
            end
        end
        print(mana)
        if (getPlayerTown(cid) > 0) then
            pos = getTownTemplePosition(getPlayerTown(cid))
        else
            pos = config.templePos
        end
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            doCreatureSetStorage(cid, config.storage, 1)
        else
            if (getCreatureStorage(cid, config.storage) == 0) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
        --selfSay("storage1=" .. getCreatureStorage(cid, config.storage))
        --if (getCreatureStorage(cid, config.storage) == 0) then
        --    doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
        --end
        --selfSay("storage2=" .. getCreatureStorage(cid, config.storage))
        doRemoveCreature(cid, true)
         db.query("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
       if (not config.keepSkills) then
          db.query("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
          db.query("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
       end
       return true
    end
--npcHandler:addModule(FocusModule:new())
 
why post on my ->tfs 1.2+<- scripting thread, even when you have a support thread about this?
Lua:
local config = {
       price = 30000, -- Precio del primer rebirth
       priceIncrease = 0, -- el precio + rebirths actuales * precio aumentado.
       rebirthLevel = 500, -- nivel para el primer rebirth.
       rebirthIncrease = 0, -- El numero de rebirth + el actual * Rebirth aumentado.
       maxRebirths = 20, -- maximo numero de rebirth que se pueden llegar.
       level = 8, -- despues del revirth a que nivel te reseteara.
       healthPercent = 0, -- el % de vida despues reset 1.00 = 100%.
       druidhealth  = 100,
       knighthealth = 350,
       sorchealth = 100,
       paladinhealth = 250,
       manaPercent = 0, -- el % de mana despues reset 1.00 = 100%.
       druidmana = 100,
       knightmana = 100,
       sorcmana = 100,
       paladinmana = 100,
       keepSkills = true, -- true si quieren que el nivel de skill se mantenga.
       skillLevel = 10, -- Only used if 'keepSkills' = false.
       magicLevel = 0, -- Only used if 'keepSkills' = false.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       templePos = {x = 1000, y = 1000, z = 7}, -- el lugar al que te enviara despues del reset.
       storage = 85987 -- Player storage rebirth count is kept on.
    }
    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
    function onCreatureDisappear(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          removeFocus(cid)
       end
    end
    function onCreatureSay(cid, type, msg)
       if((msg == "hi") and not (isFocused(cid))) then
          selfSay("Bienvenido, ".. getCreatureName(cid) ..".", cid, true)
          selfSay("I can {prestige} you!", cid)
          addFocus(cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "prestige") and (status == 1)) then
        --selfSay("GET=" .. tostring(getCreatureStorage(cid, config.storage)));
        --selfSay("MAX=" .. tostring(config.maxRebirths));
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            storage = 0
             rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
             if (getPlayerLevel(cid) >= rebirthLevel) then
                money = config.price + (config.priceIncrease * storage)
                if (getPlayerMoney(cid) >= money) then
                   selfSay("Do you want me to prestige you?", cid)
                   status = 2
                else
                   selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                   status = 1
                end
             else
                selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                status = 1
             end
        else
            if (tonumber(getCreatureStorage(cid, config.storage)) < config.maxRebirths) then
                storage = getCreatureStorage(cid, config.storage)
                rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
                if (getPlayerLevel(cid) >= rebirthLevel) then
                    money = config.price + (config.priceIncrease * storage)
                    if (getPlayerMoney(cid) >= money) then
                        selfSay("Do you want me to prestige you?", cid)
                        status = 2
                    else
                        selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                        status = 1
                    end
                else
                    selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                    status = 1
                end
            else
                selfSay("It seems you can not prestige anymore.", cid)
                status = 1
            end
        end
       elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
          selfSay("Ok then i will prestige you.", cid)
          selfSay("You will now be logged out.", cid)
          doPlayerRemoveMoney(cid, money)
          addEvent(doRebirthPlayer, 2000, {cid=cid})
          removeFocus(cid)
       elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
          selfSay("Maybe one day you will wise up and change your mind!", cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
          selfSay("Goodbye!", cid, true)
          removeFocus(cid)
       end
    end
    function onPlayerCloseChannel(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          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("Goodbye.")
                removeFocus(focus)
             end
          end
       end
       lookAtFocus()
    end
    function doRebirthPlayer(cid)
        cid = cid.cid
        if (cid == nil) then
            return true
        end
        local voc = getPlayerVocation(cid)
        local guid = getPlayerGUID(cid)
        if (config.healthPercent > 0) then
            health = getCreatureMaxHealth(cid) * config.healthPercent
        else
            if voc == 1 or voc == 5 then
                health = (config.sorchealth + (math.max(0, getCreatureStorage(cid, "hpstone")) * 5000))
            elseif voc == 2 or voc == 6 then
                health = (config.druidhealth + (math.max(0, getCreatureStorage(cid, "hpstone")) * 5000))
            elseif voc == 3 or voc == 7 then
                health = (config.paladinhealth + (math.max(0, getCreatureStorage(cid, "hpstone")) * 5000))
            elseif voc == 4 or voc == 8 then
                health = (config.knighthealth + (math.max(0, getCreatureStorage(cid, "hpstone")) * 5000))
            end
        end
        if (config.manaPercent > 0) then
            mana = getCreatureMaxMana(cid) * config.manaPercent
        else
            if voc == 1 or voc == 5 then
                mana = (config.sorcmana + (math.max(0, getCreatureStorage(cid, "manastone")) * 5000))
            elseif voc == 2 or voc == 6 then
                mana = (config.druidmana + (math.max(0, getCreatureStorage(cid, "manastone")) * 5000))
            elseif voc == 3 or voc == 7 then
                mana = (config.paladinmana + (math.max(0, getCreatureStorage(cid, "manastone")) * 5000))
            elseif voc == 4 or voc == 8 then
                mana = (config.knightmana + (math.max(0, getCreatureStorage(cid, "manastone")) * 5000))
            end
        end
        print(mana)
        if (getPlayerTown(cid) > 0) then
            pos = getTownTemplePosition(getPlayerTown(cid))
        else
            pos = config.templePos
        end
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            doCreatureSetStorage(cid, config.storage, 1)
        else
            if (getCreatureStorage(cid, config.storage) == 0) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
        --selfSay("storage1=" .. getCreatureStorage(cid, config.storage))
        --if (getCreatureStorage(cid, config.storage) == 0) then
        --    doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
        --end
        --selfSay("storage2=" .. getCreatureStorage(cid, config.storage))
        doRemoveCreature(cid, true)
         db.query("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
       if (not config.keepSkills) then
          db.query("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
          db.query("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
       end
       return true
    end
--npcHandler:addModule(FocusModule:new())
it was because i wanted to hire you :( sorry

oh and it didnt's work, i get this error :?

Code:
[12/4/2017 21:42:48] [Error - NpcScript Interface]
[12/4/2017 21:42:48] In a timer event called from:
[12/4/2017 21:42:48] data/npc/scripts/rebirth.lua:onCreatureSay
[12/4/2017 21:42:48] Description:
[12/4/2017 21:42:48] data/npc/scripts/rebirth.lua:157: bad argument #3 to 'max' (number expected, got nil)
[12/4/2017 21:42:48] stack traceback:
[12/4/2017 21:42:48]     [C]: in function 'max'
[12/4/2017 21:42:48]     data/npc/scripts/rebirth.lua:157: in function <data/npc/scripts/rebirth.lua:144>
 
must return nil instead of -1
Lua:
local config = {
       price = 30000, -- Precio del primer rebirth
       priceIncrease = 0, -- el precio + rebirths actuales * precio aumentado.
       rebirthLevel = 500, -- nivel para el primer rebirth.
       rebirthIncrease = 0, -- El numero de rebirth + el actual * Rebirth aumentado.
       maxRebirths = 20, -- maximo numero de rebirth que se pueden llegar.
       level = 8, -- despues del revirth a que nivel te reseteara.
       healthPercent = 0, -- el % de vida despues reset 1.00 = 100%.
       druidhealth  = 100,
       knighthealth = 350,
       sorchealth = 100,
       paladinhealth = 250,
       manaPercent = 0, -- el % de mana despues reset 1.00 = 100%.
       druidmana = 100,
       knightmana = 100,
       sorcmana = 100,
       paladinmana = 100,
       keepSkills = true, -- true si quieren que el nivel de skill se mantenga.
       skillLevel = 10, -- Only used if 'keepSkills' = false.
       magicLevel = 0, -- Only used if 'keepSkills' = false.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       templePos = {x = 1000, y = 1000, z = 7}, -- el lugar al que te enviara despues del reset.
       storage = 85987 -- Player storage rebirth count is kept on.
    }
    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
    function onCreatureDisappear(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          removeFocus(cid)
       end
    end
    function onCreatureSay(cid, type, msg)
       if((msg == "hi") and not (isFocused(cid))) then
          selfSay("Bienvenido, ".. getCreatureName(cid) ..".", cid, true)
          selfSay("I can {prestige} you!", cid)
          addFocus(cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "prestige") and (status == 1)) then
        --selfSay("GET=" .. tostring(getCreatureStorage(cid, config.storage)));
        --selfSay("MAX=" .. tostring(config.maxRebirths));
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            storage = 0
             rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
             if (getPlayerLevel(cid) >= rebirthLevel) then
                money = config.price + (config.priceIncrease * storage)
                if (getPlayerMoney(cid) >= money) then
                   selfSay("Do you want me to prestige you?", cid)
                   status = 2
                else
                   selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                   status = 1
                end
             else
                selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                status = 1
             end
        else
            if (tonumber(getCreatureStorage(cid, config.storage)) < config.maxRebirths) then
                storage = getCreatureStorage(cid, config.storage)
                rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
                if (getPlayerLevel(cid) >= rebirthLevel) then
                    money = config.price + (config.priceIncrease * storage)
                    if (getPlayerMoney(cid) >= money) then
                        selfSay("Do you want me to prestige you?", cid)
                        status = 2
                    else
                        selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                        status = 1
                    end
                else
                    selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                    status = 1
                end
            else
                selfSay("It seems you can not prestige anymore.", cid)
                status = 1
            end
        end
       elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
          selfSay("Ok then i will prestige you.", cid)
          selfSay("You will now be logged out.", cid)
          doPlayerRemoveMoney(cid, money)
          addEvent(doRebirthPlayer, 2000, {cid=cid})
          removeFocus(cid)
       elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
          selfSay("Maybe one day you will wise up and change your mind!", cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
          selfSay("Goodbye!", cid, true)
          removeFocus(cid)
       end
    end
    function onPlayerCloseChannel(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          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("Goodbye.")
                removeFocus(focus)
             end
          end
       end
       lookAtFocus()
    end
    function doRebirthPlayer(cid)
        cid = cid.cid
        if (cid == nil) then
            return true
        end
        local voc = getPlayerVocation(cid)
        local guid = getPlayerGUID(cid)
        if (config.healthPercent > 0) then
            health = getCreatureMaxHealth(cid) * config.healthPercent
        else
            if voc == 1 or voc == 5 then
                health = (config.sorchealth + (math.max(0, getCreatureStorage(cid, "hpstone") or 0) * 5000))
            elseif voc == 2 or voc == 6 then
                health = (config.druidhealth + (math.max(0, getCreatureStorage(cid, "hpstone") or 0) * 5000))
            elseif voc == 3 or voc == 7 then
                health = (config.paladinhealth + (math.max(0, getCreatureStorage(cid, "hpstone") or 0) * 5000))
            elseif voc == 4 or voc == 8 then
                health = (config.knighthealth + (math.max(0, getCreatureStorage(cid, "hpstone") or 0) * 5000))
            end
        end
        if (config.manaPercent > 0) then
            mana = getCreatureMaxMana(cid) * config.manaPercent
        else
            if voc == 1 or voc == 5 then
                mana = (config.sorcmana + (math.max(0, getCreatureStorage(cid, "manastone") or 0) * 5000))
            elseif voc == 2 or voc == 6 then
                mana = (config.druidmana + (math.max(0, getCreatureStorage(cid, "manastone") or 0) * 5000))
            elseif voc == 3 or voc == 7 then
                mana = (config.paladinmana + (math.max(0, getCreatureStorage(cid, "manastone") or 0) * 5000))
            elseif voc == 4 or voc == 8 then
                mana = (config.knightmana + (math.max(0, getCreatureStorage(cid, "manastone") or 0) * 5000))
            end
        end
        print(mana)
        if (getPlayerTown(cid) > 0) then
            pos = getTownTemplePosition(getPlayerTown(cid))
        else
            pos = config.templePos
        end
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            doCreatureSetStorage(cid, config.storage, 1)
        else
            if (getCreatureStorage(cid, config.storage) == 0) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
        --selfSay("storage1=" .. getCreatureStorage(cid, config.storage))
        --if (getCreatureStorage(cid, config.storage) == 0) then
        --    doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
        --end
        --selfSay("storage2=" .. getCreatureStorage(cid, config.storage))
        doRemoveCreature(cid, true)
         db.query("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
       if (not config.keepSkills) then
          db.query("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
          db.query("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
       end
       return true
    end
--npcHandler:addModule(FocusModule:new())
 
must return nil instead of -1
Lua:
local config = {
       price = 30000, -- Precio del primer rebirth
       priceIncrease = 0, -- el precio + rebirths actuales * precio aumentado.
       rebirthLevel = 500, -- nivel para el primer rebirth.
       rebirthIncrease = 0, -- El numero de rebirth + el actual * Rebirth aumentado.
       maxRebirths = 20, -- maximo numero de rebirth que se pueden llegar.
       level = 8, -- despues del revirth a que nivel te reseteara.
       healthPercent = 0, -- el % de vida despues reset 1.00 = 100%.
       druidhealth  = 100,
       knighthealth = 350,
       sorchealth = 100,
       paladinhealth = 250,
       manaPercent = 0, -- el % de mana despues reset 1.00 = 100%.
       druidmana = 100,
       knightmana = 100,
       sorcmana = 100,
       paladinmana = 100,
       keepSkills = true, -- true si quieren que el nivel de skill se mantenga.
       skillLevel = 10, -- Only used if 'keepSkills' = false.
       magicLevel = 0, -- Only used if 'keepSkills' = false.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       capacity = 1000, -- la capacidad despues del rebirth a la que te dejara.
       templePos = {x = 1000, y = 1000, z = 7}, -- el lugar al que te enviara despues del reset.
       storage = 85987 -- Player storage rebirth count is kept on.
    }
    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
    function onCreatureDisappear(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          removeFocus(cid)
       end
    end
    function onCreatureSay(cid, type, msg)
       if((msg == "hi") and not (isFocused(cid))) then
          selfSay("Bienvenido, ".. getCreatureName(cid) ..".", cid, true)
          selfSay("I can {prestige} you!", cid)
          addFocus(cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "prestige") and (status == 1)) then
        --selfSay("GET=" .. tostring(getCreatureStorage(cid, config.storage)));
        --selfSay("MAX=" .. tostring(config.maxRebirths));
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            storage = 0
             rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
             if (getPlayerLevel(cid) >= rebirthLevel) then
                money = config.price + (config.priceIncrease * storage)
                if (getPlayerMoney(cid) >= money) then
                   selfSay("Do you want me to prestige you?", cid)
                   status = 2
                else
                   selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                   status = 1
                end
             else
                selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                status = 1
             end
        else
            if (tonumber(getCreatureStorage(cid, config.storage)) < config.maxRebirths) then
                storage = getCreatureStorage(cid, config.storage)
                rebirthLevel = config.rebirthLevel + (config.rebirthIncrease * storage)
                if (getPlayerLevel(cid) >= rebirthLevel) then
                    money = config.price + (config.priceIncrease * storage)
                    if (getPlayerMoney(cid) >= money) then
                        selfSay("Do you want me to prestige you?", cid)
                        status = 2
                    else
                        selfSay("You need at least " .. money .. " gold before you can prestige.", cid)
                        status = 1
                    end
                else
                    selfSay("You need to be at least level " .. rebirthLevel .. " before you can prestige.", cid)
                    status = 1
                end
            else
                selfSay("It seems you can not prestige anymore.", cid)
                status = 1
            end
        end
       elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
          selfSay("Ok then i will prestige you.", cid)
          selfSay("You will now be logged out.", cid)
          doPlayerRemoveMoney(cid, money)
          addEvent(doRebirthPlayer, 2000, {cid=cid})
          removeFocus(cid)
       elseif((isFocused(cid)) and (msg == "no") and (status == 2)) then
          selfSay("Maybe one day you will wise up and change your mind!", cid)
          status = 1
       elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
          selfSay("Goodbye!", cid, true)
          removeFocus(cid)
       end
    end
    function onPlayerCloseChannel(cid)
       if(isFocused(cid)) then
          selfSay("Goodbye.")
          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("Goodbye.")
                removeFocus(focus)
             end
          end
       end
       lookAtFocus()
    end
    function doRebirthPlayer(cid)
        cid = cid.cid
        if (cid == nil) then
            return true
        end
        local voc = getPlayerVocation(cid)
        local guid = getPlayerGUID(cid)
        if (config.healthPercent > 0) then
            health = getCreatureMaxHealth(cid) * config.healthPercent
        else
            if voc == 1 or voc == 5 then
                health = (config.sorchealth + (math.max(0, getCreatureStorage(cid, "hpstone") or 0) * 5000))
            elseif voc == 2 or voc == 6 then
                health = (config.druidhealth + (math.max(0, getCreatureStorage(cid, "hpstone") or 0) * 5000))
            elseif voc == 3 or voc == 7 then
                health = (config.paladinhealth + (math.max(0, getCreatureStorage(cid, "hpstone") or 0) * 5000))
            elseif voc == 4 or voc == 8 then
                health = (config.knighthealth + (math.max(0, getCreatureStorage(cid, "hpstone") or 0) * 5000))
            end
        end
        if (config.manaPercent > 0) then
            mana = getCreatureMaxMana(cid) * config.manaPercent
        else
            if voc == 1 or voc == 5 then
                mana = (config.sorcmana + (math.max(0, getCreatureStorage(cid, "manastone") or 0) * 5000))
            elseif voc == 2 or voc == 6 then
                mana = (config.druidmana + (math.max(0, getCreatureStorage(cid, "manastone") or 0) * 5000))
            elseif voc == 3 or voc == 7 then
                mana = (config.paladinmana + (math.max(0, getCreatureStorage(cid, "manastone") or 0) * 5000))
            elseif voc == 4 or voc == 8 then
                mana = (config.knightmana + (math.max(0, getCreatureStorage(cid, "manastone") or 0) * 5000))
            end
        end
        print(mana)
        if (getPlayerTown(cid) > 0) then
            pos = getTownTemplePosition(getPlayerTown(cid))
        else
            pos = config.templePos
        end
        if (tostring(getCreatureStorage(cid, config.storage)) == nil) or (tostring(getCreatureStorage(cid, config.storage)) == "") then
            doCreatureSetStorage(cid, config.storage, 1)
        else
            if (getCreatureStorage(cid, config.storage) == 0) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
        --selfSay("storage1=" .. getCreatureStorage(cid, config.storage))
        --if (getCreatureStorage(cid, config.storage) == 0) then
        --    doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
        --end
        --selfSay("storage2=" .. getCreatureStorage(cid, config.storage))
        doRemoveCreature(cid, true)
         db.query("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
        db.query("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
       if (not config.keepSkills) then
          db.query("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
          db.query("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
       end
       return true
    end
--npcHandler:addModule(FocusModule:new())
Thanks man now it works! but there's only one problem i can see
when i do prestige, i dont have the look that says prestige 1, but then i do the second prestige and i get the look that says i have prestige 1, then i do my third prestige and my look says i have two and so on :(

Bump :(
 
Last edited by a moderator:
Lines 185 - 191 is probably the problem because if you add 1 + (-1) you get 0
Lua:
        else
            if (getCreatureStorage(cid, config.storage) == 0) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
So it should be
Lua:
        else
            if (getCreatureStorage(cid, config.storage) < 1) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
 
Solution
I would do this to be safe

Lua:
if (getCreatureStorage(cid, config.storage) < 1) or (getCreatureStorage(cid, config.storage) == nil) then
        doCreatureSetStorage(cid, config.storage, 1)
else
        doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
end

Credits to OT World still.
 
Lines 185 - 191 is probably the problem because if you add 1 + (-1) you get 0
Lua:
        else
            if (getCreatureStorage(cid, config.storage) == 0) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
So it should be
Lua:
        else
            if (getCreatureStorage(cid, config.storage) < 1) then
                doCreatureSetStorage(cid, config.storage, 1)
            else
                doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
            end
        end
thank you it worked! solved!
 
Back
Top