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

Blacksmith Level Limiter

cdpa2000

Member
Joined
Jan 6, 2015
Messages
58
Reaction score
5
Location
Venezuela
Hi, could anyone help me put a limitation when creating items

The items are divided into ranges, C, B, A, S, S +.

The idea would be something like:

blacksmith level: 10+ = Class C

blacksmith level: 25 = Class B

blacksmith level: 50 = Class A

blacksmith level: 75 = Class S

blacksmith level: 100 = Class S +

If you have less than 25 of the skill you can only take out class C items and so on

f2ym7XJTTrmwyONr9_O6sQ.png

I'm not sure if I'm posting it in the right place, if not, please move it
Thanks in advance and sorry for the inconvenience​
 
It's hard to do without you providing any code at all so we can see how your script works.

I'm gonna assume that you have a table of craftable items, and each of these items falls into a certain class.
This is an example of what such a table entry might look like:

Lua:
local tableOfCraftableItems = {
    [ID] = {
        requiredMaterials = {
            [id]=stacks,
            [id]=stacks, 
        ...
        }
    }
}

We would have to add an entry to each item called class and write which class it was, so it would look something like this:

Lua:
local tableOfCraftableItems = {
    [ID] = {
        class = "S+",
        requiredMaterials = {
            [id]=stacks,
            [id]=stacks,
        ...
        }
    }
}

And then you could use a function to check if player can craft a certain class of an item:

Lua:
-- This function will return true if player can craft an item of a certain class.
function canPlayerCraftItemClass(cid, class)
    local itemClasses = {
        ["S+"] = 100,
        ["S"] = 75,
        ["A"] = 50,
        ["B"] = 25,
        ["C"] = 15,
        ["D"] = 0
    }
   
    local mySkill = getPlayerSkillLevel(cid, BLACKSMITHING_SKILL) -- Change this variable to contain the player's blacksmithing skill level. I don't know which function or skillID you use, since it's a custom skill.
   
    if itemClasses[class] then
        if mySkill >= itemClasses[class] then
            return true
        end
    else
        print("Specified item class does not exist in the itemClasses table.")
    end
    return false
end

like

Lua:
if canPlayerCraftItemClass(cid, tableOfCraftableItems[ID].class) then
    -- code for crafting the item
else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You lack skill to craft this class of item.")
    return true
end

Maybe this information can help you on your way to create this, but like I mentioned above, it's really hard to help you integrate anything new into your script directly if you don't provide the script.
 
It's hard to do without you providing any code at all so we can see how your script works.

I'm gonna assume that you have a table of craftable items, and each of these items falls into a certain class.
This is an example of what such a table entry might look like:

Lua:
local tableOfCraftableItems = {
    [ID] = {
        requiredMaterials = {
            [id]=stacks,
            [id]=stacks,
        ...
        }
    }
}

We would have to add an entry to each item called class and write which class it was, so it would look something like this:

Lua:
local tableOfCraftableItems = {
    [ID] = {
        class = "S+",
        requiredMaterials = {
            [id]=stacks,
            [id]=stacks,
        ...
        }
    }
}

And then you could use a function to check if player can craft a certain class of an item:

Lua:
-- This function will return true if player can craft an item of a certain class.
function canPlayerCraftItemClass(cid, class)
    local itemClasses = {
        ["S+"] = 100,
        ["S"] = 75,
        ["A"] = 50,
        ["B"] = 25,
        ["C"] = 15,
        ["D"] = 0
    }
 
    local mySkill = getPlayerSkillLevel(cid, BLACKSMITHING_SKILL) -- Change this variable to contain the player's blacksmithing skill level. I don't know which function or skillID you use, since it's a custom skill.
 
    if itemClasses[class] then
        if mySkill >= itemClasses[class] then
            return true
        end
    else
        print("Specified item class does not exist in the itemClasses table.")
    end
    return false
end

like

Lua:
if canPlayerCraftItemClass(cid, tableOfCraftableItems[ID].class) then
    -- code for crafting the item
else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You lack skill to craft this class of item.")
    return true
end

Maybe this information can help you on your way to create this, but like I mentioned above, it's really hard to help you integrate anything new into your script directly if you don't provide the script.

The system is structured in different folders. lib, creatureScript and actions.
I can show him the necessary message, the truth is difficult for me to understand a bit although the way to do it correctly since I am still very new in that aspect, Thanks in advance
 
Back
Top