jareczekjsp
Member
Hello I use Revescripts
and I have problem when Player make reset dont have bonuses
Help me please![Frown :( :(](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Lua:
local resetSys = TalkAction("!reset")
local config = {
storageResets = 525000,
backToLevel = 8,
redskull = true,
battle = true,
pz = true,
defaultGainMaxHealth = 0.3,
defaultGainMaxMana = 0.3,
resetCostItemId = 2157, -- Item ID required for reset
resetCostAmount = 1, -- Amount of item required for reset
stages = {
{levelRequired = 2000, cost = 100, expBonus = 10.08, damageBonus = 10.08}, -- Reset 1 - 20
-- Add more stages as needed
}
}
-- Function to get experience required for a specific level
local function getExperienceForLevel(lv)
lv = lv - 1
return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
function resetSys.onSay(player, words, param)
-- Check if the player meets reset conditions
if config.redskull and player:getSkull() == 4 then
player:sendCancelMessage("You need to be without red skull to reset.")
return false
elseif config.pz and not getTilePzInfo(player:getPosition()) then
player:sendCancelMessage("You need to be in protection zone to reset.")
return false
elseif config.battle and player:getCondition(CONDITION_INFIGHT) then
player:sendCancelMessage("You need to be without battle to reset.")
return false
end
-- Find the appropriate stage based on player's resets
local playerResets = math.max(0, player:getStorageValue(config.storageResets))
local stage = nil
for _, _stage in pairs(config.stages) do
if playerResets < _stage.levelRequired then
stage = _stage
break
end
end
if not stage then
print("[Warning - ResetSystem::onSay] Stage not found for player: " .. player:getName())
return false
end
-- Check if the player has the required level
local playerLevel = player:getLevel()
if playerLevel < stage.levelRequired then
player:sendCancelMessage("You need to be level " .. stage.levelRequired .. " or higher to reset.")
return false
end
-- Check if the player has enough money to perform the reset
if not player:removeItem(config.resetCostItemId, stage.cost) then
player:sendCancelMessage("You need " .. stage.cost .. " of item " .. config.resetCostItemId .. " to perform the reset.")
return false
end
-- Perform the reset
playerResets = playerResets + 1
player:setStorageValue(config.storageResets, playerResets)
player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(config.backToLevel))
-- Apply bonuses
local expBonus = stage.expBonus
local damageBonus = stage.damageBonus
-- Apply bonuses here as needed
local maxHealth = player:getMaxHealth()
local maxMana = player:getMaxMana()
local newMaxHealth = 1150
local newMaxMana = 1135
if stage.gainMaxHealth then
newMaxHealth = maxHealth + math.ceil(maxHealth * stage.gainMaxHealth)
else
newMaxHealth = maxHealth + math.ceil(maxHealth * config.defaultGainMaxHealth)
end
if stage.gainMaxMana then
newMaxMana = maxMana + math.ceil(maxMana * stage.gainMaxMana)
else
newMaxMana = maxMana + math.ceil(maxMana * config.defaultGainMaxMana)
end
player:setMaxHealth(newMaxHealth)
player:setMaxMana(newMaxMana)
player:addHealth(newMaxHealth)
player:addMana(newMaxMana)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Now you have " .. playerResets .. " " .. (playerResets == 1 and "reset" or "resets") .. ".")
return false
end
resetSys:register()
and I have problem when Player make reset dont have bonuses
Code:
expBonus = 10.08, damageBonus = 10.08}, -- Reset 1 - 20