-- Example CreatureScript for TFS
local targetTimers = {} -- Table to store timers for each player
function onCreatureAppear(creature)
-- This function is called when the monster becomes visible
-- You may want to reset any timers or conditions here
end
function onCreatureAttack(creature, target)
-- Check if the attacker is a player
if creature:isPlayer() then
local playerGUID = creature:getGuid()
-- Check if there is an existing timer for the player
if targetTimers[playerGUID] then
-- If the player has been attacking the same creature for 15 minutes, drop the target
if targetTimers[playerGUID] + 900000 <= os.time() then
creature:setTarget(nil)
creature:sendCancelMessage("You have been attacking the same creature for 15 minutes. Your target has been dropped.")
end
else
-- If no timer exists, create one
targetTimers[playerGUID] = os.time()
end
end
end
LUA:-- Example CreatureScript for TFS local targetTimers = {} -- Table to store timers for each player function onCreatureAppear(creature) -- This function is called when the monster becomes visible -- You may want to reset any timers or conditions here end function onCreatureAttack(creature, target) -- Check if the attacker is a player if creature:isPlayer() then local playerGUID = creature:getGuid() -- Check if there is an existing timer for the player if targetTimers[playerGUID] then -- If the player has been attacking the same creature for 15 minutes, drop the target if targetTimers[playerGUID] + 900000 <= os.time() then creature:setTarget(nil) creature:sendCancelMessage("You have been attacking the same creature for 15 minutes. Your target has been dropped.") end else -- If no timer exists, create one targetTimers[playerGUID] = os.time() end end end
i guess this is for trainers anti -afk?
Yes you right. I will try this script, thank you!i guess this is for trainers anti -afk?