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

Request rebirth counter

Marilyekon

New Member
Joined
Feb 23, 2010
Messages
47
Reaction score
0
Hello. I'm almost done with my Tibia server, but I only have one thing left. Compleate rebirth system. I allready got the npc that takes you back to level 8, but if you click onn the player i it would be nice to see like this "19:21 You See Zand Graz. He's an Elder Druid. He Have Prestiged xxx times" or something like that. Do anyone know how to create a script for it? If so, it would be great! Ofc i will rep+++ You ;)
 
Can u post the link to the rebirth system or post the scripts here???
So someone can add a storage when u reborn... Then, i'm Blastuss, i reborn the first time so the storage will be 0 + 1 then i reborn second time so the storage will be 1 + 1...
Then a onLook script that shows the storage value when u look a player... ;)
It's not too difficult....

Sorry for bad english... :S
 
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 be reborn?', cid)
                talkState[talkUser] = 1

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

        local level     =   1000
        local cost      =   10000000
        
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        ----/LOCALS-----

                if getPlayerLevel(cid) >= level then
                        if doPlayerRemoveMoney(cid,cost) == TRUE then
                                if vocation == 5 then
                                        doRemoveCreature(cid)
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 1 WHERE `id` ='"..id.."';")
                                        db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                                elseif vocation == 6 then
                                        doRemoveCreature(cid)
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 1 WHERE `id` ='"..id.."';")
                                        db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                                elseif vocation == 7 then
                                        doRemoveCreature(cid)
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 1 WHERE `id` ='"..id.."';")
                                        db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                                elseif vocation == 8 then
                                        doRemoveCreature(cid)
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `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 dont have enough money. You need to pay 10000k to be rebirthed.', cid)
                                talkState[talkUser] = 0
                        end
                else
                        selfSay('Only characters of level 1000 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 are ready.', cid)
                talkState[talkUser] = 0
        
                                end
        return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
The NPC need to be like this:
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, 'rebirth')) then 
                selfSay('Are you ready to be reborn?', cid) 
                talkState[talkUser] = 1 

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

        local level     =   1000 
        local cost      =   10000000 
         
        ------/CONFIGS------- 
        -----LOCALS----- 
        local id = getPlayerGUID(cid) 
        local name = getCreatureName(cid) 
        local vocation = getPlayerVocation(cid) 
        local storage = 85987
        ----/LOCALS----- 

                if getPlayerLevel(cid) >= level then 
                        if doPlayerRemoveMoney(cid,cost) == TRUE then 
                                if vocation == 5 then 
                                        doRemoveCreature(cid) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 1 WHERE `id` ='"..id.."';") 
                                        db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                                        setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
                                elseif vocation == 6 then 
                                        doRemoveCreature(cid) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 1 WHERE `id` ='"..id.."';") 
                                        db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';") 
                                        setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
                                elseif vocation == 7 then 
                                        doRemoveCreature(cid) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `promotion` = 1 WHERE `id` ='"..id.."';") 
                                        db.executeQuery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';") 
                                        setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
                                elseif vocation == 8 then 
                                        doRemoveCreature(cid) 
                                        db.executeQuery("UPDATE `players` SET `level` = 8, `experience` = 4200, `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 dont have enough money. You need to pay 10000k to be rebirthed.', cid) 
                                talkState[talkUser] = 0 
                        end 
                else 
                        selfSay('Only characters of level 1000 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 are ready.', cid) 
                talkState[talkUser] = 0 
         
                                end 
        return TRUE 
end 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) 
npcHandler:addModule(FocusModule:new())
Now u put this on creaturescript/scripts/rebirthstorage.lua:
Lua:
local storage = 85987
function onLogin(cid)
if getPlayerStorageValue(cid, storage) < 0 then
setPlayerStorageValue(cid, storage, 0)
end
end
Now, u need to register it in creaturescripts.xml:
XML:
<event type="login" name="RebirthStorage" event="script" value="rebirthstorage.lua"/>
Now, u need to register in creaturescripts/scripts/login.lua this:
Lua:
registerCreatureEvent(cid, "RebirthStorage")

Now the look.....
First, the script that u need to put on creaturescripts/scripts with the name of lookrebirth.lua:
Lua:
local storage = 85987
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) == false then
return true
end
if getPlayerStorageValue(thing.uid, storage) > 0 then
doPlayerSendTextMessage(cid, 20, ""..getPlayerSex(thing.uid).." has reborned "..getPlayerStorageValue(thing.uid, storage).." times.")
end
return true
end
Now in creaturescripts.xml u need to add a line with:
XML:
<event type="look" name="LookRebirth" event="script" value="lookrebirth.lua"/>

I think all these stuff need to work....
Sorry for bad english

Edit: Need to register this on login.lua:
Lua:
registerCreatureEvent(cid, "LookRebirth")

Hope u put the scripts in the correct folder.... :/
 
Last edited:
When I'm trying to log it i get kiked instantly. On tibia it just says yur character is beeing loaded, please wait, and nothing else happens. But in the console, it loggs in and out in less stan a second. What could i have done wrong? :O
 
No, not the console, just the character. I think that it may have something to do with my testservers console, wich is a 8.54 (tfs 0.3.6)
 
The only Thing I got that may could help is this

Got it from my other request by Mooosie
PHP:
 function onLook(cid, thing, position, lookDistance)
local quests = {1345, 2542, 30017, 2469, 2542, 6691, 5941, 3018, 2508, 2323, 7884, 5277, 2506, 6132, 2495, 15402, 8978, 7957, 26555, 8882, 7405, 10456, 7450, 26666, 5462}
local completed = {}
	if isPlayer(thing.uid) then
		for i = 1, #quests do
			if getPlayerStorageValue(thing.uid, quests[i]) > 0 then
				table.insert(completed, 1)
			end
		end
		doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == 0 and ".\nShe" or ".\nHe") .. " has completed ".. #completed .. "/" .. #quests .. " quests")
		doPlayerSendTextMessage(cid, 27, getPlayerName(thing.uid) .. " has completed " .. #completed .. "/" .. #quests .. " quests.")
	end
return true
end
 
Last edited:
Back
Top