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?
-------
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