function onUse(player, item, fromPosition, itemEx, toPosition)
local storageValue = player:getStorageValue(81100)
if storageValue <= os.time() then
player:setStorageValue(81100, os.time() + 2 * 60 * 60)
item:remove()
player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
end
return true
end
function onKill(creature, target)
local exp = target:getType():getExperience()
-- Verifica se a criatura possui o bônus específico com o ID 81100
if creature:getStorageValue(81100) == 1 then
exp = exp + 300
end
creature:addExperience(exp, true)
return true
end
function onLogin(player)
local serverName = configManager.getString(configKeys.SERVER_NAME)
local loginStr = "Welcome to " .. serverName .. "."
if player:getLastLoginSaved() <= 0 then
loginStr = loginStr .. " Please choose your outfit."
player:sendOutfitWindow()
else
if loginStr ~= "" then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
end
loginStr = string.format("Your last visit on ".. serverName ..": %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
end
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
-- Promotion
if player:getVocation():getId() ~= 0 and player:getVocation():getId() < 5 and player:getStorageValue(30018) == 1 then
player:setVocation(player:getVocation():getId() + 4)
end
if player:isPremium() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* You receiving 10% more experience.")
end
-- Outfits
if not player:isPremium() then
if player:getSex() == PLAYERSEX_FEMALE then
local outfit = player:getOutfit()
if outfit.lookType > 262 then
player:setOutfit({lookType = 259, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
end
else
local outfit = player:getOutfit()
if outfit.lookType > 233 then
player:setOutfit({lookType = 230, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
end
end
end
-- Premium system
if player:isPremium() then
player:setStorageValue(43434, 1)
elseif player:getStorageValue(43434) == 1 then
player:setStorageValue(43434, 0)
end
local taskStatus = player:getStorageValue(18000)
if taskStatus > 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Your currently task: " .. tasks[taskStatus].name .. ".")
end
local day = os.date("*t").wday
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* The daily monster: " .. DailyMonster .. " - Bonus ".. DailyBonus .."% of experience.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Your current experience stage: " .. decimalPlace(Game.getExperienceStage(player:getLevel())) .. "x")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Official Discord Server: https://discord.gg/AedM8zA")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* To train use the !train command inside the temple")
-- Events
player:registerEvent("DailyMonster")
player:registerEvent("PlayerDeath")
player:registerEvent("kills")
player:registerEvent("Reward")
player:registerEvent("Spell")
player:registerEvent("Task")
player:registerEvent("MonsterBoost")
return true
end
function onLogin(cid)
local player = Player(cid)
if not player then
return false
end
local storageValue = player:getStorageValue(81100)
local currentTime = os.time()
if storageValue <= currentTime then
local doubleExpDuration = 2 * 60 * 60 -- 2 hours in seconds
local newExpEndTime = currentTime + doubleExpDuration
player:setStorageValue(81100, newExpEndTime)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have received double experience for 2 hours!")
else
local remainingTime = storageValue - currentTime
local hours = math.floor(remainingTime / 3600)
local minutes = math.floor((remainingTime % 3600) / 60)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You still have " .. hours .. " hours and " .. minutes .. " minutes of double experience.")
end
return true
end
<event type="login" name="doublexp" script="doublexp.lua"/>
registerCreatureEvent(cid, "doublexp")
function onUse(player, item, fromPosition, itemEx, toPosition)
local storageValue = player:getStorageValue(81100)
if storageValue <= os.time() then
local doubleExpDuration = 2 * 60 * 60 -- 2 hours in seconds
local newExpEndTime = os.time() + doubleExpDuration
player:setStorageValue(81100, newExpEndTime)
item:remove()
player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
end
return true
end
it seems that it worked for me, but I have some problems related to the experience gain that I get very highif creature:getStorageValue(81100) == 1 then
exp = exp + 300
end
this seems like should never be equal to 1. Try to make creature:getStorageValue(81100) > os.time()
<action itemid="3660" script="expboost.lua"/>
function onUse(player, item, fromPosition, itemEx, toPosition)
local storageValue = player:getStorageValue(81100)
if storageValue <= os.time() then
local doubleExpDuration = 2 * 60 * 60 -- 2 hours in seconds
local newExpEndTime = os.time() + doubleExpDuration
player:setStorageValue(81100, newExpEndTime)
item:remove()
player:say("You have just activated 2 hours of Double Experience!", TALKTYPE_MONSTER_SAY)
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the daily bonus.")
end
return true
end
<event type="kill" name="MonsterBoost" script="boosteexp.lua" />
function onKill(creature, target)
local exp = target:getType():getExperience()
if target:isPlayer() then
-- Se o alvo for um jogador, não há bônus de experiência
elseif creature:getStorageValue(81100) > os.time() then
-- Se o atacante tiver o bônus ativo, adiciona 300 de experiência
exp = exp + 100
end
creature:addExperience(exp, true)
return true
end
function onLogin(player)
local serverName = configManager.getString(configKeys.SERVER_NAME)
local loginStr = "Welcome to " .. serverName .. "."
if player:getLastLoginSaved() <= 0 then
loginStr = loginStr .. " Please choose your outfit."
player:sendOutfitWindow()
else
if loginStr ~= "" then
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
end
loginStr = string.format("Your last visit on ".. serverName ..": %s.", os.date("%a %b %d %X %Y", player:getLastLoginSaved()))
end
player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
-- Promotion
if player:getVocation():getId() ~= 0 and player:getVocation():getId() < 5 and player:getStorageValue(30018) == 1 then
player:setVocation(player:getVocation():getId() + 4)
end
if player:isPremium() then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* You receiving 10% more experience.")
end
-- Outfits
if not player:isPremium() then
if player:getSex() == PLAYERSEX_FEMALE then
local outfit = player:getOutfit()
if outfit.lookType > 262 then
player:setOutfit({lookType = 259, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
end
else
local outfit = player:getOutfit()
if outfit.lookType > 233 then
player:setOutfit({lookType = 230, lookHead = 78, lookBody = 106, lookLegs = 58, lookFeet = 95})
end
end
end
-- Premium system
if player:isPremium() then
player:setStorageValue(43434, 1)
elseif player:getStorageValue(43434) == 1 then
player:setStorageValue(43434, 0)
end
local taskStatus = player:getStorageValue(18000)
if taskStatus > 0 then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Your currently task: " .. tasks[taskStatus].name .. ".")
end
local day = os.date("*t").wday
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* The daily monster: " .. DailyMonster .. " - Bonus ".. DailyBonus .."% of experience.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Your current experience stage: " .. decimalPlace(Game.getExperienceStage(player:getLevel())) .. "x")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* Official Discord Server: https://discord.gg/AedM8zA")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "* To train use the !train command inside the temple")
-- Events
player:registerEvent("DailyMonster")
player:registerEvent("PlayerDeath")
player:registerEvent("kills")
player:registerEvent("Reward")
player:registerEvent("Spell")
player:registerEvent("Task")
player:registerEvent("MonsterBoost")
return true
end