Advertisement
Pasterbiner123321

Untitled

May 27th, 2024
446
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.96 KB | None | 0 0
  1. local RESET_SYS = TalkAction("!reset")
  2.  
  3. local CONFIG = {
  4.     STORAGE_RESETS = 53009, -- Sprawdź czy wolne
  5.     BACK_TO_LEVEL = 8,
  6.     EXPERIENCE_FOR_LEVEL_8 = 4200,
  7.     REDSKULL = true,
  8.     BATTLE = true,
  9.     PZ = false,
  10.     DEFAULT_GAIN_MAX_HEALTH = 0.1,
  11.     DEFAULT_GAIN_MAX_MANA = 0.1,
  12.     STAGES = {
  13.         {resets = 5, level = 10, premium = 14, storage = 101},
  14.         {resets = 10, level = 15, premium = 19, storage = 201},
  15.         {resets = 15, level = 20, premium = 29, storage = 301},
  16.         {resets = 20, level = 30, premium = 39, storage = 401},
  17.         {resets = 30, level = 40, premium = 49, storage = 501},
  18.         {resets = math.huge, level = 40, premium = 50, storage = 601}
  19.     }
  20. }
  21.  
  22. local function canResetPlayer(player)
  23.     if CONFIG.REDSKULL and player:getSkull() == SKULL_RED then
  24.         player:sendCancelMessage("You need to be without red skull to reset.")
  25.         return false
  26.     elseif CONFIG.PZ and not getTilePzInfo(player:getPosition()) then
  27.         player:sendCancelMessage("You need to be in protection zone to reset.")
  28.         return false
  29.     elseif CONFIG.BATTLE and player:getCondition(CONDITION_INFIGHT) then
  30.         player:sendCancelMessage("You need to be without battle to reset.")
  31.         return false
  32.     end
  33.     return true
  34. end
  35.  
  36. function RESET_SYS.onSay(player, words, param)
  37.     if not canResetPlayer(player) then
  38.         return false
  39.     end
  40.  
  41.     local playerResets = math.max(0, player:getStorageValue(CONFIG.STORAGE_RESETS))
  42.     local stage = nil
  43.     for _, _stage in pairs(CONFIG.STAGES) do
  44.         if playerResets <= _stage.resets then
  45.             stage = _stage
  46.             break
  47.         end
  48.     end
  49.  
  50.     if not stage then
  51.         print("[Warning - ResetSystem::onSay] Stage not found for player: " .. player:getName())
  52.         return false
  53.     end
  54.  
  55.     local resetLevel = player:isPremium() and stage.premium or stage.level
  56.     local playerLevel = player:getLevel()
  57.     if playerLevel < resetLevel then
  58.         player:sendCancelMessage("You need level " .. resetLevel .. " or more to reset.")
  59.         return false
  60.     end
  61.  
  62.     playerResets = playerResets + 1
  63.     player:setStorageValue(CONFIG.STORAGE_RESETS, playerResets)
  64.  
  65.     -- Ustaw poziom gracza na 8 poprzez ustawienie doświadczenia na 4200
  66.     local currentExperience = player:getExperience()
  67.     local experienceForLevel8 = CONFIG.EXPERIENCE_FOR_LEVEL_8
  68.     print("Current experience: " .. currentExperience)
  69.     print("Setting experience to: " .. experienceForLevel8)
  70.    
  71.     if currentExperience > experienceForLevel8 then
  72.         player:removeExperience(currentExperience - experienceForLevel8)
  73.     else
  74.         player:addExperience(experienceForLevel8 - currentExperience, true)
  75.     end
  76.  
  77.     print("Experience after reset: " .. player:getExperience())
  78.     print("Level after reset: " .. player:getLevel())
  79.  
  80.     local maxHealth = player:getMaxHealth()
  81.     local maxMana = player:getMaxMana()
  82.     local newMaxHealth = stage.gainMaxHealth or (maxHealth * (1 + CONFIG.DEFAULT_GAIN_MAX_HEALTH))
  83.     local newMaxMana = stage.gainMaxMana or (maxMana * (1 + CONFIG.DEFAULT_GAIN_MAX_MANA))
  84.  
  85.     local vocHealthBonus = 0
  86.     local vocManaBonus = 0
  87.     local playerVocation = player:getVocation():getId()
  88.     if playerVocation == 3 or playerVocation == 4 then -- Paladin or Knight
  89.         vocHealthBonus = 50
  90.         vocManaBonus = 30
  91.     elseif playerVocation == 1 or playerVocation == 2 then -- Sorcerer or Druid
  92.         vocHealthBonus = 30
  93.         vocManaBonus = 50
  94.     end
  95.  
  96.     player:setMaxHealth(maxHealth + newMaxHealth + vocHealthBonus)
  97.     player:setMaxMana(maxMana + newMaxMana + vocManaBonus)
  98.     player:addHealth(newMaxHealth + vocHealthBonus)
  99.     player:addMana(newMaxMana + vocManaBonus)
  100.     player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
  101.     player:sendTextMessage(MESSAGE_INFO_DESCR, "Now you have " .. playerResets .. " " .. (playerResets == 1 and "reset" or "resets") .. ".")
  102.     return false
  103. end
  104.  
  105. RESET_SYS:register()
  106.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement