• 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 Rewrite to 1.2 help

insebbe123

New Member
Joined
Mar 31, 2012
Messages
42
Best answers
0
Reaction score
0
hello, im trying to make a rebirth script work on my 1.2 with 8.6 server
but i doesn't know how to make the prestige/rebirth update in database when i remove rebirth in database it doesn't update in script,
so i can't remove prestiges via database please help


prestige.lua
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)
    local player = Player(cid)
    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 startlevel = 8
        local exp = 4200
        local level = 5000
        local cost = 0
        ------/CONFIGS-------
        -----LOCALS-----
        local id = player:getGuid()
        local name = player:getName()
        local vocation = player:getVocation() and player:getVocation():getId() or 0
        local storage = player:getStorageValue(85987)
        local Max_Rebirth = 10000  --Change this for the number of rebirths
        ----/LOCALS-----
        if(player:getLevel() >= level) then
        if player:getStorageValue(85987) < Max_Rebirth then
            if(player:removeMoney(cost) == TRUE) then
                if(isInArray({5, 6, 7, 8}, vocation)) then
                    player:setStorageValue(85987, storage == -1 and 1 or storage + 1)
                                db.query('UPDATE players SET rebirths =rebirths+'.. 1 ..' WHERE id = '..player:getGuid())
                                player:remove()
                                db.query("UPDATE `players` SET `level` = 8, `experience` = 4200 WHERE `id` ='"..id.."';")
                                db.query("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 0 mil 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 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())
player.lua
Code:
function Player:onLook(thing, position, distance)

    local description = "You see " .. thing:getDescription(distance)

    if self:getGroup():getAccess() then

        if thing:isItem() then

            description = string.format("%s\nItem ID: %d", description, thing:getId())



            local actionId = thing:getActionId()

            if actionId ~= 0 then

                description = string.format("%s, Action ID: %d", description, actionId)

            end



            local uniqueId = thing:getAttribute(ITEM_ATTRIBUTE_UNIQUEID)

            if uniqueId > 0 and uniqueId < 65536 then

                description = string.format("%s, Unique ID: %d", description, uniqueId)

            end



            local itemType = thing:getType()



            local transformEquipId = itemType:getTransformEquipId()

            local transformDeEquipId = itemType:getTransformDeEquipId()

            if transformEquipId ~= 0 then

                description = string.format("%s\nTransforms to: %d (onEquip)", description, transformEquipId)

            elseif transformDeEquipId ~= 0 then

                description = string.format("%s\nTransforms to: %d (onDeEquip)", description, transformDeEquipId)

            end



            local decayId = itemType:getDecayId()

            if decayId ~= -1 then

                description = string.format("%s\nDecays to: %d", description, decayId)

            end

        elseif thing:isCreature() then

            local str = "%s\nHealth: %d / %d"

            if thing:getMaxMana() > 0 then

                str = string.format("%s, Mana: %d / %d", str, thing:getMana(), thing:getMaxMana())

            end

            description = string.format(str, description, thing:getHealth(), thing:getMaxHealth()) .. "."

        end



        local position = thing:getPosition()

        description = string.format(

            "%s\nPosition: %d, %d, %d",

            description, position.x, position.y, position.z

        )



        if thing:isCreature() and thing:isPlayer() then

                description = string.format("%s\nIP: %s.", description, Game.convertIpToString(thing:getIp()))

            end

        end



if thing:isPlayer() and thing:isCreature() then

        description = string.format("%s\n [Prestiges: %d] \n",

            description, math.max(0, thing:getStorageValue(85987)))

    end

    self:sendTextMessage(MESSAGE_INFO_DESCR, description)

end
 
Last edited:
OP
I

insebbe123

New Member
Joined
Mar 31, 2012
Messages
42
Best answers
0
Reaction score
0
bump, i really wanna know, how can i make this better and make us of 1.x ZnoteACC with rebirths added
 
Top