Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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!
function onEquip(player, item, slot)
local cd = EXHAUSTTIME --in seconds
local storage = YOURSTORAGE
player:addStorageValue(storage, os.time() + cd)
if player:getStorageValue(storage) <= os.time() then
return true
else
return player:sendCancelMessage("You cannot equip this item yet") and false
end
end
remember to register the script on movements.xml
NOTE: this code will work with any item you register it on movements.xml
NOTE2: Have it in mind that adding a custom script to an item is broken in TFS 1.x and some features wont work, you either have a function="onEquip" or a script="yourcode.lua" registered. for example the requisite of level onEquip or vocation. I think there was a patch for it. Also, you can code those requirement manually for level or whatever you need on the code I gave you.
NOTE3: You can also use something similar to that code within events/player/onMoveEvent() function and using toPosition.y and the ring position.
you should only be adding time if the 1st condition passes
otherwise you will never be able to equip the item because the value is always going to be greater than os.time()
you can also add this piece of code to force register abilities on items + execute script beforehand
if the script returns true it will handle registering the item as usual like you use function="onEquip" + a script Update movement.cpp · Vulcanx/forgottenserver@1c78471
Lua:
local config = {
cooldown = 3000, -- milliseconds for more precision
storage = 99999 -- sample storage value
}
function onEquip(player, item, slot)
if player:getStorageValue(config.storage) <= os.mtime() then
player:setStorageValue(config.storage, os.mtime() + config.cooldown)
return true
end
player:sendCancelMessage("You cannot equip this item yet")
return false
end
you should only be adding time if the 1st condition passes
otherwise you will never be able to equip the item because the value is always going to be greater than os.time()
you can also add this piece of code to force register abilities on items + execute script beforehand
if the script returns true it will handle registering the item as usual like you use function="onEquip" + a script Update movement.cpp · Vulcanx/forgottenserver@1c78471
Lua:
local config = {
cooldown = 3000, -- milliseconds for more precision
storage = 99999 -- sample storage value
}
function onEquip(player, item, slot)
if player:getStorageValue(config.storage) <= os.mtime() then
player:setStorageValue(config.storage, os.mtime() + config.cooldown)
return true
end
player:sendCancelMessage("You cannot equip this item yet")
return false
end
I'm grateful for this answer, but
if storage < os.time() i got message "There is not enough room"
and if storage > os.time() i got message "You cannot dress this object there"
+ this github edited movements got me some errors while trying to compile
my source code looks like this