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

Action Herblore / Mining Skill [TFS 1.1]

Codex, i have maaany scripts from people working on my server. Many of those are yours btw. In this one is just feels like im missing something, and i dont know what is it.

@Codex NG Stop being so sarcastic, it doesnt helps at all. All im doing here is trying by myself and asking politely.
It has been solved. Updated the main post to include this fix.
 
Works like a charm, installed it awhile ago and tried it out, but now when i actually started playing a bit on my server and tested it some more, i noticed one thing i really really need help with...

everytime i relog the mining level resets to 1, so everytime i log in i need to start all over again.
please help? ;)

Edit:
should be something to do with firstitems.lua that the player dont save storages or something..

here is my first items script
Code:
local config = {
       [1] = {
               --equipment spellbook, wand of vortex, leather armor, leather helmet, leather legs, leather boots
               items = {{2175, 1}, {2190, 1}, {2467, 1}, {2461, 1}, {2649, 1}, {2643, 1}},
               --container rope, shovel, mana potion
               container = {{2120, 1}, {2554, 1}, {7620, 1}}
       },
       [2] = {
               --equipment dwrven shield, 5 spear, leather armor, leather legs, leather helmet
               items = {{2512, 1}, {2389, 10}, {2467, 1}, {2649, 1}, {2643, 1}, {2461, 1}},
               --container rope, shovel, health potion
               container = {{2120, 1}, {2554, 1}, {7618, 1}}
       },
       [3] = {
               --equipment dwarven shield, steel axe, leather armor, leather helmet, leather legs
               items = {{2512, 1}, {8601, 1}, {2467, 1}, {2461, 1}, {2649, 1}, {2643, 1}},
               --container jagged sword, daramian mace, rope, shovel, health potion
               container = {{8602, 1}, {2439, 1}, {2120, 1}, {2554, 1}, {7618, 1}}
       }
}

function onLogin(cid)
   local player = Player(cid)
   local targetVocation = config[player:getVocation():getId()]
   if not targetVocation then
       return true
   end

   if player:getLastLoginSaved() ~= 0 then
       player:setStorageValue(15002, 1)  -- Mining Skill
       player:setStorageValue(15003, 0)  -- Mining Skill Tries
       player:setStorageValue(16002, 1)  -- woodcutting skill
       player:setStorageValue(16003, 0)  -- woodcutting skill Tries
       return true
   end

   for i = 1, #targetVocation.items do
       player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
   end

   local backpack = player:addItem(1988)
   if not backpack then
       return true
   end

   for i = 1, #targetVocation.container do
       backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
   end
   return true
end
 
Last edited:
Works like a charm, installed it awhile ago and tried it out, but now when i actually started playing a bit on my server and tested it some more, i noticed one thing i really really need help with...

everytime i relog the mining level resets to 1, so everytime i log in i need to start all over again.
please help? ;)

Edit:
should be something to do with firstitems.lua that the player dont save storages or something..

here is my first items script
Code:
local config = {
       [1] = {
               --equipment spellbook, wand of vortex, leather armor, leather helmet, leather legs, leather boots
               items = {{2175, 1}, {2190, 1}, {2467, 1}, {2461, 1}, {2649, 1}, {2643, 1}},
               --container rope, shovel, mana potion
               container = {{2120, 1}, {2554, 1}, {7620, 1}}
       },
       [2] = {
               --equipment dwrven shield, 5 spear, leather armor, leather legs, leather helmet
               items = {{2512, 1}, {2389, 10}, {2467, 1}, {2649, 1}, {2643, 1}, {2461, 1}},
               --container rope, shovel, health potion
               container = {{2120, 1}, {2554, 1}, {7618, 1}}
       },
       [3] = {
               --equipment dwarven shield, steel axe, leather armor, leather helmet, leather legs
               items = {{2512, 1}, {8601, 1}, {2467, 1}, {2461, 1}, {2649, 1}, {2643, 1}},
               --container jagged sword, daramian mace, rope, shovel, health potion
               container = {{8602, 1}, {2439, 1}, {2120, 1}, {2554, 1}, {7618, 1}}
       }
}

function onLogin(cid)
   local player = Player(cid)
   local targetVocation = config[player:getVocation():getId()]
   if not targetVocation then
       return true
   end

   if player:getLastLoginSaved() ~= 0 then
       player:setStorageValue(15002, 1)  -- Mining Skill
       player:setStorageValue(15003, 0)  -- Mining Skill Tries
       player:setStorageValue(16002, 1)  -- woodcutting skill
       player:setStorageValue(16003, 0)  -- woodcutting skill Tries
       return true
   end

   for i = 1, #targetVocation.items do
       player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
   end

   local backpack = player:addItem(1988)
   if not backpack then
       return true
   end

   for i = 1, #targetVocation.container do
       backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
   end
   return true
end

I really saw this too late I think, lol
Anyways, if anyone is using this and finds this issue, just change this line:
Code:
if player:getLastLoginSaved() ~= 0 then
To:
Code:
if player:getLastLoginSaved() <= 0 then
 
Its never to late my friend!
I did not test this yet but thanks for helping out :)
That change will add the skill only if player has NEVER logged in. If you already have players created that don't have the skill, you could add an special check for them:

Code:
if player:getStorageValue(15002) == -1 then        --Mining check
    player:setStorageValue(15002, 1)
    player:setStorageValue(15003, 0)
    return true
end

if player:getStorageValue(16002) == -1 then        --Lumberjacking check
    player:setStorageValue(16002, 1)
    player:setStorageValue(16003, 0)
    return true
end
 
Its been so long, will need to add everything all over again to my new test server, thing is... just noticed its for 1.1 you think it will work for 1.2? :)
 
Its been so long, will need to add everything all over again to my new test server, thing is... just noticed its for 1.1 you think it will work for 1.2? :)
I have indeed used it in 1.2 without any modification whatsoever, so yeah, it would work.
Also, just to point it out, it's been quite some time since I've done this and to be honest it looks way too simple. If you would like a different behaviour/have different ideas about how to implement it I could do an special script that suits your need..As i'm kinda bored these days XD
 
hi i have an issue, when i try to harvest it ask me to be level one also for mine i change to zero and now tells me i need skill 0 to harvest mine
 
hi i have an issue, when i try to harvest it ask me to be level one also for mine i change to zero and now tells me i need skill 0 to harvest mine

This is why, you don't have the storages assigned to the player. Not assigned is not even 0, it's -1. So that's why changing the script to zero won't work.
Also, remember to add the skill storages to the player (With firstitems.lua) or whatever method you see fit.

You can add something like this in login.lua so existing players will get the skill on level 1 after they log in.
Code:
local skill = xxxx
    local storage = player:getStorageValue(skill)
   
    if storage == -1 then
        player:setStorageValue(skill, 1)
        player:setStorageValue(skill + 1, 0)
    end
 
This is why, you don't have the storages assigned to the player. Not assigned is not even 0, it's -1. So that's why changing the script to zero won't work.
Also, remember to add the skill storages to the player (With firstitems.lua) or whatever method you see fit.

You can add something like this in login.lua so existing players will get the skill on level 1 after they log in.
Code:
local skill = xxxx
    local storage = player:getStorageValue(skill)
  
    if storage == -1 then
        player:setStorageValue(skill, 1)
        player:setStorageValue(skill + 1, 0)
    end

thanks the storage from the action script and the firstitems.lua i put was incorrect
now it works but dont know why i dont receive my firstitems i place the code correctly? heres my script
Code:
-- Without Rookgaard
local config = {
    [0] = {
        --club, coat
        items = {{2510, 1}, {2480, 1}, {2464, 1}, {2468, 1}, {2643, 1}, {2412, 1}},
        --container rope, shovel, red apple
        container = {{2120, 1}, {2666, 1}, {2554, 1}}
    },   
    [1] = {
        --equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf
        items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, rope, shovel, mana potion
        container = {{2152, 20}, {7620, 5}, {18559, 1}}
    },
    [13] = {
        --equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf
        items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, rope, shovel, mana potion
        container = {{2152, 20}, {7620, 5}, {18559, 1}}
    },
    [2] = {
        --equipment spellbook, snakebite rod, magician' robe, mage hat, studded legs, leather boots scarf
        items = {{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, rope, shovel, mana potion
        container = {{2152, 20}, {7620, 5}, {18559, 1}}
    },
    [3] = {
        --equipment dwarven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet
        items = {{2456, 1}, {2465, 1}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
        --container platinum coin, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {7618, 5}, {7620, 5}, {2544, 100}, {18559, 1}}
    },
    [15] = {
        --equipment dwarven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet
        items = {{2525, 1}, {2389, 5}, {2465, 1}, {2478, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
        --container platinum coin, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {7618, 5}, {7620, 5}, {18559, 1}}
    },
    [17] = {
        --equipment dwarven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet
        items = {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
        --container platinum coin, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {7618, 5}, {7620, 5}, {18559, 1}}
    },
    [4] = {
        --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf
        items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, jagged sword, daramian mace, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {8602, 1}, {2439, 1}, {7618, 5}, {7620, 5}, {18559, 1}}
    },
    [9] = {
        --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf
        items = {{2378, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, jagged sword, daramian mace, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {2413, 1}, {2321, 1}, {7618, 5}, {7620, 5}, {18559, 1}}
    },
    [11] = {
        --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf
        items = {{2525, 1}, {8601, 1}, {2485, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, jagged sword, daramian mace, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {8602, 1}, {2439, 1}, {7618, 5}, {7620, 5}, {18559, 1}}
    }
}

function onLogin(player)
    local targetVocation = config[player:getVocation():getId()]
    if not targetVocation then
        return true
    end

    if player:getStorageValue(15002) == -1 then        --Mining check
    player:setStorageValue(15002, 1)
    player:setStorageValue(15003, 0)
    return true
end

if player:getStorageValue(16002) == -1 then        --Lumberjacking check
    player:setStorageValue(16002, 1)
    player:setStorageValue(16003, 0)
    return true
end
    if (player:getSlotItem(CONST_SLOT_LEFT)) then

        return true
    end

    for i = 1, #targetVocation.items do
        player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
    end

    local backpack = player:getVocation():getId() == 0 and player:addItem(1987) or player:addItem(1988)
    if not backpack then
        return true
    end

    for i = 1, #targetVocation.container do
        backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
    end
    return true
end
 
thanks the storage from the action script and the firstitems.lua i put was incorrect
now it works but dont know why i dont receive my firstitems i place the code correctly? heres my script
Code:
-- Without Rookgaard
local config = {
    [0] = {
        --club, coat
        items = {{2510, 1}, {2480, 1}, {2464, 1}, {2468, 1}, {2643, 1}, {2412, 1}},
        --container rope, shovel, red apple
        container = {{2120, 1}, {2666, 1}, {2554, 1}}
    },  
    [1] = {
        --equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf
        items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, rope, shovel, mana potion
        container = {{2152, 20}, {7620, 5}, {18559, 1}}
    },
    [13] = {
        --equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf
        items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, rope, shovel, mana potion
        container = {{2152, 20}, {7620, 5}, {18559, 1}}
    },
    [2] = {
        --equipment spellbook, snakebite rod, magician' robe, mage hat, studded legs, leather boots scarf
        items = {{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, rope, shovel, mana potion
        container = {{2152, 20}, {7620, 5}, {18559, 1}}
    },
    [3] = {
        --equipment dwarven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet
        items = {{2456, 1}, {2465, 1}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
        --container platinum coin, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {7618, 5}, {7620, 5}, {2544, 100}, {18559, 1}}
    },
    [15] = {
        --equipment dwarven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet
        items = {{2525, 1}, {2389, 5}, {2465, 1}, {2478, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
        --container platinum coin, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {7618, 5}, {7620, 5}, {18559, 1}}
    },
    [17] = {
        --equipment dwarven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet
        items = {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
        --container platinum coin, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {7618, 5}, {7620, 5}, {18559, 1}}
    },
    [4] = {
        --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf
        items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, jagged sword, daramian mace, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {8602, 1}, {2439, 1}, {7618, 5}, {7620, 5}, {18559, 1}}
    },
    [9] = {
        --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf
        items = {{2378, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, jagged sword, daramian mace, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {2413, 1}, {2321, 1}, {7618, 5}, {7620, 5}, {18559, 1}}
    },
    [11] = {
        --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf
        items = {{2525, 1}, {8601, 1}, {2485, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
        --container platinum coin, jagged sword, daramian mace, rope, shovel, health potion, mana potion
        container = {{2152, 20}, {8602, 1}, {2439, 1}, {7618, 5}, {7620, 5}, {18559, 1}}
    }
}

function onLogin(player)
    local targetVocation = config[player:getVocation():getId()]
    if not targetVocation then
        return true
    end

    if player:getStorageValue(15002) == -1 then        --Mining check
    player:setStorageValue(15002, 1)
    player:setStorageValue(15003, 0)
    return true
end

if player:getStorageValue(16002) == -1 then        --Lumberjacking check
    player:setStorageValue(16002, 1)
    player:setStorageValue(16003, 0)
    return true
end
    if (player:getSlotItem(CONST_SLOT_LEFT)) then

        return true
    end

    for i = 1, #targetVocation.items do
        player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
    end

    local backpack = player:getVocation():getId() == 0 and player:addItem(1987) or player:addItem(1988)
    if not backpack then
        return true
    end

    for i = 1, #targetVocation.container do
        backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
    end
    return true
end
Sorry for the late reply, been busy these days. You could try removing the returns after the checking part, it should look like this:
Code:
if player:getStorageValue(15002) == -1 then        --Mining check
    player:setStorageValue(15002, 1)
    player:setStorageValue(15003, 0)
end

if player:getStorageValue(16002) == -1 then        --Lumberjacking check
    player:setStorageValue(16002, 1)
    player:setStorageValue(16003, 0)
end
Please try it and see if it works now.


is there a way to check your current minning skill?
Indeed there is, you just need the storage value you assigned to that particular skill. Let's say you used 15002 for Mining.
Code:
player:getCustomSkill(15002)
That function will return you the level of the skill assigned to Mining, also you can see the % left you need to advance in a skill using:
Code:
player:getCustomSkillPercent(15002)
Useful to make some talkactions for players to check how their skill is going.
 
Sorry for the late reply, been busy these days. You could try removing the returns after the checking part, it should look like this:
Code:
if player:getStorageValue(15002) == -1 then        --Mining check
    player:setStorageValue(15002, 1)
    player:setStorageValue(15003, 0)
end

if player:getStorageValue(16002) == -1 then        --Lumberjacking check
    player:setStorageValue(16002, 1)
    player:setStorageValue(16003, 0)
end
Please try it and see if it works now.



Indeed there is, you just need the storage value you assigned to that particular skill. Let's say you used 15002 for Mining.
Code:
player:getCustomSkill(15002)
That function will return you the level of the skill assigned to Mining, also you can see the % left you need to advance in a skill using:
Code:
player:getCustomSkillPercent(15002)
Useful to make some talkactions for players to check how their skill is going.

thank you somuch ramiro! ive been playiing some servers and they have your systems its just so practical!
 
Lua Script Error: [Action Interface]
data/actions/scripts/craft/mining.lua:eek:nUse
data/actions/scripts/craft/mining.lua:55: attempt to call method 'getCustomSkill' (a nil value)
stack traceback:
[C]: in function 'getCustomSkill'
data/actions/scripts/craft/mining.lua:55: in function <data/actions/scripts/craft/mining.lua:52>
How to fix that function?
 
A global min/max mining level? The message is already sent like that when you install Player - Spell experience 1.2

At the top of the script you set the skill name and the storage where it will be kept.
Code:
local name = "Herblore"       -- Name of the Custom Skill
local storage = 15000       -- Storage used to store Custom Skill Levels

Whenever you advance in that skill it will print to the player "You advanced to herblore level X."
 
from first glance of the script looks like we can add as many "stones" as we like and this type of system can be used for basically any single thing you want 😮
even cook food!

i will try to "add" (convert) Smith to "Alchemy skill".
should be awesome.. will post the results if its work :)
with credits to you and the other dude who made "spell exp 1.2" :)
 
from first glance of the script looks like we can add as many "stones" as we like and this type of system can be used for basically any single thing you want 😮
even cook food!

i will try to "add" (convert) Smith to "Alchemy skill".
should be awesome.. will post the results if its work :)
with credits to you and the other dude who made "spell exp 1.2" :)
Indeed you can use it as a blueprint for those skills! By all means, go and try to do it! If you need help feel free to contact me! Good luck!
 
Back
Top