• 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 not working rebirth description

Thorn

Spriting since 2013
Joined
Sep 24, 2012
Messages
2,203
Solutions
1
Reaction score
921
Location
Chile
hii, i'm trying to add a rebirth system, everything is working except the on look (he has 2 prestiges, something like that)
if i'm correct i have to add a creature script lua, then add it into xml, and then add registerevent in login.lua
... well still not working, i will post my scripts if you guys could help me plzz
Code:
<event type="look" name="RebirthDescription" event="script" value="rebirthdescription.lua"/>

Code:
function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and thing.uid ~= cid then
        local sex = getPlayerSex(thing.uid)
        local message = "You see " .. getPlayerName(thing.uid) .. " (Level " .. getPlayerLevel(thing.uid) .. ")."
        if(getPlayerFlagValue(thing.uid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION)) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is a " .. getPlayerGroupName(thing.uid) .. "."
        elseif(getPlayerVocation(thing.uid) ~= 0) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is a " .. getPlayerVocationName(thing.uid):lower() .. "."
        else
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " has no vocation."
        end
        if(getPlayerNameByGUID(getPlayerPartner(thing.uid), false, false) ~= nil) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is " .. (sex == PLAYERSEX_FEMALE and "wife" or "husband") .. " of " .. getPlayerNameByGUID(getPlayerPartner(thing.uid)) .. "."
        end
        if(getPlayerGuildId(thing.uid) > 0) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is " .. (getPlayerGuildRank(thing.uid) == "" and "a member" or getPlayerGuildRank(thing.uid)) .. " of the " .. getPlayerGuildName(thing.uid)
            message = getPlayerGuildNick(thing.uid) ~= "" and message .. " (" .. getPlayerGuildNick(thing.uid) .. ")." or message .. "."
        end
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS)) then
            message = message .. "\nHealth: [" .. getCreatureHealth(thing.uid) .. " / " .. getCreatureMaxHealth(thing.uid) .. "], Mana: [" .. getCreatureMana(thing.uid) .. " / " .. getCreatureMaxMana(thing.uid) .. "]." 
        end
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION)) then
            message = message .. "\nPosition: [X: " .. position.x .. "] [Y: " .. position.y .. "] [Z: " .. position.z .. "]."
        end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, message .. (sex == PLAYERSEX_FEMALE and " \nShe" or " \nHe") .. " has prestiged " .. (getCreatureStorage(thing.uid, 85987) == -1 and "0" or getCreatureStorage(thing.uid, 85987)) .. " " .. (math.abs(getCreatureStorage(thing.uid, 85987)) == 1 and "time." or "times."))
        return false
    elseif thing.uid == cid 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) .. "]."
        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) == -1 and "0" or getCreatureStorage(cid, 85987)) .. " " .. (getCreatureStorage(cid, 85987) == 1 and "time." or "times."))
    end
    return true
end

and the register event
Code:
registerCreatureEvent(cid, "RebirthDescription")

plzzz what i'm doing wrong :(
 
hii, i'm trying to add a rebirth system, everything is working except the on look (he has 2 prestiges, something like that)
if i'm correct i have to add a creature script lua, then add it into xml, and then add registerevent in login.lua
... well still not working, i will post my scripts if you guys could help me plzz
Code:
<event type="look" name="RebirthDescription" event="script" value="rebirthdescription.lua"/>

Code:
function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and thing.uid ~= cid then
        local sex = getPlayerSex(thing.uid)
        local message = "You see " .. getPlayerName(thing.uid) .. " (Level " .. getPlayerLevel(thing.uid) .. ")."
        if(getPlayerFlagValue(thing.uid, PLAYERFLAG_SHOWGROUPINSTEADOFVOCATION)) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is a " .. getPlayerGroupName(thing.uid) .. "."
        elseif(getPlayerVocation(thing.uid) ~= 0) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is a " .. getPlayerVocationName(thing.uid):lower() .. "."
        else
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " has no vocation."
        end
        if(getPlayerNameByGUID(getPlayerPartner(thing.uid), false, false) ~= nil) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is " .. (sex == PLAYERSEX_FEMALE and "wife" or "husband") .. " of " .. getPlayerNameByGUID(getPlayerPartner(thing.uid)) .. "."
        end
        if(getPlayerGuildId(thing.uid) > 0) then
            message = message .. " " .. (sex == PLAYERSEX_FEMALE and "She" or "He") .. " is " .. (getPlayerGuildRank(thing.uid) == "" and "a member" or getPlayerGuildRank(thing.uid)) .. " of the " .. getPlayerGuildName(thing.uid)
            message = getPlayerGuildNick(thing.uid) ~= "" and message .. " (" .. getPlayerGuildNick(thing.uid) .. ")." or message .. "."
        end
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEECREATUREDETAILS)) then
            message = message .. "\nHealth: [" .. getCreatureHealth(thing.uid) .. " / " .. getCreatureMaxHealth(thing.uid) .. "], Mana: [" .. getCreatureMana(thing.uid) .. " / " .. getCreatureMaxMana(thing.uid) .. "]."
        end
        if(getPlayerFlagValue(cid, PLAYERCUSTOMFLAG_CANSEEPOSITION)) then
            message = message .. "\nPosition: [X: " .. position.x .. "] [Y: " .. position.y .. "] [Z: " .. position.z .. "]."
        end
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, message .. (sex == PLAYERSEX_FEMALE and " \nShe" or " \nHe") .. " has prestiged " .. (getCreatureStorage(thing.uid, 85987) == -1 and "0" or getCreatureStorage(thing.uid, 85987)) .. " " .. (math.abs(getCreatureStorage(thing.uid, 85987)) == 1 and "time." or "times."))
        return false
    elseif thing.uid == cid 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) .. "]."
        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) == -1 and "0" or getCreatureStorage(cid, 85987)) .. " " .. (getCreatureStorage(cid, 85987) == 1 and "time." or "times."))
    end
    return true
end

and the register event
Code:
registerCreatureEvent(cid, "RebirthDescription")

plzzz what i'm doing wrong :(
Maybe your Login.lua dosnt work

This one works for me
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    if (getConfigValue("accountManager") == FALSE and getCreatureName(cid) == "Account Manager") then
        return false
    end

    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")
        registerCreatureEvent(cid, "ZombieAttack")
        registerCreatureEvent(cid, "RedSkullAmulet")
        registerCreatureEvent(cid, "RebirthDescription")
    registerCreatureEvent(cid,'SpellUp')


    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    return true
end
 
but i can't replace my login lua for yours D: i have unique things, take a look
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
accountManager = "Account Manager"                     
managerCounter = 0

  for i, player in ipairs(getOnlinePlayers()) do
      if accountManager:lower() == player:lower() then           
      managerCounter = managerCounter + 1
      end
  end
function onLogin(cid)
        if isPlayer(cid) and getPlayerPromotionLevel(cid) == 2 then
                doPlayerSetPromotionLevel(cid, 1)
        end
end

  if managerCounter >= 3 then
      return false
  end
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
        doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, loss * 10)
        doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")

    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    registerCreatureEvent(cid, "attackguild")   
    registerCreatureEvent(cid, "advance")
    registerCreatureEvent(cid, "SkullCheck")
    registerCreatureEvent(cid, "demonOakLogout")
    registerCreatureEvent(cid, "demonOakDeath")
    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "30")
    registerCreatureEvent(cid, "ExpVip")
        registerCreatureEvent(cid, "Achievements")
    registerCreatureEvent(cid, "PlayerKill")
    registerCreatureEvent(cid, "task_count")
    registerCreatureEvent(cid, "teleportmonster")
    registerCreatureEvent(cid, "inquisitionPortals")
    registerCreatureEvent(cid, "KillingInTheNameOf")
        registerCreatureEvent(cid, "fullmh")
    registerCreatureEvent(cid, "partyAndGuildProtection")
    registerCreatureEvent(cid, "LevelRecompense")
    registerCreatureEvent(cid, "zombieevent")
    registerCreatureEvent(cid, "ZombieMw")
    registerCreatureEvent(cid, "zombieevent")
        registerCreatureEvent(cid, "MonsterPortal")
        registerCreatureEvent(cid, "MonsterPortal2")                     
        registerCreatureEvent(cid, "MonsterPortal3")
        registerCreatureEvent(cid, "MonsterPortal4")
        registerCreatureEvent(cid, "MonsterPortal5")
        registerCreatureEvent(cid, "RebirthDescription")

    if (InitArenaScript ~= 0) then
    InitArenaScript = 1

        for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end

    if getPlayerStorageValue(cid, 42309) < 1 then
        for i = 42300, 42309 do
            setPlayerStorageValue(cid, i, 0)
        end
    end

    if getPlayerStorageValue(cid, 42319) < 1 then
        for i = 42310, 42319 do
            setPlayerStorageValue(cid, i, 0)
        end
    end

    if getPlayerStorageValue(cid, 42329) < 1 then
        for i = 42320, 42329 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0)
    end
    setPlayerStorageValue(cid, 42350, 0)
    setPlayerStorageValue(cid, 42352, 0)

return true
end


plzzz anyone is there another solution?
 
Please... INDENT your code properly...

Try this:
Code:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    accountManager = "Account Manager"                   
    managerCounter = 0
    for i, player in ipairs(getOnlinePlayers()) do
        if accountManager:lower() == player:lower() then
            managerCounter = managerCounter + 1
        end
    end

    if isPlayer(cid) and getPlayerPromotionLevel(cid) == 2 then
        doPlayerSetPromotionLevel(cid, 1)
    end

    if managerCounter >= 3 then
        return false
    end
   
    local loss = getConfigValue('deathLostPercent')
    if loss ~= nil then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
        doPlayerSetLossPercent(cid, PLAYERLOSS_SKILLS, loss * 10)
        doPlayerSetLossPercent(cid, PLAYERLOSS_MANA, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if accountManager == MANAGER_NONE then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "GuildMotd")

    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end

    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    registerCreatureEvent(cid, "attackguild") 
    registerCreatureEvent(cid, "advance")
    registerCreatureEvent(cid, "SkullCheck")
    registerCreatureEvent(cid, "demonOakLogout")
    registerCreatureEvent(cid, "demonOakDeath")
    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "30")
    registerCreatureEvent(cid, "ExpVip")
    registerCreatureEvent(cid, "Achievements")
    registerCreatureEvent(cid, "PlayerKill")
    registerCreatureEvent(cid, "task_count")
    registerCreatureEvent(cid, "teleportmonster")
    registerCreatureEvent(cid, "inquisitionPortals")
    registerCreatureEvent(cid, "KillingInTheNameOf")
    registerCreatureEvent(cid, "fullmh")
    registerCreatureEvent(cid, "partyAndGuildProtection")
    registerCreatureEvent(cid, "LevelRecompense")
    registerCreatureEvent(cid, "zombieevent")
    registerCreatureEvent(cid, "ZombieMw")
    registerCreatureEvent(cid, "zombieevent")
    registerCreatureEvent(cid, "MonsterPortal")
    registerCreatureEvent(cid, "MonsterPortal2")                   
    registerCreatureEvent(cid, "MonsterPortal3")
    registerCreatureEvent(cid, "MonsterPortal4")
    registerCreatureEvent(cid, "MonsterPortal5")
    registerCreatureEvent(cid, "RebirthDescription")

    if (InitArenaScript ~= 0) then
        InitArenaScript = 1
        for i = 42300, 42309 do
            setGlobalStorageValue(i, 0)
            setGlobalStorageValue(i+100, 0)
        end
    end

    if getPlayerStorageValue(cid, 42309) < 1 then
        for i = 42300, 42309 do
            setPlayerStorageValue(cid, i, 0)
        end
    end

    if getPlayerStorageValue(cid, 42319) < 1 then
        for i = 42310, 42319 do
            setPlayerStorageValue(cid, i, 0)
        end
    end

    if getPlayerStorageValue(cid, 42329) < 1 then
        for i = 42320, 42329 do
            setPlayerStorageValue(cid, i, 0)
        end
    end
    if getPlayerStorageValue(cid, 42355) == -1 then
        setPlayerStorageValue(cid, 42355, 0)
    end
    setPlayerStorageValue(cid, 42350, 0)
    setPlayerStorageValue(cid, 42352, 0)

    return true
end
 
@pepe i tried yours and didn't work, @Himii here it is my prestige script, hope it helps
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local t = {}
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
    elseif(msgcontains(msg, 'prestige')) then
        selfSay('Are you ready to prestige and start a new life?', cid)
        t[cid] = 1
    elseif(msgcontains(msg, 'yes') and t[cid] == 1) then
        -------CONFIGS-------
        local level = 400
        local cost = 10000
        local hppercent = 85 -- change xx to the percent
        local mppercent = 75 -- change xx to the percent
        ------/CONFIGS-------
        local storage = getCreatureStorage(cid, 85987)
    if(storage < 20) then
        if getPlayerLevel(cid) >= level then
            if getPlayerPromotionLevel(cid) >= 0 then
                if doPlayerRemoveMoney(cid, cost) then
                    doCreatureSetStorage(cid, 85987, math.max(0, storage) + 1)
                    local hp, mana = math.floor((getCreatureMaxHealth(cid)/100)*hppercent), math.floor((getCreatureMaxMana(cid)/100)*mppercent)
                    local q = "UPDATE `players` SET `level` = 8, health = ".. hp ..", healthmax = ".. hp ..", `experience` = 4200, mana = ".. mana ..", manamax = ".. mana .." WHERE `id` = ".. getPlayerGUID(cid)
                    doRemoveCreature(cid)
                    db.executeQuery(q)
                else
                    selfSay('You don\'t have enough money. You need to pay ".. cost .." gold coins to be rebirthed.', cid)
                    t[cid] = 0
                end
            else
                selfSay('Please talk with Promotion Guy and promote first.', cid)
                t[cid] = 0
            end
        else
            selfSay('Only characters of level "400" or higher can be rebirthed.', cid)
            t[cid] = 0
        end
    else
        selfSay('You have already reached the highest prestige available.', cid)
        t[cid] = 0
    end
    elseif(msgcontains(msg, 'no') and t[cid] == 1) then
        selfSay('Okey. Come back when you feel ready.', cid)
        t[cid] = 0
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Im not that much of an scripter but this is what i shuld have done:
Execuse this in your database:
PHP:
ALTER TABLE `players` ADD `rebirths` INT NOT NULL DEFAULT 0;

Replace your prestige script with this:
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local t = {}
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
    elseif(msgcontains(msg, 'prestige')) then
        selfSay('Are you ready to prestige and start a new life?', cid)
        t[cid] = 1
    elseif(msgcontains(msg, 'yes') and t[cid] == 1) then
        -------CONFIGS-------
        local level = 400
        local cost = 10000
        local hppercent = 85 -- change xx to the percent
        local mppercent = 75 -- change xx to the percent
        ------/CONFIGS-------
        local storage = getCreatureStorage(cid, 85987)
    if(storage < 20) then
        if getPlayerLevel(cid) >= level then
            if getPlayerPromotionLevel(cid) >= 0 then
                if doPlayerRemoveMoney(cid, cost) then
                    doCreatureSetStorage(cid, 85987, math.max(0, storage) + 1)
                    local hp, mana = math.floor((getCreatureMaxHealth(cid)/100)*hppercent), math.floor((getCreatureMaxMana(cid)/100)*mppercent)
                    local q = "UPDATE `players` SET `level` = 8, health = ".. hp ..", healthmax = ".. hp ..", `experience` = 4200, mana = ".. mana ..", manamax = ".. mana .." WHERE `id` = ".. getPlayerGUID(cid)
                    local r = "UPDATE `players` SET `Rebirths` = `Rebirths` + " .. rebs .. " WHERE id=" .. getPlayerGUID(cid)
                    doRemoveCreature(cid)
                    db.executeQuery(q)
                    db.executeQuery(r)
                else
                    selfSay('You don\'t have enough money. You need to pay ".. cost .." gold coins to be rebirthed.', cid)
                    t[cid] = 0
                end
            else
                selfSay('Please talk with Promotion Guy and promote first.', cid)
                t[cid] = 0
            end
        else
            selfSay('Only characters of level "400" or higher can be rebirthed.', cid)
            t[cid] = 0
        end
    else
        selfSay('You have already reached the highest prestige available.', cid)
        t[cid] = 0
    end
    elseif(msgcontains(msg, 'no') and t[cid] == 1) then
        selfSay('Okey. Come back when you feel ready.', cid)
        t[cid] = 0
    end
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

and your rebirthdescription.lua with:
Code:
function onLook(cid, thing, position, lookDistance)
    if(isPlayer(thing.uid) and thing.uid ~= cid and getPlayerRebirth(thing.uid) ~= -1) then
        doPlayerSetSpecialDescription(thing.uid, (getPlayerSex(thing.uid) == PLAYERSEX_FEMALE and ".\nShe" or ".\nHe") .. " has " .. getPlayerRebirth(thing.uid) .. " " .. (getPlayerRebirth(thing.uid) == 1 and "rebirths" or "rebirth"))
    elseif(thing.uid == cid and getPlayerRebirth(cid) ~= -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(getPlayerByName(getPlayerPartner(cid), false, false) ~= nil) then
            message = message .. " You are " .. (getPlayerSex(cid) == PLAYERSEX_FEMALE and "wife" or "husband") .. " of " .. getPlayerByName(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)) .. "."
        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 " .. getPlayerRebirth(cid) .. " " .. (getPlayerRebirth(cid) == 1 and "times." or "time."))
    end
    return true
end

and added in lib/050-functions:
Code:
function getPlayerRebirth(cid)
    local Info = db.getResult("SELECT `Rebirths` FROM `players` WHERE `id` = " .. getPlayerGUID(cid) .. " LIMIT 1")
        if Info:getID() ~= LUA_ERROR then
        local rebs= Info:getDataInt("Rebirths")
        Info:free()
        return rebs
    end
    return LUA_ERROR
end
function doAddRebirth(cid, rebs)
    db.executeQuery("UPDATE `players` SET `Rebirths` = `Rebirths` + " .. rebs .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
function doRemoveRebirth(cid, rebs)
    db.executeQuery("UPDATE `players` SET `Rebirths` = `Rebirths` - " .. rebs .. " WHERE `id` = " .. getPlayerGUID(cid) .. ";")
end
 
Last edited:
yeah, i will, now i'm just working, i don't need a website for now :/
i used to have my server in the 8.6 version, everything worked fine (prestige things) and now i changed to 9.83, everything is working good, except that onlook thing :(
 
Last edited:
Back
Top