• 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!

Lua Rebirth npc need little fix

FreakOut

Wroking In XoleraServ
Joined
Nov 18, 2013
Messages
72
Reaction score
5
Location
Cairo - Egypt
as @WiLDTuRTLE , requested this script
1- max rebirth is 5
2- price for rebirth increase by 10kk per rebirth
3- keep 25% of mana and health
4- rest 20% of skills
5- change vocation while rebirth

my script can do this
1-max reb is 5
2- price increase but first rebirth is for free then second rebirth for 20 million :(
3- not keep 25% of mana or health
4- rest all skills but not 20% it's rest to be new :(
5- you can change vocation

Code:
local config = {
 price = 10000000, -- Price of first rebirth
 priceIncrease = 10000000, -- Works as 'price' + current rebirths * priceIncrease.
 rebirthLevel = 8, -- Level for first rebirth.
 rebirthIncrease = 0, -- Works as 'rebirthLevel' + current rebirths * rebirthIncrease.
 maxRebirths = 5, -- Number of times a player can rebirth.
 level = 8, -- The level the player is set to apon rebirth.
 healthPercent = 0.25, -- 1.00 = 100%.
 health = false, -- Only used if 'healthPercent' = 0.
 manaPercent = 0.25, -- 1.00 = 100%.
 mana = false, -- Only used if 'manaPercent' = 0.
 keepSkills = false, -- Wether players keep skills and level apon rebirth.
 skillLevel = 10, -- Only used if 'keepSkills' = false.
 magicLevel = 0, -- Only used if 'keepSkills' = false.
 capacity = 10000, -- The capacity players are set to apon rebirth.
 templePos = {x = 2000, y = 2000, z = 7}, -- The place where players reset to should there town id return 0.
 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("Welcome, ".. getCreatureName(cid) ..".", cid, true)
 selfSay("I can {rebirth} you!", cid)
 addFocus(cid)
 status = 1
 elseif((isFocused(cid)) and (msg == "rebirth") and (status == 1)) then
 if (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("I can rebirth you for " .. money .. " gold.", cid)
 selfSay("Do you want me to rebirth you?", cid)
 status = 2
 else
 selfSay("You need at least " .. money .. " gold before you can rebirth.", cid)
 status = 1
 end
 else
 selfSay("You need to be at least level " .. rebirthLevel .. " before you can rebirth.", cid)
 status = 1
 end
 else
 selfSay("It seems you can not rebirth anymore.", cid)
 status = 1
 end
 elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
 selfSay("Ok now , choose you next vocation? {sorcerer , Druid , Paladin , Knight} we are on.", cid)
 else if(msg == "sorcerer") then
 status = 3
 selfSay("so you need to be sorcerer.? then type {wizard}", cid)
 elseif(msg == "wizard") then
 doPlayerSetVocation(cid, 1)
 doPlayerSetStorageValue(cid, 85987, storage == -1 and 1 or storage + 1)
 doPlayerRemoveMoney(cid, money)
 doRemoveCreature(cid)
 if(msg == "no") then
 status =4
 selfSay("so what vocation you need?.", cid)
 end
 else if(msg == "druid") then
 status = 3
 selfSay("so you need to be druid.? then type {healer}", cid)
 elseif(msg == "healer") then
 doPlayerSetVocation(cid, 2)
 doPlayerSetStorageValue(cid, 85987, storage == -1 and 1 or storage + 1)
 doPlayerRemoveMoney(cid, money)
 doRemoveCreature(cid)
 if(msg == "no") then
 status =4
 selfSay("so what vocation you need?.", cid)
 end
 else if(msg == "paladin") then
 status = 3
 selfSay("so you need to be paladin.? then type {archer}", cid)
 elseif(msg == "archer") then
 doPlayerSetVocation(cid, 3)
 doPlayerSetStorageValue(cid, 85987, storage == -1 and 1 or storage + 1)
 doPlayerRemoveMoney(cid, money)
 doRemoveCreature(cid)
 if(msg == "no") then
 selfSay("so what vocation you need?.", cid)
 end
 else if(msg == "knight") then
 status = 3
 selfSay("so you need to be knight.? then type {warrior}", cid)
 elseif(msg == "warrior") then
 doPlayerSetVocation(cid, 4)
 doPlayerSetStorageValue(cid, 85987, storage == -1 and 1 or storage + 1)
 doPlayerRemoveMoney(cid, money)
 doRemoveCreature(cid)
 if(msg == "no") then
 status =4
 selfSay("so what vocation you need?.", cid)
 end
 elseif((isFocused(cid)) and (msg == "no") and (status == 4)) 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 
 end
 end
 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 guid = getPlayerGUID(cid)
 if (config.healthPercent > 0) then
 health = getCreatureMaxHealth(cid) * config.healthPercent
 else
 health = config.health
 end
 if (config.manaPercent > 0) then
 mana = getCreatureMaxMana(cid) * config.manaPercent
 else
 mana = config.mana
 end
 if (getPlayerTown(cid) > 0) then
 pos = getTownTemplePosition(getPlayerTown(cid))
 else
 pos = config.templePos
 end
 doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
 doRemoveCreature(cid, true)
 db.executeQuery("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
 db.executeQuery("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
 db.executeQuery("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
 db.executeQuery("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
 db.executeQuery("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
 db.executeQuery("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
 db.executeQuery("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
 db.executeQuery("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
 db.executeQuery("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
 if (not config.keepSkills) then
 db.executeQuery("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
 db.executeQuery("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
 end
 return true
end
 
Last edited:
You can't even read the script like that. So you tab them,
Code:
function onCreatureDisappear(cid)
    if(isFocused(cid)) then
        selfSay("Goodbye.")
        removeFocus(cid)
    end
end
instead of:
Code:
function onCreatureDisappear(cid)
if(isFocused(cid)) then
selfSay("Goodbye.")
removeFocus(cid)
end
end
 
You can't even read the script like that. So you tab them,
Code:
function onCreatureDisappear(cid)
    if(isFocused(cid)) then
        selfSay("Goodbye.")
        removeFocus(cid)
    end
end
instead of:
Code:
function onCreatureDisappear(cid)
if(isFocused(cid)) then
selfSay("Goodbye.")
removeFocus(cid)
end
end
how can I do this brother I copy paste my script :(
it's tabbed on my script
so how can I fix it in otland
 
so how can I fix it in otland
Click on the code button and paste the script there.
J2qD0HI.png
 
what I need well .. first rebirth should cost 10 million not for free
I get 50% hp&mana of what max I have
Code:
local config = {
    price = 10000000, -- Price of first rebirth
    priceIncrease = 10000000, -- Works as 'price' + current rebirths * priceIncrease.
    rebirthLevel = 8, -- Level for first rebirth.
    rebirthIncrease = 0, -- Works as 'rebirthLevel' + current rebirths * rebirthIncrease.
    maxRebirths = 5, -- Number of times a player can rebirth.
    level = 8, -- The level the player is set to apon rebirth.
    healthPercent = .25, -- 1.00 = 100%.
    health = false, -- Only used if 'healthPercent' = 0.
    manaPercent = .25, -- 1.00 = 100%.
    mana = false, -- Only used if 'manaPercent' = 0.
    keepSkills = false, -- Wether players keep skills and level apon rebirth.
    skillLevel = 10, -- Only used if 'keepSkills' = false.
    magicLevel = 0, -- Only used if 'keepSkills' = false.
    capacity = 10000, -- The capacity players are set to apon rebirth.
    templePos = {x = 2000, y = 2000, z = 7}, -- The place where players reset to should there town id return 0.
    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("Welcome, ".. getCreatureName(cid) ..".", cid, true)
        selfSay("I can {rebirth} you!", cid)
        addFocus(cid)
        status = 1
    elseif((isFocused(cid)) and (msg == "rebirth") and (status == 1)) then
        if (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("I can rebirth you for " .. money .. " gold.", cid)
                    selfSay("Do you want me to rebirth you?", cid)
                    status = 2
                else
                    selfSay("You need at least " .. money .. " gold before you can rebirth.", cid)
                    status = 1
                end
            else
                selfSay("You need to be at least level " .. rebirthLevel .. " before you can rebirth.", cid)
                status = 1
            end
        else
            selfSay("It seems you can not rebirth anymore.", cid)
            status = 1
        end
       
    elseif((isFocused(cid)) and (msg == "yes") and (status == 2)) then
        selfSay("Ok now , choose you next vocation? {sorcerer , Druid , Paladin , Knight} we are on.", cid)
else if(msg == "sorcerer") then
            status = 3
        selfSay("so you need to be sorcerer.? then type {wizard}", cid)
                elseif(msg == "wizard") then
                    doPlayerSetVocation(cid, 1)
                    doPlayerSetStorageValue(cid, 85987, storage == -1 and 1 or storage + 1)
                    doPlayerRemoveMoney(cid, money)
                    doRemoveCreature(cid)
                if(msg == "no") then
                status =4
                    selfSay("so what vocation you need?.", cid)
                end
else if(msg == "druid") then
            status = 3
        selfSay("so you need to be druid.? then type {healer}", cid)
                elseif(msg == "healer") then
                    doPlayerSetVocation(cid, 2)
                    doPlayerSetStorageValue(cid, 85987, storage == -1 and 1 or storage + 1)
                    doPlayerRemoveMoney(cid, money)
                    doRemoveCreature(cid)
                if(msg == "no") then
                status =4
                    selfSay("so what vocation you need?.", cid)
                end
else if(msg == "paladin") then
            status = 3
        selfSay("so you need to be paladin.? then type {archer}", cid)
                elseif(msg == "archer") then
                    doPlayerSetVocation(cid, 3)
                    doPlayerSetStorageValue(cid, 85987, storage == -1 and 1 or storage + 1)
                    doPlayerRemoveMoney(cid, money)
                    doRemoveCreature(cid)
                if(msg == "no") then
                    selfSay("so what vocation you need?.", cid)
                end
else if(msg == "knight") then
            status = 3
        selfSay("so you need to be knight.? then type {warrior}", cid)
                elseif(msg == "warrior") then
                    doPlayerSetVocation(cid, 4)
                    doPlayerSetStorageValue(cid, 85987, storage == -1 and 1 or storage + 1)
                    doPlayerRemoveMoney(cid, money)
                    doRemoveCreature(cid)
                if(msg == "no") then
                status =4
                    selfSay("so what vocation you need?.", cid)
                end
           
    elseif((isFocused(cid)) and (msg == "no") and (status == 4)) 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   
end
end
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 guid = getPlayerGUID(cid)
    if (config.healthPercent > 0) then
        health = getCreatureMaxHealth(cid) * config.healthPercent
    else
        health = config.health
    end
    if (config.manaPercent > 0) then
        mana = getCreatureMaxMana(cid) * config.manaPercent
    else
        mana = config.mana
    end
    if (getPlayerTown(cid) > 0) then
        pos = getTownTemplePosition(getPlayerTown(cid))
    else
        pos = config.templePos
    end
    doCreatureSetStorage(cid, config.storage, getCreatureStorage(cid, config.storage) + 1)
    doRemoveCreature(cid, true)
    db.executeQuery("UPDATE `players` SET level = " .. config.level .. " WHERE id = " .. guid .. ";")
    db.executeQuery("UPDATE `players` SET cap = " .. config.capacity .. " WHERE id = " .. guid .. ";")
    db.executeQuery("UPDATE `players` SET health = " .. health .. " WHERE id = " .. guid .. ";")
    db.executeQuery("UPDATE `players` SET healthmax = " .. health .. " WHERE id = " .. guid .. ";")
    db.executeQuery("UPDATE `players` SET mana = " .. mana .. " WHERE id = " .. guid .. ";")
    db.executeQuery("UPDATE `players` SET manamax = " .. mana .. " WHERE id = " .. guid .. ";")
    db.executeQuery("UPDATE `players` SET posx = " .. pos.x .. " WHERE id = " .. guid .. ";")
    db.executeQuery("UPDATE `players` SET posy = " .. pos.y .. " WHERE id = " .. guid .. ";")
    db.executeQuery("UPDATE `players` SET posz = " .. pos.z .. " WHERE id = " .. guid .. ";")
    if (not config.keepSkills) then
        db.executeQuery("UPDATE `players` SET maglevel = " .. config.magicLevel .. " WHERE id = " .. guid .. ";")
        db.executeQuery("UPDATE `player_skills` SET value = " .. config.skillLevel .. " WHERE id = " .. guid .. ";")
    end
    return true
end
 
Back
Top