• 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.4] Save Player on Advance and heal optionally

Competitibia

Pain & Glory WHole
Joined
Apr 1, 2021
Messages
545
Solutions
3
Reaction score
210
creaturescripts/scripts/advancesave.lua

Lua:
local config = {
    savePlayer = true,
    healPlayerOnLevel = false
}

function onAdvance(cid, skill, oldLevel, newLevel)
    if(skill == SKILL__EXPERIENCE) then
        return true
    end

    if(skill == SKILL__LEVEL)  then
        doSendAnimatedText(getPlayerPosition(cid), "LEVEL UP", TEXTCOLOR_WHITE)
        if (config.healPlayeronLevel) then
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
        end
    end
    if(skill == SKILL__MAGLEVEL) then
        doSendAnimatedText(getPlayerPosition(cid), "MAGIC UP", TEXTCOLOR_BLUE)
    end
   
    if(skill == SKILL_AXE) then
        doSendAnimatedText(getPlayerPosition(cid), "AXE UP", TEXTCOLOR_ORANGE)
    end
    if(skill == SKILL_CLUB) then
        doSendAnimatedText(getPlayerPosition(cid), "CLUB UP", TEXTCOLOR_ORANGE)
    end
    if(skill == SKILL_SWORD) then
        doSendAnimatedText(getPlayerPosition(cid), "SWORD UP", TEXTCOLOR_ORANGE)
    end
    if(skill == SKILL_SHIELD) then
        doSendAnimatedText(getPlayerPosition(cid), "SHIELDING UP", TEXTCOLOR_ORANGE)
    end
    if(skill == SKILL_DISTANCE) then
        doSendAnimatedText(getPlayerPosition(cid), "DISTANCE UP", TEXTCOLOR_ORANGE)
    end


    if(config.savePlayer) then
        doPlayerSave(cid, true)
    end

    return true
end
/creaturescripts.xml
XML:
<event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>


/scripts/login.lua
Lua:
registerCreatureEvent(cid, "AdvanceSave")
 
Lua:
local config = {
    savePlayer = true,
    healPlayerOnLevel = false,
    skillsTable = {
        [SKILL__LEVEL] = {text = "LEVEL UP", textColor = TEXTCOLOR_WHITE},
        [SKILL__MAGLEVEL] = {text = "MAGIC UP", textColor = TEXTCOLOR_BLUE},
        [SKILL_AXE] = {text = "AXE UP", textColor = TEXTCOLOR_ORANGE},
        [SKILL_CLUB] = {text = "CLUB UP", textColor = TEXTCOLOR_ORANGE},
        [SKILL_SWORD] = {text = "SWORD UP", textColor = TEXTCOLOR_ORANGE},
        [SKILL_SHIELD] = {text = "SHIELDING UP", textColor = TEXTCOLOR_ORANGE},
        [SKILL_DISTANCE] = {text = "DISTANCE UP", textColor = TEXTCOLOR_ORANGE}   
    }
}

function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == SKILL__EXPERIENCE then
        return true
    end

    local skillTable = skillsTable[skill]
    if not skillTable then
        return true
    end

    if skill == SKILL__LEVEL and config.healPlayerOnLevel then
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
    end

    doSendAnimatedText(getPlayerPosition(cid), skillTable.text, skillTable.textColor)

    if config.savePlayer then
        doPlayerSave(cid, true)
    end

    return true
end
 
Lua:
local config = {
    savePlayer = true,
    healPlayerOnLevel = false,
    skillsTable = {
        [SKILL__LEVEL] = {text = "LEVEL UP", textColor = TEXTCOLOR_WHITE},
        [SKILL__MAGLEVEL] = {text = "MAGIC UP", textColor = TEXTCOLOR_BLUE},
        [SKILL_AXE] = {text = "AXE UP", textColor = TEXTCOLOR_ORANGE},
        [SKILL_CLUB] = {text = "CLUB UP", textColor = TEXTCOLOR_ORANGE},
        [SKILL_SWORD] = {text = "SWORD UP", textColor = TEXTCOLOR_ORANGE},
        [SKILL_SHIELD] = {text = "SHIELDING UP", textColor = TEXTCOLOR_ORANGE},
        [SKILL_DISTANCE] = {text = "DISTANCE UP", textColor = TEXTCOLOR_ORANGE} 
    }
}

function onAdvance(cid, skill, oldLevel, newLevel)
    if skill == SKILL__EXPERIENCE then
        return true
    end

    local skillTable = skillsTable[skill]
    if not skillTable then
        return true
    end

    if skill == SKILL__LEVEL and config.healPlayerOnLevel then
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
        doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
    end

    doSendAnimatedText(getPlayerPosition(cid), skillTable.text, skillTable.textColor)

    if config.savePlayer then
        doPlayerSave(cid, true)
    end

    return true
end
Funny u didn't even name the variable right.
Programming at 1 am be like 😩
 
Back
Top