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

HELP WITH REBIRTH SYSTEM

naod123456

Wazzaap
Joined
Mar 28, 2013
Messages
242
Reaction score
4
Hi!

In my server i´m using rebirth system its a war server tfs 0.4 8.6.
When sombody prestige they keep their hp and mana i don´t whant that i whanna make so they get the mana and hp of the level they are this is my rebirth.lua

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, '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 = 250
        local cost = 1
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getCreatureStorage(cid, 85987)
        local Max_Rebirth = 1000 --Change this for the number of rebirths

        ----/LOCALS-----
        if(getPlayerLevel(cid) >= level) then
        if getCreatureStorage(cid, 85987) < Max_Rebirth then
            if(doPlayerRemoveMoney(cid, cost) == TRUE) then
                if(isInArray({5, 6, 7, 8}, vocation)) then
                    doCreatureSetStorage(cid, 85987, storage == -1 and 1 or storage + 1)
                                db.executeQuery('UPDATE players SET rebirths=rebirths+'.. 1 ..' WHERE id='..getPlayerGUID(cid))
                            doBroadcastMessage("" ..  name .. " has just prestiged!", TALKTYPE_ORANGE_1)
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE `players` SET `level` = 80, `experience` = 4200")
                    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 to be rebirthed.', cid)
                talkState[talkUser] = 0
            end
        else
            selfSay('You have reached the maximum rebirth.', cid)
            talkState[talkUser] = 0
        end
    else
        selfSay('Only characters of level 250 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())

anyone ^^^
 
Last edited by a moderator:
Back
Top