• 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 System problems

Unknown99

New Member
Joined
Aug 11, 2015
Messages
6
Reaction score
0
Hi I am having some issues with a Rebirth system when I done the rebirth it didn't show my vocation again as you can see in the screen shot below could anyone help me fix this?
 

Attachments

  • Screenshot 2023-11-24 224035.png
    Screenshot 2023-11-24 224035.png
    1.2 MB · Views: 13 · VirusTotal
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('Ready for me to rebirth you?', cid)
        talkState[talkUser] = 1

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

    local level    = 40000        -- Put here the level to rebirth
    local cost    = 20000        -- Put here the cost to rebirth in GP (20000 = 20k)

    local name = getCreatureName(cid)
    local vocation = getPlayerVocation(cid)

        if getPlayerLevel(cid) >= level then
            if doPlayerRemoveMoney(cid, cost) == TRUE then
                if vocation == 1 then
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE players SET level = 8, experience = 4200, vocation = 1 WHERE name ='"..name.."';")
                elseif vocation == 2 then
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE players SET level = 8, experience = 4200, vocation = 2 WHERE name ='"..name.."';")
                elseif vocation == 3 then
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE players SET level = 8, experience = 4200, vocation = 3 WHERE name ='"..name.."';")
                elseif vocation == 4 then
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE players SET level = 8, experience = 4200, vocation = 4 WHERE name ='"..name.."';")
                else
                    selfSay('Not a valid vocation. Contact administrator.', cid)
                    talkState[talkUser] = 0
                end
            else
                selfSay('You dont have enough money. You need to pay 20k to be rebirthed.', cid)
                talkState[talkUser] = 0
            end
        else
            selfSay('Only characters of level 40k or higher can be rebirthed.', cid)
            talkState[talkUser] = 0
        end

    elseif msgcontains(msg, 'no') and talkState[talkUser] == 1 then
        talkState[talkUser] = 0
        selfSay('Okey come back when you are ready.', cid)
    end
    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Try to replace lines 42-53 with
Code:
if vocation >= 1 and vocation <= 4 then
                    doRemoveCreature(cid)
                    db.executeQuery("UPDATE players SET level = 8, experience = 4200 WHERE name ='"..name.."';")
 
Back
Top