• 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 npc that gives the new vocation and goes back to the 8th level

Mateus Robeerto

Excellent OT User
Joined
Jun 5, 2016
Messages
1,337
Solutions
71
Reaction score
697
Location
ლ(ಠ益ಠლ)
could someone do it for me?

example player who is master sorcerer when talking to npc that he gives the new vocation supreme sorcerer and go back to 8 level



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('When you rebirth, you can enter the rebirth area hidden under the throne right next to us.', cid)
        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 = 750000
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getPlayerStorageValue(cid, 85988)
        local skillPoints = getPlayerStorageValue(cid, 23000)
        local maxRebirth = 10  --Change this for the number of rebirths

        ----/LOCALS-----
        if(getPlayerLevel(cid) >= level) then
        if getPlayerStorageValue(cid, 85988) < maxRebirth then
            if(doPlayerRemoveMoney(cid, cost) == TRUE) then
                if(isInArray({5, 6, 7, 8}, vocation)) then
                    local player = Player(cid)
                    player:setStorageValue(85988, storage == -1 and 1 or storage + 1)
                    player:setStorageValue(23000, skillPoints == -1 and 1 or skillPoints + 1)
                    db.query('UPDATE players SET rebirths=rebirths+'.. 1 ..' WHERE id='..getPlayerGUID(cid))
                    Game.broadcastMessage("Player: " ..  name .. " just became an newborn!", MESSAGE_STATUS_WARNING)
                    doRemoveCreature(cid)
                    db.query("UPDATE `players` SET `level` = 8, `experience` = 4200, `healthmax` = 185, `health` = 185, `manamax` = 90, `mana` = 90, `cap` = 470 WHERE `id` = "..id)
                    db.query("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                else
                    selfSay('Please talk with the Forgotten King and be promoted first.', cid)
                    talkState[talkUser] = 0
                end
            else
                selfSay('You don\'t have enough money. You need to pay 750k 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 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 feel ready.', cid)
        talkState[talkUser] = 0
end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
Hi there! Glad to hear that you were able to solve the problem with your script, and congratulations on finishing it! Would you be willing to share your script with the community? I'm sure many people would appreciate it.
Also, if you don't mind, could you please specify which engine you're using in the future? It would make it easier for people to understand and help with any issues you may have. Thanks!
 
Hi there! Glad to hear that you were able to solve the problem with your script, and congratulations on finishing it! Would you be willing to share your script with the community? I'm sure many people would appreciate it.
Also, if you don't mind, could you please specify which engine you're using in the future? It would make it easier for people to understand and help with any issues you may have. Thanks!
I'm going to share the complete script here or somewhere else as soon as I leave my work and get home jaja I'm going to share it for everyone, the script is working really well, resets the level and skills, new vocations, it took me about 2 days to finish it the fuck script saw kk
Post automatically merged:

the script is complete and works well!!


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('When you rebirth, you can enter the rebirth area hidden under the throne right next to us.', cid)
        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 = 750000
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getPlayerStorageValue(cid, 85988)
        local skillPoints = getPlayerStorageValue(cid, 23000)
        local maxRebirth = 1  --Change this for the number of rebirths
        local new = (getPlayerVocation(cid)+4)

        ----/LOCALS-----
        if(getPlayerLevel(cid) >= level) then
        if getPlayerStorageValue(cid, 85988) < maxRebirth then
            if(doPlayerRemoveMoney(cid, cost) == TRUE) then
                if(isInArray({5, 6, 7, 8}, vocation)) then
                    local player = Player(cid)
                    doPlayerSetVocation(cid, new)
                    doSendMagicEffect(getCreaturePos(cid), 49)
                    player:setStorageValue(85988, storage == -1 and 1 or storage + 1)
                    player:setStorageValue(23000, skillPoints == -1 and 1 or skillPoints + 1)
                    db.query('UPDATE players SET rebirths=rebirths+'.. 1 ..' WHERE id='..getPlayerGUID(cid))
                    Game.broadcastMessage("Player: " ..  name .. " just became an newborn!", MESSAGE_STATUS_WARNING)
                    doRemoveCreature(cid)
                    db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `id` = "..id)
                    db.query("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                else
                    selfSay('Please talk with the Forgotten King and be promoted first.', cid)
                    talkState[talkUser] = 0
                end
            else
                selfSay('You don\'t have enough money. You need to pay 750k 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 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 feel ready.', cid)
        talkState[talkUser] = 0
end

    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Last edited:
it works well, but how would you not reset the skills? fist, axe, ml...
omg that was a question lol


SQL:
db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470' WHERE `id` = "..id)
 
omg that was a question lol


SQL:
db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470' WHERE `id` = "..id)
Lua:
db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `id` = "..id)
 
Lua:
db.query("UPDATE `players` SET `level` = '8', `health` = '185', `healthmax` = '185', `experience` = '4200', `maglevel` = '0', `mana` = '90', `manamax` = '90', `manaspent` = '0', `cap` = '470', `skill_fist` = '10', `skill_fist_tries` = '0', `skill_club` = '10', `skill_club_tries` = '0', `skill_sword` = '10', `skill_sword_tries` = '0', `skill_axe` = '10', `skill_axe_tries` = '0', `skill_dist` = '10', `skill_dist_tries` = '0', `skill_shielding` = '10', `skill_shielding_tries` = '0', `skill_fishing` = '10', `skill_fishing_tries` = '0' WHERE `id` = "..id)
just replace the line he said with mine @Shoorkill
 
Back
Top