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

Reborn System

Castic

Member
Joined
Sep 10, 2010
Messages
175
Reaction score
7
Well I've looked on the forum and I haven't seen the reborn system that I'm searching for. I'm in need of a Reborn system that once you've reached level 500, a message appears in your default chat saying "Congratulations, you've reached level 500. You now have the option to reborn with your new vocation(a promotion). If you would like to be Reborn, please visit NPC." Also, you can only reborn once. When you reborn, you keep all of your items, but your skills and everything else gets reset back to it's original state.

So you goto the npc and say Hi, reborn, yes. Blah blah, and if you try it again it says you've already been reborn, you can no longer reborn.

Thanks.
 
>>1142124

Lua:
local t = {
	level=700, -- level required for rebirth
	RemainingLvl=8, -- {8} = level(normal) level you become after the rebirth
	skull=true, -- players with white skull can ascend?
	redskull=true, -- players with red skull can ascend?
	prot=true, -- players must be in protection zone to ascend?
	bat=true -- players must not have battle condition to ascend?
}
 
local function getResets(cid)
	return math.max(0, getPlayerStorageValue(cid, 1020))
end
 
function onSay(cid, words, param)
	local skull = getCreatureSkullType(cid)
	if (not t.skull and skull == SKULL_WHITE) or (not t.redskull and skull == SKULL_RED) then
		doPlayerSendTextMessage(cid, 22, 'You cannot ascend with a ' .. (skull == SKULL_WHITE and 'white' or 'red') .. ' skull.')
	end
 
	local pos = getThingPos(cid)
	if t.prot and not getTileInfo(pos).protection then
		return doPlayerSendTextMessage(cid, 22, 'You must be in a protection zone to ascend.')
	elseif t.bat and hasCondition(cid, CONDITION_INFIGHT) then
		return doPlayerSendTextMessage(cid, 22, 'You must lose your battle sign to ascend.')
	end
 
	local lvl = getPlayerLevel(cid)
	if lvl >= t.level then
		local new, newLvl = getResets(cid) + 1, math.max(t.RemainingLvl, t.RemainingLvl + lvl - t.level)
		setPlayerStorageValue(cid, 1020, new)
		doPlayerSetSpecialDescription(cid, '. ' .. (getPlayerSex(cid) == 0 and 'Sh' or 'H') .. 'e is on Ascension # ' .. new)
		doPlayerPopupFYI(cid, 'You have ascended, and you now have ' .. new .. ' reset' .. (new == 1 and '' or 's') .. ' in total.')
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		local pid, hp, mana = getPlayerGUID(cid), math.ceil(getCreatureMaxHealth(cid) * (0.2 * new)), math.ceil(getCreatureMaxMana(cid) * (0.2 * new))
		doRemoveCreature(cid)
		db.executeQuery('UPDATE `players` SET `level` = ' .. newLvl .. ', `experience` = ' .. getExperienceForLevel(newLvl) .. ', `promotion` = 0, `health` = ' .. hp ..', `healthmax` = ' .. hp .. ', `mana` = ' .. mana .. ', `manamax` = ' .. mana .. ' WHERE `id` = ' .. pid .. ' LIMIT 1;')
	else
		doPlayerSendCancel(cid, 'You need to reach level ' .. t.level .. ' or higher to ascend.')
		doSendMagicEffect(pos, CONST_ME_POFF)
	end
	return true
 
>>1142124

Lua:
local t = {
	level=700, -- level required for rebirth
	RemainingLvl=8, -- {8} = level(normal) level you become after the rebirth
	skull=true, -- players with white skull can ascend?
	redskull=true, -- players with red skull can ascend?
	prot=true, -- players must be in protection zone to ascend?
	bat=true -- players must not have battle condition to ascend?
}
 
local function getResets(cid)
	return math.max(0, getPlayerStorageValue(cid, 1020))
end
 
function onSay(cid, words, param)
	local skull = getCreatureSkullType(cid)
	if (not t.skull and skull == SKULL_WHITE) or (not t.redskull and skull == SKULL_RED) then
		doPlayerSendTextMessage(cid, 22, 'You cannot ascend with a ' .. (skull == SKULL_WHITE and 'white' or 'red') .. ' skull.')
	end
 
	local pos = getThingPos(cid)
	if t.prot and not getTileInfo(pos).protection then
		return doPlayerSendTextMessage(cid, 22, 'You must be in a protection zone to ascend.')
	elseif t.bat and hasCondition(cid, CONDITION_INFIGHT) then
		return doPlayerSendTextMessage(cid, 22, 'You must lose your battle sign to ascend.')
	end
 
	local lvl = getPlayerLevel(cid)
	if lvl >= t.level then
		local new, newLvl = getResets(cid) + 1, math.max(t.RemainingLvl, t.RemainingLvl + lvl - t.level)
		setPlayerStorageValue(cid, 1020, new)
		doPlayerSetSpecialDescription(cid, '. ' .. (getPlayerSex(cid) == 0 and 'Sh' or 'H') .. 'e is on Ascension # ' .. new)
		doPlayerPopupFYI(cid, 'You have ascended, and you now have ' .. new .. ' reset' .. (new == 1 and '' or 's') .. ' in total.')
		doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
		local pid, hp, mana = getPlayerGUID(cid), math.ceil(getCreatureMaxHealth(cid) * (0.2 * new)), math.ceil(getCreatureMaxMana(cid) * (0.2 * new))
		doRemoveCreature(cid)
		db.executeQuery('UPDATE `players` SET `level` = ' .. newLvl .. ', `experience` = ' .. getExperienceForLevel(newLvl) .. ', `promotion` = 0, `health` = ' .. hp ..', `healthmax` = ' .. hp .. ', `mana` = ' .. mana .. ', `manamax` = ' .. mana .. ' WHERE `id` = ' .. pid .. ' LIMIT 1;')
	else
		doPlayerSendCancel(cid, 'You need to reach level ' .. t.level .. ' or higher to ascend.')
		doSendMagicEffect(pos, CONST_ME_POFF)
	end
	return true
With this script can you reborn more than once? I only want it so you can reborn one time. Also, what about the npc?
 
Last edited:
Yeah, I just really looked at the script. You clearly didn't read the thread and just assumed you knew what I wanted. Please read the thread before trying to be a hero.

I want it so you reborn with a new vocation, I also want an NPC and not a talkaction...
 
Simply add storage to the script if you aren't able to do that i may fix it later to you :)

Edit: "(0, getPlayerStorageValue(cid, 1020))" Didnt see that first...

Edit: This script isnt working:
[17/01/2011 00:21:03] [Error - LuaScriptInterface::loadFile] data/npc/scripts/Rebirth.lua:29: '<eof>' expected near 'end'
[17/01/2011 00:21:03] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/Rebirth.lua
[17/01/2011 00:21:03] data/npc/scripts/Rebirth.lua:29: '<eof>' expected near 'end'
 
Heres my old easy edit script =/ if u know how to edit it how u want it then it'll be good for yah.
Code:
  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

        if(msgcontains(msg, 'rebirth')) then
                selfSay('Ready for me to rebirth you?', cid)
                talkState[talkUser] = 1

        elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then

        local level     = 60000         -- Put here the level to rebirth
        local cost      = 5000000000         -- Put here the cost to rebirth in GP (20000 = 20k)

        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)

                if getPlayerLevel(cid) >= level then
                        if doPlayerRemoveItem(cid,2157,5000) == TRUE then
				if(isInArray({9,10,11,12,25,26,27,28}, getPlayerVocation(cid)) == TRUE) then
                                        doRemoveCreature(cid)
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
                                        db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")
                                elseif vocation == 9 then
                                        doRemoveCreature(cid)
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
                                        db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")
                                elseif vocation == 10 then
                                        doRemoveCreature(cid)
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
                                        db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")
                                elseif vocation == 11 then
                                        doRemoveCreature(cid)
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
                                        db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")
                                elseif vocation == 12 then
                                        doRemoveCreature(cid)
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `health` = 250, `healthmax` = 250, `mana` = 250, `manamax` = 250, `promotion` = 3 WHERE `id` ='"..id.."';")
                                        db.executeQuery("UPDATE `players` SET `name` = '¥ "..name.."' WHERE `id` ='"..id.."';")

                                else
                                        selfSay('Not a valid vocation. Contact administrator.', cid)
                                        talkState[talkUser] = 0
                                end
			else
				selfSay('You need 5,000 GN to Reborn.', cid)
			end 
		end
        elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
                talkState[talkUser] = 0
                selfSay('Okey come back when you are ready.', cid)
        
                                end
        return TRUE
end

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

All that extra if is in array vocation ids n the same thing under, is just for if i wanted to change things on a different vocation id, remove it from array list and it auto reads down to the next elseif..
 
i got this error


Lua Script Error: [Npc interface]
data/npc/scripts/rebirth.lua:eek:nThink
data/npc/lib/npcsystem/npchandler.lua:293: bad argument #3 to 'gsub' (string/function/table expected)
stack traceback:
[C]: ?
[C]: in function 'gsub'
data/npc/lib/npcsystem/npchandler.lua:293: in function 'parseMessage'
data/npc/lib/npcsystem/npchandler.lua:528: in function 'onWalkAway'
data/npc/lib/npcsystem/npchandler.lua:474: in function 'onThink'
data/npc/scripts/rebirth.lua:18: in function <data/npc/scripts/rebirth.lua:17>
 
Back
Top