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

exercise weapons little problem

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i have problem with this script, now i can use all weapons in same time on dummy, and i can training all skills in one time
I was try add "stopEvent(training)" after functions onUse and in function start_train after "if exercise:isItem() then", but nothing happend, still i can training all skills in one time


Code:
local skills = {
    [7766] = {id = SKILL_SWORD, voc = 4},
    [7772] = {id = SKILL_AXE, voc = 4},
    [7776] = {id = SKILL_CLUB, voc = 4},
    [2426] = {id = SKILL_DISTANCE, voc = 3, range = 18},
    [7773] = {id = SKILL_MAGLEVEL, voc = 2, range = CONST_ANI_FIRE},
}

------- CONFIG -----//
local dummies = {5788}
local skill_gain = 1 -- per hit
local gain_stamina = 60
local skillRate = configManager.getNumber(configKeys.RATE_SKILL)
local magicRate = configManager.getNumber(configKeys.RATE_MAGIC)

local function start_train(pid, start_pos, itemid, fpos)
    local player = Player(pid)
    if player ~= nil then
        local pos_n = player:getPosition()

        if start_pos:getDistance(pos_n) == 0 and getTilePzInfo(pos_n) then
            if player:getItemCount(itemid) >= 1 then
                local exercise = player:getItemById(itemid, true)

                if exercise:isItem() then
                    if exercise:hasAttribute(ITEM_ATTRIBUTE_CHARGES) then
                        local charges_n = exercise:getAttribute(ITEM_ATTRIBUTE_CHARGES)

                        if charges_n >= 1 then
                            exercise:setAttribute(ITEM_ATTRIBUTE_CHARGES, (charges_n - 1))

                            local required = 0
                            local currently = 0
                            local voc = player:getVocation()

                            if skills[itemid].id == SKILL_MAGLEVEL then
                                player:addManaSpent(math.ceil(500 * magicRate))
                            else
                                player:addSkillTries(skills[itemid].id, 1 * skillRate)
                            end

                            fpos:sendMagicEffect(CONST_ME_HITAREA)
                            if skills[itemid].range then
                                pos_n:sendDistanceEffect(fpos, skills[itemid].range)
                            end
                            player:setStamina(player:getStamina() + 60)

                            if charges_n == 1 then
                                exercise:remove(1)
                                return true
                            end
                            local training = addEvent(start_train, voc:getAttackSpeed(), pid, start_pos, itemid, fpos)
                        else
                            exercise:remove(1)
                            stopEvent(training)
                        end
                    end
                end
            end
        else
            stopEvent(training)
        end
    else
        stopEvent(training)
    end
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local start_pos = player:getPosition()

    if target:isItem() then
        if isInArray(dummies, target:getId()) then
            if not skills[item.itemid].range and (start_pos:getDistance(target:getPosition()) > 1) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Get closer to the dummy.")
                stopEvent(training)
                return false
            end
            if not player:getVocation():getId() == skills[item.itemid].voc or not player:getVocation():getId() == (skills[item.itemid].voc + 4) then
                stopEvent(training)
                return false
            end
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You started training.")
            start_train(player:getId(), start_pos, item.itemid, target:getPosition())
        end
    end

    return true
end
 
Solution
Hi, i have problem with this script, now i can use all weapons in same time on dummy, and i can training all skills in one time
I was try add "stopEvent(training)" after functions onUse and in function start_train after "if exercise:isItem() then", but nothing happend, still i can training all skills in one time


Code:
local skills = {
    [7766] = {id = SKILL_SWORD, voc = 4},
    [7772] = {id = SKILL_AXE, voc = 4},
    [7776] = {id = SKILL_CLUB, voc = 4},
    [2426] = {id = SKILL_DISTANCE, voc = 3, range = 18},
    [7773] = {id = SKILL_MAGLEVEL, voc = 2, range = CONST_ANI_FIRE},
}

------- CONFIG -----//
local dummies = {5788}
local skill_gain = 1 -- per hit
local gain_stamina = 60
local skillRate = configManager.getNumber(configKeys.RATE_SKILL)...
Hi, i have problem with this script, now i can use all weapons in same time on dummy, and i can training all skills in one time
I was try add "stopEvent(training)" after functions onUse and in function start_train after "if exercise:isItem() then", but nothing happend, still i can training all skills in one time


Code:
local skills = {
    [7766] = {id = SKILL_SWORD, voc = 4},
    [7772] = {id = SKILL_AXE, voc = 4},
    [7776] = {id = SKILL_CLUB, voc = 4},
    [2426] = {id = SKILL_DISTANCE, voc = 3, range = 18},
    [7773] = {id = SKILL_MAGLEVEL, voc = 2, range = CONST_ANI_FIRE},
}

------- CONFIG -----//
local dummies = {5788}
local skill_gain = 1 -- per hit
local gain_stamina = 60
local skillRate = configManager.getNumber(configKeys.RATE_SKILL)
local magicRate = configManager.getNumber(configKeys.RATE_MAGIC)

local function start_train(pid, start_pos, itemid, fpos)
    local player = Player(pid)
    if player ~= nil then
        local pos_n = player:getPosition()

        if start_pos:getDistance(pos_n) == 0 and getTilePzInfo(pos_n) then
            if player:getItemCount(itemid) >= 1 then
                local exercise = player:getItemById(itemid, true)

                if exercise:isItem() then
                    if exercise:hasAttribute(ITEM_ATTRIBUTE_CHARGES) then
                        local charges_n = exercise:getAttribute(ITEM_ATTRIBUTE_CHARGES)

                        if charges_n >= 1 then
                            exercise:setAttribute(ITEM_ATTRIBUTE_CHARGES, (charges_n - 1))

                            local required = 0
                            local currently = 0
                            local voc = player:getVocation()

                            if skills[itemid].id == SKILL_MAGLEVEL then
                                player:addManaSpent(math.ceil(500 * magicRate))
                            else
                                player:addSkillTries(skills[itemid].id, 1 * skillRate)
                            end

                            fpos:sendMagicEffect(CONST_ME_HITAREA)
                            if skills[itemid].range then
                                pos_n:sendDistanceEffect(fpos, skills[itemid].range)
                            end
                            player:setStamina(player:getStamina() + 60)

                            if charges_n == 1 then
                                exercise:remove(1)
                                return true
                            end
                            local training = addEvent(start_train, voc:getAttackSpeed(), pid, start_pos, itemid, fpos)
                        else
                            exercise:remove(1)
                            stopEvent(training)
                        end
                    end
                end
            end
        else
            stopEvent(training)
        end
    else
        stopEvent(training)
    end
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local start_pos = player:getPosition()

    if target:isItem() then
        if isInArray(dummies, target:getId()) then
            if not skills[item.itemid].range and (start_pos:getDistance(target:getPosition()) > 1) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Get closer to the dummy.")
                stopEvent(training)
                return false
            end
            if not player:getVocation():getId() == skills[item.itemid].voc or not player:getVocation():getId() == (skills[item.itemid].voc + 4) then
                stopEvent(training)
                return false
            end
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You started training.")
            start_train(player:getId(), start_pos, item.itemid, target:getPosition())
        end
    end

    return true
end
Make each skill a statue and a text
5 statue
5788
1 for magic
2 for axe
3 for sword
4 for distance
5 for clup
 
Hi, i have problem with this script, now i can use all weapons in same time on dummy, and i can training all skills in one time
I was try add "stopEvent(training)" after functions onUse and in function start_train after "if exercise:isItem() then", but nothing happend, still i can training all skills in one time


Code:
local skills = {
    [7766] = {id = SKILL_SWORD, voc = 4},
    [7772] = {id = SKILL_AXE, voc = 4},
    [7776] = {id = SKILL_CLUB, voc = 4},
    [2426] = {id = SKILL_DISTANCE, voc = 3, range = 18},
    [7773] = {id = SKILL_MAGLEVEL, voc = 2, range = CONST_ANI_FIRE},
}

------- CONFIG -----//
local dummies = {5788}
local skill_gain = 1 -- per hit
local gain_stamina = 60
local skillRate = configManager.getNumber(configKeys.RATE_SKILL)
local magicRate = configManager.getNumber(configKeys.RATE_MAGIC)

local function start_train(pid, start_pos, itemid, fpos)
    local player = Player(pid)
    if player ~= nil then
        local pos_n = player:getPosition()

        if start_pos:getDistance(pos_n) == 0 and getTilePzInfo(pos_n) then
            if player:getItemCount(itemid) >= 1 then
                local exercise = player:getItemById(itemid, true)

                if exercise:isItem() then
                    if exercise:hasAttribute(ITEM_ATTRIBUTE_CHARGES) then
                        local charges_n = exercise:getAttribute(ITEM_ATTRIBUTE_CHARGES)

                        if charges_n >= 1 then
                            exercise:setAttribute(ITEM_ATTRIBUTE_CHARGES, (charges_n - 1))

                            local required = 0
                            local currently = 0
                            local voc = player:getVocation()

                            if skills[itemid].id == SKILL_MAGLEVEL then
                                player:addManaSpent(math.ceil(500 * magicRate))
                            else
                                player:addSkillTries(skills[itemid].id, 1 * skillRate)
                            end

                            fpos:sendMagicEffect(CONST_ME_HITAREA)
                            if skills[itemid].range then
                                pos_n:sendDistanceEffect(fpos, skills[itemid].range)
                            end
                            player:setStamina(player:getStamina() + 60)

                            if charges_n == 1 then
                                exercise:remove(1)
                                return true
                            end
                            local training = addEvent(start_train, voc:getAttackSpeed(), pid, start_pos, itemid, fpos)
                        else
                            exercise:remove(1)
                            stopEvent(training)
                        end
                    end
                end
            end
        else
            stopEvent(training)
        end
    else
        stopEvent(training)
    end
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local start_pos = player:getPosition()

    if target:isItem() then
        if isInArray(dummies, target:getId()) then
            if not skills[item.itemid].range and (start_pos:getDistance(target:getPosition()) > 1) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Get closer to the dummy.")
                stopEvent(training)
                return false
            end
            if not player:getVocation():getId() == skills[item.itemid].voc or not player:getVocation():getId() == (skills[item.itemid].voc + 4) then
                stopEvent(training)
                return false
            end
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You started training.")
            start_train(player:getId(), start_pos, item.itemid, target:getPosition())
        end
    end

    return true
end

you can try as solution

Lua:
local skills = {
    [7766] = {id = SKILL_SWORD, voc = 4},
    [7772] = {id = SKILL_AXE, voc = 4},
    [7776] = {id = SKILL_CLUB, voc = 4},
    [2426] = {id = SKILL_DISTANCE, voc = 3, range = 18},
    [7773] = {id = SKILL_MAGLEVEL, voc = 2, range = CONST_ANI_FIRE},
}

------- CONFIG -----//
local dummies = {5788}
local skill_gain = 1 -- per hit
local gain_stamina = 60
local skillRate = configManager.getNumber(configKeys.RATE_SKILL)
local magicRate = configManager.getNumber(configKeys.RATE_MAGIC)

local function start_train(pid, start_pos, itemid, fpos)
    local player = Player(pid)
    if player ~= nil then
        local pos_n = player:getPosition()

        if start_pos:getDistance(pos_n) == 0 and getTilePzInfo(pos_n) then
            if player:getItemCount(itemid) >= 1 then
                local exercise = player:getItemById(itemid, true)

                if exercise:isItem() then
                    if exercise:hasAttribute(ITEM_ATTRIBUTE_CHARGES) then
                        local charges_n = exercise:getAttribute(ITEM_ATTRIBUTE_CHARGES)

                        if charges_n >= 1 then
                            exercise:setAttribute(ITEM_ATTRIBUTE_CHARGES, (charges_n - 1))

                            local required = 0
                            local currently = 0
                            local voc = player:getVocation()

                            if skills[itemid].id == SKILL_MAGLEVEL then
                                player:addManaSpent(math.ceil(500 * magicRate))
                            else
                                player:addSkillTries(skills[itemid].id, 1 * skillRate)
                            end

                            fpos:sendMagicEffect(CONST_ME_HITAREA)
                            if skills[itemid].range then
                                pos_n:sendDistanceEffect(fpos, skills[itemid].range)
                            end
                            player:setStamina(player:getStamina() + 60)
                            if charges_n == 1 then
                                exercise:remove(1)
                                return true
                            end
                            local training = addEvent(start_train, voc:getAttackSpeed(), pid, start_pos, itemid, fpos)
                            player:setStorageValue(121212, os.time() + 4)
                        else
                            exercise:remove(1)
                            stopEvent(training)
                        end
                    end
                end
            end
        else
            stopEvent(training)
        end
    else
        stopEvent(training)
    end
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getStorageValue(121212) >= os.time() then
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You can only train one skill at a time.')
    return true
end

    local start_pos = player:getPosition()

    if target:isItem() then
        if isInArray(dummies, target:getId()) then
            if not skills[item.itemid].range and (start_pos:getDistance(target:getPosition()) > 1) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Get closer to the dummy.")
                stopEvent(training)
                return false
            end
            if not player:getVocation():getId() == skills[item.itemid].voc or not player:getVocation():getId() == (skills[item.itemid].voc + 4) then
                stopEvent(training)
                return false
            end
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You started training.")
            start_train(player:getId(), start_pos, item.itemid, target:getPosition())
        end
    end

    return true
end


i don't know where you put stopevent, but, try my modifications
 
Solution
Make each skill a statue and a text
5 statue
5788
1 for magic
2 for axe
3 for sword
4 for distance
5 for clup
Nonsense

you can try as solution

Lua:
local skills = {
    [7766] = {id = SKILL_SWORD, voc = 4},
    [7772] = {id = SKILL_AXE, voc = 4},
    [7776] = {id = SKILL_CLUB, voc = 4},
    [2426] = {id = SKILL_DISTANCE, voc = 3, range = 18},
    [7773] = {id = SKILL_MAGLEVEL, voc = 2, range = CONST_ANI_FIRE},
}

------- CONFIG -----//
local dummies = {5788}
local skill_gain = 1 -- per hit
local gain_stamina = 60
local skillRate = configManager.getNumber(configKeys.RATE_SKILL)
local magicRate = configManager.getNumber(configKeys.RATE_MAGIC)

local function start_train(pid, start_pos, itemid, fpos)
    local player = Player(pid)
    if player ~= nil then
        local pos_n = player:getPosition()

        if start_pos:getDistance(pos_n) == 0 and getTilePzInfo(pos_n) then
            if player:getItemCount(itemid) >= 1 then
                local exercise = player:getItemById(itemid, true)

                if exercise:isItem() then
                    if exercise:hasAttribute(ITEM_ATTRIBUTE_CHARGES) then
                        local charges_n = exercise:getAttribute(ITEM_ATTRIBUTE_CHARGES)

                        if charges_n >= 1 then
                            exercise:setAttribute(ITEM_ATTRIBUTE_CHARGES, (charges_n - 1))

                            local required = 0
                            local currently = 0
                            local voc = player:getVocation()

                            if skills[itemid].id == SKILL_MAGLEVEL then
                                player:addManaSpent(math.ceil(500 * magicRate))
                            else
                                player:addSkillTries(skills[itemid].id, 1 * skillRate)
                            end

                            fpos:sendMagicEffect(CONST_ME_HITAREA)
                            if skills[itemid].range then
                                pos_n:sendDistanceEffect(fpos, skills[itemid].range)
                            end
                            player:setStamina(player:getStamina() + 60)
                            if charges_n == 1 then
                                exercise:remove(1)
                                return true
                            end
                            local training = addEvent(start_train, voc:getAttackSpeed(), pid, start_pos, itemid, fpos)
                            player:setStorageValue(121212, os.time() + 4)
                        else
                            exercise:remove(1)
                            stopEvent(training)
                        end
                    end
                end
            end
        else
            stopEvent(training)
        end
    else
        stopEvent(training)
    end
    return true
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getStorageValue(121212) >= os.time() then
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You can only train one skill at a time.')
    return true
end

    local start_pos = player:getPosition()

    if target:isItem() then
        if isInArray(dummies, target:getId()) then
            if not skills[item.itemid].range and (start_pos:getDistance(target:getPosition()) > 1) then
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Get closer to the dummy.")
                stopEvent(training)
                return false
            end
            if not player:getVocation():getId() == skills[item.itemid].voc or not player:getVocation():getId() == (skills[item.itemid].voc + 4) then
                stopEvent(training)
                return false
            end
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You started training.")
            start_train(player:getId(), start_pos, item.itemid, target:getPosition())
        end
    end

    return true
end


i don't know where you put stopevent, but, try my modifications

Working!, im did it with storage like you, but it not work with only set storage value 0/1, but with os.time its working perfecty!
 
Back
Top