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

Solved Prestige npc not reseting level

Wolffy

Active Member
Joined
Mar 29, 2009
Messages
282
Reaction score
29
Im using 0.4 tfs and getting this error


Code:
[20:10:39.444] [Error - NpcScript Interface]
[20:10:39.444] data/npc/scripts/rebirth.lua:onCreatureSay
[20:10:39.444] Description:
[20:10:39.444] data/npc/scripts/rebirth.lua:50: attempt to call field 'executeQuery' (a nil value)
[20:10:39.460] stack traceback:
[20:10:39.460]  data/npc/scripts/rebirth.lua:50: in function 'callback'
[20:10:39.460]  data/npc/lib/npcsystem/npchandler.lua:390: in function 'onCreatureSay'
[20:10:39.460]  data/npc/scripts/rebirth.lua:8: in function <data/npc/scripts/rebirth.lua:8>

Here is the 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 = 717217
        local cost = 0
        ------/CONFIGS-------
        -----LOCALS-----
        local id = getPlayerGUID(cid)
        local name = getCreatureName(cid)
        local vocation = getPlayerVocation(cid)
        local storage = getCreatureStorage(cid, 4500)
        local Max_Rebirth = 10000  --Change this for the number of rebirths

local spellReborn = {
    [1] = 'Reborn1',
    [5] = 'Reborn5',
    [10] = 'Reborn10',
    [25] = 'Reborn25',
    [50] = 'Reborn50',
    [100] = 'Reborn100',
    [250] = 'Reborn250',
    [500] = 'Reborn500'
}

        ----/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, 9}, 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` = 8, `experience` = 4200")
                    db.executequery("UPDATE `players` SET `name` = '"..name.."' WHERE `id` ='"..id.."';")
                else
                    selfSay('Please do the promotion quest first.', cid)
                    talkState[talkUser] = 0
                end
            else
                selfSay('You don\'t have enough money. You need to pay 5 Crystal Coins to be prestiged.', cid)
                talkState[talkUser] = 0
            end
        else
            selfSay('You have reached the maximum rebirth.', cid)
            talkState[talkUser] = 0
        end
    else
        selfSay('Only characters of level 500 or higher can be prestiged.', 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())
 
Back
Top