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

TFS 0.X 0.4 Recovery Exp only recovers levels from level 1 to 100, it does not recover levels from level 717217, I want it to recover levels 1 until 717217

Enderlop

Banned User
Joined
Jan 10, 2024
Messages
93
Reaction score
16
Explanation:
You bought the exp you lost on your last death from the NPC.

XML:
Lib > functions.lua add
death_tabble = {before_exp = 135215,after_exp = 135216, check = 251201}

CREATURESCRIPTS/SCRIPTS

XML:
function onLogin(cid)

registerCreatureEvent(cid, "Exp_P")

if getPlayerStorageValue(cid, death_tabble.check) >= 1 then

setPlayerStorageValue(cid, death_tabble.after_exp, getPlayerExperience(cid))

setPlayerStorageValue(cid, death_tabble.check, -1)

end

return true

end

function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)

setPlayerStorageValue(cid, death_tabble.before_exp, getPlayerExperience(cid))

setPlayerStorageValue(cid, death_tabble.check, 1)

return TRUE

end

CREATURESCRIPTS.XML

XML:
<event type="preparedeath" name="Exp_P" event="script" value="exp_buy.lua"/>

<event type="login" name="Exp_L" event="script" value="exp_buy.lua"/>

NPC

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Scrutinon" script="data/npc/scripts/expbuy.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look typeex="7825" head="7825" body="0" legs="0" feet="0" addons="0"/>
<parameters>
  <parameter key="message_greet" value="Great |PLAYERNAME|! I can {recover} the lost exp on your death." />
  <parameter key="message_decline" value="GoodBye." />
</parameters>
</npc>

NPC/SCRIPTS

XML:
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
    local msg = string.lower(msg)
    local itemid, count = 9020, 300 -- edit item id and count here

    if isInArray({"recover", "recuperar", "exp", "experience"}, msg) then
        npcHandler:say("Do you wish to recover the lost experience after your death for "..count.." "..getItemNameById(itemid).."? {yes}", cid)
        talkState[talkUser] = 1
    elseif (msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerStorageValue(cid, death_tabble.before_exp)  ~= -1 and getPlayerExperience(cid) < getPlayerStorageValue(cid, death_tabble.before_exp) then
            if doPlayerRemoveItem(cid, itemid, count) == TRUE then
                local count = (getPlayerStorageValue(cid, death_tabble.before_exp) - getPlayerStorageValue(cid, death_tabble.after_exp))
                doPlayerAddExp(cid, count)
                npcHandler:say("Thank you! Here is your experience.", cid)
            else
                npcHandler:say("Sorry, you don't have enough "..getItemNameById(itemid).."!", cid)
                talkState[talkUser] = 0
            end
        else
            npcHandler:say("Sorry, you have not died or have already recovered your lost experience!", cid)
            talkState[talkUser] = 0
        end
    elseif msg == "no" then
        npcHandler:say("Then not", cid)
        talkState[talkUser] = 0
        npcHandler:releaseFocus(cid)
    end

    return TRUE
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())
 
Last edited:
Back
Top