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

Lua attack and gain exp

Methemia

Member
Joined
Feb 1, 2015
Messages
60
Reaction score
9
I want to attack and gain experience each 2 minutes


I'm basing myself on the stamina code events/creatures.lua

can you help me?

Code:
local staminaBonus = {
    target = 'Training Monk',
    period = 120000, -- time on miliseconds
    bonus = 1, -- gain stamina
    events = {}
}


local function addStamina(name)
    local player = Player(name)
    if not player then
        staminaBonus.events[name] = nil
    else
        local target = player:getTarget()
        if not target or target:getName() ~= staminaBonus.target then
            staminaBonus.events[name] = nil
        else
            player:setStamina(player:getStamina() + staminaBonus.bonus)
            staminaBonus.events[name] = addEvent(addStamina, staminaBonus.period, name)
        end
    end
end
-------


Code:
if self:isPlayer() then
        if target and target:getName() == staminaBonus.target then
            local name = self:getName()
            if not staminaBonus.events[name] then
                staminaBonus.events[name] = addEvent(addStamina, staminaBonus.period, name)
            end
        end
 

Similar threads

Back
Top