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

talkaction tfs 1.4 buy skill

vitorelias1

New Member
Joined
Sep 27, 2022
Messages
27
Reaction score
2
Hi Guys!


The Demon Helmet Server - Version: (TFS 1.4)
Compiled with: Microsoft Visual C++ version 14.2
x64


I have this script but it is not working it is a command to buy skill it gives an error in the console

observations: it removes the item but does not add the skills and gives the error in the console.

needed a strength in this script. thank you!
Ícone Verificada pela comunidade


1684686147306.png

Lua:
SKILL_CLUB = "skill_club"
SKILL_DISTANCE = "skill_dist"
SKILL_SHIELD = "skill_shielding"
SKILL_MAGLEVEL = "maglevel"
SKILL_SWORD = "skill_sword"
SKILL_AXE = "skill_axe"
local buyComprar = TalkAction("!buy")
local storage = 45611
local coinID = 9971 -- currency to buy skills




local skills = {
    ["magiclevel"] = {vocations = {1, 5, 2, 6, 11, 12}, voc_msg= "Only Sorcerers, Druids and Infernalists can buy magic level.", lim = 200, lim_msg = "You cannot have magic level above 200.", price= 3, incre = 1, skill = 7},
 
}



function buyComprar.onSay(player, words, param)
    local player = Player(player)
    local pid = player:getGuid()
    local tile = player:getTile()
    local param = param:lower()
    if not tile:hasFlag(TILESTATE_PROTECTIONZONE) then
        player:sendCancelMessage("You need to be in protected area to use this command.")
        return true
    end
    if player:getStorageValue(storage) >= os.time() then
        player:sendCancelMessage("For security reasons you can only use this command in " .. player:getStorageValue(storage)-os.time() .. " seconds.")
        return true
    end
 
    if skills[param] then
        local v = skills[param]
        if param == "magiclevel" and player:getBaseMagicLevel() >= v.lim or (player:getBaseMagicLevel() + v.incre ) >= v.lim then
            player:sendCancelMessage(v.lim_msg) return true
        elseif player:getSkillLevel(v.skill) + v.incre >= v.lim then
            print("oooooookay") -- here you have to stop the code
            player:sendCancelMessage(v.lim_msg) return true           
        end
        if not isInArray(v.vocations, player:getVocation():getId()) then
            player:sendCancelMessage(v.voc_msg)
            return true
        end
        if player:getItemCount(coinID) >= v.price then
            player:removeItem(coinID, v.price)
            player:setStorageValue(storage, os.time()+1)
            player:remove()
            db.query("UPDATE players SET ".. v.skill .. " = " .. v.skill .. " + " .. v.incre .. " WHERE id = ".. pid)
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "You do not have the necessary amount to buy.")
        end
        return true
    end
    return true
end
buyComprar:separator(" ")
buyComprar:register()
 
why don't you just use the addSkill/magicLevel function instead of a query?


your query is wrong that is why it is giving an error, and also running a query into an online player doesn't work, it only works when player is offline

so it works perfectly but there is a problem the limit that I set for a player to buy skill distance, axe, sword or club is 350 and magic level 200 but using this script it does not obey the limit and is stuck skill distance ex; 208 and magic level, max is 156



Lua:
if skills[param] then
        local v = skills[param]
        if param == "magiclevel" and player:getBaseMagicLevel() >= v.lim or (player:getBaseMagicLevel() + v.incre ) >= v.lim then
            player:sendCancelMessage(v.lim_msg) return true
        elseif player:getSkillLevel(v.skill) + v.incre >= v.lim then
            player:sendCancelMessage(v.lim_msg) return true          
        end
        if not isInArray(v.vocations, player:getVocation():getId()) then
            player:sendCancelMessage(v.voc_msg)
            return true
        end
        if player:getItemCount(coinID) >= v.price then
            player:removeItem(coinID, v.price)
            player:setStorageValue(storage, os.time()+1)
            local skillId = v.skill
            local amount = v.incre
            for i = 1, amount do
                local curSkill = player:getSkillLevel(skillId)
                local curTries = player:getSkillTries(skillId)
                local voc = player:getVocation()
                local nextTries = voc:getRequiredSkillTries(skillId, curSkill + 1)
                player:addSkillTries(skillId, nextTries - curTries + curTries / nextTries * voc:getRequiredSkillTries(skillId, curSkill + 2))
            end
        else
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "Você não possui a quantidade necessária para comprar.")
        end
        return true
    end

1684700825126.png
I can keep using the command about 500x, it doesn't go more than 208 and I wanted it to reach 350 skill distance and for ml 156
unless you increase the skills limit in src





View attachment 75694
 
Back
Top