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

RevScripts 2nd Level System (no rebirth)

alejandro762

Well-Known Member
Joined
Sep 6, 2021
Messages
225
Reaction score
63
Hello,

I'm looking to get a second level in game showed when looking on player and also using a talk action.
Using TFS 1.3,

Example:
You see Vulkan (Level 5000). He is a sorcerer. [lvl.123]

How it works, you go farm monsters, then you will receive 100% xp, as normal, but every monster can give you 5-20% base xp to the second level, also an item like 1111 can give you some XP when you use it ( to the second level also ).
This second level using a storage for example, 18000, 100 ( 100 means , level 100 ) to give some door access for this second level.
Using a talkaction example !level to see the level, experience needed to the next level ( a cap level, for example 1000 or 2000 ).
 
Solution
I'm too fast and you used string.format in the bad way, now I can see.

Lua:
if thing:isCreature() then
            if thing:isPlayer() then
                description = string.format("%s\nLevel:  [%d]", description, thing:getStorageValue(100000))
            end
        end
Post automatically merged:

And now I understood what you would like to achieve.
If you want to remove a ⛏️ pick, just like you said
item:remove(1)

If you want to remove a target, use itemEx const.
itemEx:remove(1)

Explanation:
itemEx = targeting thing

So it does not matter where the thing is - on the ground, in a backpack.
Small up.

If anyone could make it, maybe without any experience from monsters.
For example just using an item to get the experience on this level.
For example taking a minning system , removing all functions about stones, loot, etc, and replacing the action to an item onUse, player:addExperience(500000), but on this second level and showing it on player.lua if is possible ?
 
Without source edit not, addExperience function always will be adding you exp to the main voc.
Yes, about this ok,
I mean like, Action - [1.3] Simple Mining System (https://otland.net/threads/1-3-simple-mining-system.276179/)


Removing the stone system, with storage and save the level system. The action on this it will be on use item giving xp to this level like a minning system with level, and calling it on player.lua showing the level near the name.
Is possible with for example using a task system, but im not lua scripter didnt know how to start.
Post automatically merged:

Without source edit not, addExperience function always will be adding you exp to the main voc.
Let's try.

This script give you a 'level' while minning.
Change items , is easy. Remove the item used, cid:removeItem(24807, 1) or item:remove(1)

How we can add here, detecting if the item is on backpack or at ground like target:remove(1), because added on function and added target.itemId == 24808 then, target:remove(1) having a boolean error.

Once i done the target remove , and the used item removed here, this will be done


Lua:
local mining = Action()

local config = {
maxmininglevel = 100,
storagemining = 100000,
expperlevel = 1500,
experiencemining = 125
}

local stone = {
    blue = {24808, 8633, 9798, 1354},
    green = {8640, 8636, 9791, 1353},
    lightblue = {8638, 8634, 9790, 12344},
    red = {8639, 8635, 9788, 1355},
}

local stones = {
    crystal = {stone.blue[1], stone.green[1], stone.lightblue[1], stone.red[1]},
    lcrystal = {stone.blue[2], stone.green[2], stone.lightblue[2], stone.red[2]},
    pcrystal = {stone.blue[3], stone.green[3], stone.lightblue[3], stone.red[3]},
    scrystal = {stone.blue[4], stone.green[4], stone.lightblue[4], stone.red[4]},
}

local ore = {
    blue = {12396, 7759, 5905, 2158},
    green = {2149, 7761, 12396 ,2155},
    lightblue = {2150, 7762, 12575, 2155},
    red = {2147, 7760, 5906, 2156},
}

local ores = { ore.blue[1], ore.blue[2], ore.blue[3], ore.blue[4], ore.green[1], ore.green[2], ore.green[3], ore.green[4], ore.lightblue[1], ore.lightblue[2], ore.lightblue[3], ore.lightblue[4], ore.red[1], ore.red[2], ore.red[3], ore.red[4]}

local levels = {
    {
    level = {0,19},
    stone = {stones.crystal[1], stones.crystal[2], stones.crystal[3], stones.crystal[4]},
    items = {ores[1],ores[5], ores[9], ores[13]},
    iselect = 0,
    bstart = 1,
    gstart = 2,
    lbstart = 3,
    rstart = 4,
    chance = 100, -- 30
    qtdmax = 1,
    expgainmin = 15, --15
    expgainmax = 50 --50
    },
    {
    level = {20,49},
    stone = {stones.crystal[1], stones.crystal[2], stones.crystal[3], stones.crystal[4], stones.lcrystal[1], stones.lcrystal[2], stones.lcrystal[3], stones.lcrystal[4]},
    items = {ores[1],ores[2], ores[5], ores[6], ores[9],ores[10], ores[13], ores[14]},
    iselect = 1,
    bstart = 1,
    gstart = 3,
    lbstart = 5,
    rstart = 7,
    chance = 10,
    qtdmax = 1,
    expgainmin = 25,
    expgainmax = 75
    },
    {
    level = {50,69},
    stone = {stones.crystal[1], stones.crystal[2], stones.crystal[3], stones.crystal[4], stones.lcrystal[1], stones.lcrystal[2], stones.lcrystal[3], stones.lcrystal[4], stones.pcrystal[1], stones.pcrystal[2], stones.pcrystal[3], stones.pcrystal[4]},
    items = {ores[1],ores[2], ores[3], ores[5], ores[6], ores[7], ores[9],ores[10], ores[11], ores[13], ores[14], ores[15]},
    iselect = 2,
    bstart = 1,
    gstart = 4,
    lbstart = 7,
    rstart = 10,
    chance = 10,
    qtdmax = 1,
    expgainmin = 35,
    expgainmax = 95
    },
    {
    level = {70,89},
    stone = {stones.crystal[1], stones.crystal[2], stones.crystal[3], stones.crystal[4], stones.lcrystal[1], stones.lcrystal[2], stones.lcrystal[3], stones.lcrystal[4], stones.pcrystal[1], stones.pcrystal[2], stones.pcrystal[3], stones.pcrystal[4], stones.scrystal[1], stones.scrystal[2], stones.scrystal[3], stones.scrystal[4]},
    items = {ores[1],ores[2], ores[3], ores[4], ores[5], ores[6], ores[7], ores[8], ores[9],ores[10], ores[11], ores[12], ores[13], ores[14], ores[15], ores[16]},
    iselect = 3,
    bstart = 1,
    gstart = 5,
    lbstart = 9,
    rstart = 13,
    chance = 10,
    qtdmax = 1,
    expgainmin = 55,
    expgainmax = 125
    },
    {
    level = {90,100},
    stone = {stones.crystal[1], stones.crystal[2], stones.crystal[3], stones.crystal[4], stones.lcrystal[1], stones.lcrystal[2], stones.lcrystal[3], stones.lcrystal[4], stones.pcrystal[1], stones.pcrystal[2], stones.pcrystal[3], stones.pcrystal[4], stones.scrystal[1], stones.scrystal[2], stones.scrystal[3], stones.scrystal[4]},
    items = {ores[1],ores[2], ores[3], ores[4], ores[5], ores[6], ores[7], ores[8], ores[9],ores[10], ores[11], ores[12], ores[13], ores[14], ores[15], ores[16]},
    iselect = 3,
    bstart = 1,
    gstart = 5,
    lbstart = 9,
    rstart = 13,
    chance = 10,
    qtdmax = 1,
    expgainmin = 125,
    expgainmax = 180
    }
}

function mining.onUse(cid, item, fromPosition, itemEx, toPosition)


local getMiningLevel = getPlayerStorageValue(cid, config.storagemining)
local getMiningExp = getPlayerStorageValue(cid, config.experiencemining)

    if getMiningLevel == -1 then
        setPlayerStorageValue(cid, config.storagemining, 0)
    end
    if getMiningExp < 0 then
        setPlayerStorageValue(cid, config.experiencemining, 0)
    end

    if (isInArray(stones.crystal, itemEx.itemid) or isInArray(stones.lcrystal, itemEx.itemid) or isInArray(stones.pcrystal, itemEx.itemid) or isInArray(stones.scrystal, itemEx.itemid))  then
      
        for a = 1, #levels do
            min = levels[a].level[1]; max = levels[a].level[2]

            if (getMiningLevel >= min and getMiningLevel <= max) then
                if isInArray(levels[a].stone, itemEx.itemid) then
                        if (math.random(1, 100) <= levels[a].chance) then
                            quantity = math.random(1, levels[a].qtdmax)
                            experience = math.random(levels[a].expgainmin, levels[a].expgainmax)
                                if isInArray(stone.blue, itemEx.itemid) then
                                    iselection = math.random(levels[a].bstart, levels[a].bstart + levels[a].iselect)
                                    collect = levels[a].items[iselection]
                                end
                                if isInArray(stone.green, itemEx.itemid) then
                                    iselection = math.random(levels[a].gstart, levels[a].gstart + levels[a].iselect)
                                    collect = levels[a].items[iselection]
                                end
                                if isInArray(stone.lightblue, itemEx.itemid) then
                                    iselection = math.random(levels[a].lbstart, levels[a].lbstart + levels[a].iselect)
                                    collect = levels[a].items[iselection]
                                end
                                if isInArray(stone.red, itemEx.itemid) then
                                    iselection = math.random(levels[a].rstart, levels[a].rstart + levels[a].iselect)
                                    collect = levels[a].items[iselection]
                                end
                          
                            if getMiningLevel == 100 then
                            doSendMagicEffect(toPosition, 9)
                            doPlayerSendTextMessage(cid, 22, text)
                          
                            elseif getMiningLevel <= 99 then
                          
                                if getMiningExp >= config.expperlevel then
                                    doSendMagicEffect(getCreaturePosition(cid), 49)
                                    setPlayerStorageValue(cid, config.storagemining, getMiningLevel + 1)
                                    setPlayerStorageValue(cid, config.experiencemining, getMiningExp - config.expperlevel)
                                    text = "You collected " ..quantity.. " matter" ..(quantity > 1 and "s" or "").. ". \n You have gained " ..experience.. " experience points in Mining. \n You advanced from mining skill level " ..getMiningLevel.. " to mining skill level " ..(getMiningLevel + 1).. "."
                                else
                                    setPlayerStorageValue(cid, config.experiencemining, getMiningExp + experience)
                                    text = "You collected " ..quantity.. " matter" ..(quantity > 1 and "s" or "").. ". \n You have gained " ..experience.. " experience points in Mining. \n" ..(config.expperlevel - getMiningExp - experience).. " experience points left to next level. \nCurrent Mining Skill: " ..getMiningLevel.. "."
                                end
                                doSendMagicEffect(toPosition, 9)
                                doPlayerSendTextMessage(cid, 22, text)
                                
                            end
                          
                        else
                            doPlayerSendTextMessage(cid, 22, "Working.")
                        end
                else
                    doPlayerSendTextMessage(cid, 22, "You need to get better in Mining to mining this.")
                end
            end

        end

    else
        doSendMagicEffect(getCreaturePosition(cid), 2)
        doPlayerSendTextMessage(cid, 22, "You can't mining this.")
    end

  
end

mining:id(24807)
mining:register()

Then on player.lua,
how we can call there 'the level' from this script ?
Code:
if thing:isCreature() then
        if thing:isPlayer() then
            description = string.format("%s\nLevel:  ["..getMiningLevel(thing)"]")
        end
    end

Like this i got an error onLook player
 
Last edited:
I do not know how to search items in backpacks or at a ground coz I use 0.3.6 and you 1.3. There's better functions to make it work. So I'm out.


As for the second, you use a local variable in another script and you get an error.

Try this:
Lua:
if thing:isCreature() then
        if thing:isPlayer() then
            description = string.format("%s\nLevel:  ["..getPlayerStorageValue(thing, 100000)"]")
        end
    end
 
I do not know how to search items in backpacks or at a ground coz I use 0.3.6 and you 1.3. There's better functions to make it work. So I'm out.


As for the second, you use a local variable in another script and you get an error.

Try this:
Lua:
if thing:isCreature() then
        if thing:isPlayer() then
            description = string.format("%s\nLevel:  ["..getPlayerStorageValue(thing, 100000)"]")
        end
    end
Oh, well.

Is giving also an error "attempt to call a number vale stack traceback C: at 0x7ff65ee52f50".

I got an if thing:isCreature() then function.
I try also add it on it, but giving same error.

Thanks anyway, i will wait if anyone using tfs 1.3 know how to make it working
 
I'm too fast and you used string.format in the bad way, now I can see.

Lua:
if thing:isCreature() then
            if thing:isPlayer() then
                description = string.format("%s\nLevel:  [%d]", description, thing:getStorageValue(100000))
            end
        end
Post automatically merged:

And now I understood what you would like to achieve.
If you want to remove a ⛏️ pick, just like you said
item:remove(1)

If you want to remove a target, use itemEx const.
itemEx:remove(1)

Explanation:
itemEx = targeting thing

So it does not matter where the thing is - on the ground, in a backpack.
 
Last edited:
Solution
I'm too fast and you used string.format in the bad way, now I can see.

Lua:
if thing:isCreature() then
            if thing:isPlayer() then
                description = string.format("%s\nLevel:  [%d]", description, thing:getStorageValue(100000))
            end
        end
Post automatically merged:

And now I understood what you would like to achieve.
If you want to remove a ⛏️ pick, just like you said
item:remove(1)

If you want to remove a target, use itemEx const.
itemEx:remove(1)

Explanation:
itemEx = targeting thing

So it does not matter where the thing is - on the ground, in a backpack.

Thanks is working perfect.

I just wanna know,
itemEx is Old function, but working on tfs 1.3 , then target:remove is the new one ?
Is like, if i use cid, on function i can't use player or vice versa, that is ?
 
Last edited:
Thanks is working perfect.

I just wanna know,
itemEx is Old function, but working on tfs 1.3 , then target:remove is the new one ?
Is like, if i use cid, on function i can't use player or vice versa, that is ?
You used the old function's declaration:
Lua:
function mining.onUse(cid, item, fromPosition, itemEx, toPosition)

This is a new one:
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)

So cid = player and itemEx = target
Change for the new one and it should work.
 
Back
Top