• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

RevScripts Item on use, makes player not vissible by monsters

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,312
Reaction score
135
Hey! does that even possible ?

idea:

if player use item id XXX it makes all monsters doesnt attack the player for period of time, example 15 seconds, and every second an effect casted on player, and last sec effect shoud be different one


Thanks in advance for your time!
 
I'm so sorry I don't have experience with TFS 1 x try this

Lua:
-- invisibilityItem.lua
local invisibilityItemId = 1234 -- replace with the actual Item ID
local invisibilityTime = 15000 -- 15 seconds in milliseconds
local invisibilityStorage = Storage.InvisibilityStorage -- replace with an unused storage value


local invisibilityEffect = CONST_ME_MAGIC_RED -- replace with the desired effect
local lastEffect = CONST_ME_MAGIC_BLUE -- replace with the desired last effect


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(invisibilityStorage) > 0 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are already invisible.")
        return true
    end


    player:setStorageValue(invisibilityStorage, 1)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are now invisible to monsters for 15 seconds.")


    item:remove(1)
    
    -- Apply effects every second for the duration
    for i = 1, 14 do
        addEvent(function()
            player:getPosition():sendMagicEffect(invisibilityEffect)
        end, i * 1000)
    end


    -- Apply last effect after 15 seconds and remove invisibility
    addEvent(function()
        player:setStorageValue(invisibilityStorage, -1)
        player:getPosition():sendMagicEffect(lastEffect)
    end, invisibilityTime)


    return true
end
 
I'm so sorry I don't have experience with TFS 1 x try this

Lua:
-- invisibilityItem.lua
local invisibilityItemId = 1234 -- replace with the actual Item ID
local invisibilityTime = 15000 -- 15 seconds in milliseconds
local invisibilityStorage = Storage.InvisibilityStorage -- replace with an unused storage value


local invisibilityEffect = CONST_ME_MAGIC_RED -- replace with the desired effect
local lastEffect = CONST_ME_MAGIC_BLUE -- replace with the desired last effect


function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(invisibilityStorage) > 0 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are already invisible.")
        return true
    end


    player:setStorageValue(invisibilityStorage, 1)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are now invisible to monsters for 15 seconds.")


    item:remove(1)
   
    -- Apply effects every second for the duration
    for i = 1, 14 do
        addEvent(function()
            player:getPosition():sendMagicEffect(invisibilityEffect)
        end, i * 1000)
    end


    -- Apply last effect after 15 seconds and remove invisibility
    addEvent(function()
        player:setStorageValue(invisibilityStorage, -1)
        player:getPosition():sendMagicEffect(lastEffect)
    end, invisibilityTime)


    return true
end
thanks for your time!

i tryed it and it doesnt work, i cannot see error now if there is any
 
Back
Top