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

Rebirth help

troxet

New Member
Joined
Oct 7, 2010
Messages
158
Reaction score
3
Location
United kingdom
Hello ive got a Rebirth System but if somebody will enter the Rebirth then the Hp, Mana, and Skills they stay the same but they should restart >




This is my Npc/scripts/Rebirth.lua

PHP:
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('Are you ready to rebirth and start a new life?', cid)
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		-------CONFIGS-------
		local level = 1000 
		local cost = 0
		------/CONFIGS-------
		-----LOCALS-----
		local id = getPlayerGUID(cid)
		local name = getCreatureName(cid)
		local vocation = getPlayerVocation(cid)
		local storage = getCreatureStorage(cid, 85987)
		----/LOCALS-----
		if(getPlayerLevel(cid) >= level) then
			if(doPlayerRemoveMoney(cid, cost) == TRUE) then
				if(isInArray({1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 22}, vocation)) then
					doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
					doRemoveCreature(cid)
					db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `healthmax` = 2000, `manamax` = 2000, `promotion` = 1 WHERE `id` ='"..id.."';")
					db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
				else
					selfSay('Please talk with Forgotten King and promote first.', cid)
					talkState[talkUser] = 0
				end
			else
				selfSay('You don\'t have enough money. You need to pay 10 mil to be rebirthed.', cid)
				talkState[talkUser] = 0
			end
		else
			selfSay('Only characters of level 400000 or higher can be rebirthed.', cid)
			talkState[talkUser] = 0
		end
	elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
		selfSay('Okey. Come back when you feel ready.', cid)
		talkState[talkUser] = 0
	end
 
	return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


Also i wanted to add my other vocations that you can rebirth with !


rep++ for help ! Thanx
 
use this script
step 1:
in creaturescript/scripts:

Lua Code:
LUA:
Efunction onLook(cid, thing, position, lookDistance)
    if(isPlayer(thing.uid) and thing.uid ~= cid and getCreatureStorage(thing.uid, 85987) ~= -1) then
        doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == PLAYERSEX_FEMALE and ".\nShe" or ".\nHe") .. " has prestiged " .. getCreatureStorage(thing.uid, 85987) .. " " .. (getCreatureStorage(thing.uid, 85987) == 1 and "time" or "times"))
    elseif(thing.uid == cid and getCreatureStorage(cid, 85987) ~= -1) then
        local message = "You see yourself."
        if(getPlayerFlagValue(cid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION)) then
            message = message .. " You are " .. getPlayerGroupName(cid) .. "."
        elseif(getPlayerVocation(cid) ~= 0) then
            message = message .. " You are a " .. getPlayerVocationName(cid):lower() .. "."
        else
            message = message .. " You have no vocation."
        end
 
        if(getPlayerNameByGUID(getPlayerPartner(cid), false, false) ~= nil) then
            message = message .. " You are " .. (getPlayerSex(cid) == PLAYERSEX_FEMALE and "wife" or "husband") .. " of " .. getPlayerNameByGUID(getPlayerPartner(cid)) .. "."
        end
 
        if(getPlayerGuildId(cid) > 0) then
            message = message .. " You are " .. (getPlayerGuildRank(cid) == "" and "a member" or getPlayerGuildRank(cid)) .. " of the " .. getPlayerGuildName(cid)
            message = getPlayerGuildNick(cid) ~= "" and message .. " (" .. getPlayerGuildNick(cid) .. ")." or message .. "."
        end
 
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS)) then
            message = message .. "\nHealth: [" .. getCreatureHealth(cid) .. " / " .. getCreatureMaxHealth(cid) .. "], Mana: [" .. getCreatureMana(cid) .. " / " .. getCreatureMaxMana(cid) .. "]."
            message = message .. "\nIP: " .. doConvertIntegerToIp(getPlayerIp(cid)) .. ", Client: " .. getClientVersion(cid) .. "."
        end
 
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION)) then
            message = message .. "\nPosition: [X: " .. position.x .. "] [Y: " .. position.y .. "] [Z: " .. position.z .. "]."
        end
 
        return false, doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, message .. " \nYou have prestiged " .. getCreatureStorage(cid, 85987) .. " " .. (getCreatureStorage(cid, 85987) == 1 and "time." or "times."))
    end
 
    return true
end


name it rebirthdescription.lua

step 2:
then add this line in creaturescipts/creaturescripts.xml
XML Code:

XML:
<event type="look" name="RebirthDescription" event="script" value="rebirthdescription.lua"/>




step 3:
then this go to data/npc add new file prestige.lua
XML Code:

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Prestige Npc" script="data/npc/scripts/rebirth.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100"/>
<look type="73" head="78" body="88" legs="0" feet="88" addons="3"/>
    <parameters>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. Im in charge of the 'Prestige' system."/>
        <parameter key="message_farewell" value="Good bye my dear friend."/>
    </parameters>
</npc>

but make it prestige.xml if u want name it rebirthnpc or prestige like me

step4:
now go to npc/scripts
add this in rebirth.lua

Lua Code:

LUA:
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, 'prestige')) then
        selfSay('Are you ready to prestige and start a new life?', cid)
        talkState[talkUser] = 1
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        -------CONFIGS-------
        local level = 717217
        local cost = 0
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getCreatureStorage(cid, 85987)
        ----/LOCALS-----
        if(getPlayerLevel(cid) >= level) then
            if(doPlayerRemoveMoney(cid, cost) == TRUE) then
                if(isInArray({1, 2, 3, 4, 5, 6, 7, 8}, vocation)) then
                    doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 0 WHERE `id` ='"..id.."';")
                    db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                else
                    selfSay('Please talk with Forgotten King and promote first.', cid)
                    talkState[talkUser] = 0
                end
            else
                selfSay('You don\'t have enough money. You need to pay 1 gold coin to be rebirthed.', cid)
                talkState[talkUser] = 0
            end
        else
            selfSay('Only characters of level 717217 or higher can be rebirthed.', cid)
            talkState[talkUser] = 0
        end
    elseif(msgcontains(msg, 'no') and talkState[talkUser] == 1) then
        selfSay('Okey. Come back when you feel ready.', cid)
        talkState[talkUser] = 0
    end
 
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())



Step 5:go to creaturescript/script/login.lua and add this line
Lua Code:

LUA:
 registerCreatureEvent(cid, "RebirthDescription")



step6: now start ur server and test

PsS! this script its not my i found it like 1 month ago but iam using it in my server
REP+ me if it helped!!

Edited ! Remember rep+ me if it helped!

or if u want go buy kekox rebirth system its the best!

http://otland.net/f485/fully-functional-rebirth-system-147666/

(And remember to rep+ me ! )
 
LUA:
local config = {
	price = 0, -- Price of first rebirth
	priceIncrease = 0, -- Works as 'price' + current rebirths * priceIncrease.
	rebirthLevel = 717217, -- Level for first rebirth.
	rebirthIncrease = 0, -- Works as 'rebirthLevel' + current rebirths * rebirthIncrease.
	maxRebirths = 50, -- Number of times a player can rebirth.
	level = 8, -- The level the player is set to apon rebirth.
	healthPercent = 0.20, -- 1.00 = 100%.
	health = 100, -- Only used if 'healthPercent' = 0.
	manaPercent = 0.20, -- 1.00 = 100%.
	mana = 100, -- Only used if 'manaPercent' = 0.
	keepSkills = true, -- 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 = 0, y = 0, z = 0}, -- 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 then i will rebirth 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 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


if this work reb me
 
Back
Top