jareczekjsp
Member
Hello I use TFS 1.5 by nekiro and I have reborn system
And I would like Make doors Items from reborn 1 or 3 When have player have 3 reborn can use arrow ,wand etc.
How I can do it? because I have problem
I try make it with chat gpt
but no working no reaction all players can use items
LUA:
local config = {
talk = "!reset",
resetCostItemId = 10558,
newlevel = 8,
redskull = true,
battle = true,
pz = true,
healthPercent = 25, -- hp percentage (20%)
manaPercent = 25, -- mp percentage (20%)
storageResets = 525000,
expBonus = 10, -- experience bonus in percentage (10%)
damageBonus = 3, -- damage bonus in percentage (10%)
templePosition = Position(160, 54, 7),
stages = {
{levelRequired = 1000, cost = 100},
{levelRequired = 1250, cost = 200},
{levelRequired = 1500, cost = 300},
{levelRequired = 1750, cost = 400},
{levelRequired = 2000, cost = 500},
{levelRequired = 2250, cost = 600},
{levelRequired = 2500, cost = 700},
{levelRequired = 2750, cost = 800},
{levelRequired = 3000, cost = 900},
{levelRequired = 3250, cost = 1000},
{levelRequired = 3500, cost = 1100},
{levelRequired = 3750, cost = 1200},
{levelRequired = 4000, cost = 1300},
{levelRequired = 4250, cost = 1400},
{levelRequired = 4500, cost = 1500},
{levelRequired = 2500, cost = 1600},
{levelRequired = 3750, cost = 1700},
{levelRequired = 4000, cost = 1750},
{levelRequired = 4250, cost = 1800},
{levelRequired = 4500, cost = 1900},
{levelRequired = 4750, cost = 2000},
{levelRequired = 5000, cost = 2100},
{levelRequired = 5250, cost = 2200},
{levelRequired = 5500, cost = 2300},
{levelRequired = 5750, cost = 2400},
{levelRequired = 6000, cost = 2800},
-- Add more stages as needed
}
}
-- Function to get the current stage based on player's reset count
local function getCurrentStage(player)
local currentResets = player:getStorageValue(config.storageResets)
if currentResets < 0 then
currentResets = 0
end
return config.stages[currentResets + 1]
end
-- Function to reset the player
local function resetPlayer(player)
local currentStage = getCurrentStage(player)
if not currentStage then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "No more reset stages available, please contact the administrator!")
return false
end
local itemType = ItemType(config.resetCostItemId)
local itemName = itemType:getName()
if player:getItemCount(config.resetCostItemId) < currentStage.cost then
player:sendCancelMessage("You need " .. currentStage.cost .. " " .. itemName .. "(s) to perform the reset.")
return false
end
if config.battle and player:getCondition(CONDITION_INFIGHT) then
player:sendCancelMessage("You need to be out of battle to reset.")
return false
end
if config.pz then
local tile = Tile(player:getPosition())
if not tile or not tile:hasFlag(TILESTATE_PROTECTIONZONE) then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to be in a protection zone to reset.")
return false
end
end
if config.redskull and player:getSkull() == SKULL_RED then
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You need to be without red skull to reset.")
return false
end
if player:getLevel() < currentStage.levelRequired then
player:sendCancelMessage("You need to be level " .. currentStage.levelRequired .. " or higher to reset.")
return false
end
player:removeItem(config.resetCostItemId, currentStage.cost)
local currentResets = math.max(0, player:getStorageValue(config.storageResets))
local baseHealth = 1500
local baseMana = 350
local newHealthMax = baseHealth + (baseHealth * config.healthPercent / 100) * (currentResets + 1)
local newManaMax = baseMana + (baseMana * config.manaPercent / 100) * (currentResets + 1)
player:setMaxHealth(math.ceil(newHealthMax))
player:setMaxMana(math.ceil(newManaMax))
player:setStorageValue(config.storageResets, currentResets + 1)
player:teleportTo(config.templePosition)
config.templePosition:sendMagicEffect(CONST_ME_TELEPORT)
local query = string.format("UPDATE players SET health = %d, healthmax = %d, mana = %d, manamax = %d, level = %d, experience = %d WHERE id = %d",
math.ceil(newHealthMax), math.ceil(newHealthMax), math.ceil(newManaMax), math.ceil(newManaMax), config.newlevel, 4200, player:getGuid())
player:remove()
db.query(query)
return true
end
local talkaction = TalkAction(config.talk)
function talkaction.onSay(player, words, param, type)
resetPlayer(player)
return false
end
talkaction:separator(" ")
talkaction:register()
-- EventCallback to handle experience gain with bonus
local ec = EventCallback
ec.onGainExperience = function(self, source, exp, rawExp)
if not source:isMonster() then
return exp
end
local playerResets = math.max(0, self:getStorageValue(config.storageResets))
local bonusPercent = playerResets * config.expBonus
local percent = 1 + (bonusPercent / 100)
exp = exp * percent
return exp
end
ec:register()
-- CreatureEvent to handle damage bonus
local resetSysEvent = CreatureEvent("resetSys")
function resetSysEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not creature or not attacker then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
local playerResets = 0
if attacker:isPlayer() then
playerResets = attacker:getStorageValue(config.storageResets)
end
if playerResets == -1 then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
playerResets = math.max(0, playerResets)
local bonusPercent = playerResets * config.damageBonus
if bonusPercent > 0 then
local bonusDamage = primaryDamage * bonusPercent / 100
primaryDamage = primaryDamage + bonusDamage
secondaryDamage = secondaryDamage + bonusDamage
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
resetSysEvent:register()
-- EventCallback to register the resetSys event for monsters
local eventCallback = EventCallback
function eventCallback.onSpawn(creature, position, startup, artificial)
if creature:isMonster() then
creature:registerEvent("resetSys")
end
return true
end
eventCallback:register(-666)
How I can do it? because I have problem
Post automatically merged:
I try make it with chat gpt
LUA:
-- Lista przedmiotów, które będą dostępne po 4 resetach
local restrictedItems = {
[44189] = true, -- Przykładowe przedmioty
[15410] = true,
[18406] = true,
[39323] = true,
[15409] = true,
[39319] = true,
[15407] = true,
[18404] = true,
[18403] = true,
[15408] = true,
[15411] = true,
[39312] = true,
[18410] = true
}
-- Funkcja sprawdzająca, czy gracz ma co najmniej 4 resety
local function canEquipAfterResets(player)
local currentResets = player:getStorageValue(config.storageResets)
return currentResets >= 4 -- Sprawdzenie, czy gracz ma 4 lub więcej resetów
end
-- Funkcja obsługująca zakładanie przedmiotu
local function onEquipItem(player, item)
if restrictedItems[item:getId()] and not canEquipAfterResets(player) then
-- Jeśli przedmiot należy do restrictedItems, ale gracz ma mniej niż 4 resety
player:sendCancelMessage("You need at least 4 resets to wear this item.") -- Komunikat
return false -- Zatrzymanie zakładania przedmiotu
end
return true -- Jeśli wszystko jest OK, pozwól na zakładanie przedmiotu
end
-- Rejestracja zdarzenia przy próbie zakładania przedmiotu
local equipEvent = CreatureEvent("equipItemCheck")
equipEvent:register()
-- Obsługuje zdarzenie zakładania przedmiotu
function equipEvent.onEquip(player, item)
return onEquipItem(player, item)
end
Last edited: