• 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 HELP TFS 1.4 SCRIPT CHEST 24HRS

VagosClubTM

Active Member
Joined
Aug 16, 2019
Messages
219
Reaction score
32
Location
Chile
hello friends I have this script that I wish it could work in TFS 1.4, with revscript. I tried but I could not adapt it if someone could help me it would be great I will leave the base code here thank you very much in advance.

Lua:
local config = {
  items = {
      [1] = {2160, 1},
      [2] = {18337, 10},
[3] = {9971, 5}
  },
  level = 8,
  tempo = 24*60*60, -- 24 horas

  stoTime = 31402
}

function onUse(player, item, fromPosition, itemEx, toPosition)

  if player:getLevel() >= config.level then
      if player:getStorageValue(config.stoTime) - os.time() < 0 then
          player:setStorageValue(config.stoTime, os.time() + config.tempo)
          for _, table in pairs(config.items) do
              for i=1, #config.items do
                  player:addItem(table[i])
              end
          end
      else
          player:getStorageValue(config.stoTime, 0)
          player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Wait: %s.", string.diff(player:getStorageValue(config.stoTime)-os.time())))
      end
  else
      player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voce nao tem level "..config.level..".")
  end

end
 
Solution
hello friends I have this script that I wish it could work in TFS 1.4, with revscript. I tried but I could not adapt it if someone could help me it would be great I will leave the base code here thank you very much in advance.

Lua:
local config = {
  items = {
      [1] = {2160, 1},
      [2] = {18337, 10},
[3] = {9971, 5}
  },
  level = 8,
  tempo = 24*60*60, -- 24 horas

  stoTime = 31402
}

function onUse(player, item, fromPosition, itemEx, toPosition)

  if player:getLevel() >= config.level then
      if player:getStorageValue(config.stoTime) - os.time() < 0 then
          player:setStorageValue(config.stoTime, os.time() + config.tempo)
          for _, table in pairs(config.items) do
              for i=1, #config.items do...
hello friends I have this script that I wish it could work in TFS 1.4, with revscript. I tried but I could not adapt it if someone could help me it would be great I will leave the base code here thank you very much in advance.

Lua:
local config = {
  items = {
      [1] = {2160, 1},
      [2] = {18337, 10},
[3] = {9971, 5}
  },
  level = 8,
  tempo = 24*60*60, -- 24 horas

  stoTime = 31402
}

function onUse(player, item, fromPosition, itemEx, toPosition)

  if player:getLevel() >= config.level then
      if player:getStorageValue(config.stoTime) - os.time() < 0 then
          player:setStorageValue(config.stoTime, os.time() + config.tempo)
          for _, table in pairs(config.items) do
              for i=1, #config.items do
                  player:addItem(table[i])
              end
          end
      else
          player:getStorageValue(config.stoTime, 0)
          player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Wait: %s.", string.diff(player:getStorageValue(config.stoTime)-os.time())))
      end
  else
      player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Voce nao tem level "..config.level..".")
  end

end
Try this out, you'll have to put the item id in at the bottom, let me know how it works.
Lua:
local config = {
    rewardItems = { {2160, 1}, {18337, 10}, {9971, 5}},
    minimumLevel = 8,

    exhaustTime = 24 * 60 * 60, -- 24 hours
    exhaustStorage = 31402
}

local function secondsToString(seconds)
    if not seconds or seconds < 1 then
        return false
    end

    local hours = math.floor(seconds / 3600)
    local minutes = math.floor((seconds - (hours * 3600)) / 60)
    seconds = seconds - (hours * 3600) - (minutes * 60)

    local hour_string = hours > 0 and (hours .. (hours == 1 and " hour " or " hours ")) or ""
    local minute_string = minutes > 0 and (minutes .. (minutes == 1 and " minute " or " minutes ")) or ""
    local second_string = seconds > 0 and (seconds .. (seconds == 1 and " second " or " seconds ")) or ""

    local string = hour_string .. minute_string .. second_string

    local words = {}
    for word in string:gmatch("%S+") do
        table.insert(words, word)
    end

    if #words > 2 then
        string = ""
        for key, word in pairs(words) do
            if key == (#words - 1) then
                string = string .. " and"
            end
            string = string .. " " .. word
        end
    end
    return string:trim()
end

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getLevel() < config.minimumLevel then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must have minimumLevel "..config.minimumLevel..".")
        return true
    end

    local exhaustStorage = player:getStorageValue(config.exhaustStorage)
    local currentTime = os.time()
    if exhaustStorage > currentTime then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait " .. secondsToString(exhaustStorage - currentTime) .. ".")
        return true
    end

    player:setStorageValue(config.exhaustStorage, currentTime + config.exhaustTime)
    for _, item in pairs(config.rewardItems) do
        player:addItem(item[1], item[2])
    end

    return true
end

action:id(9075) -- add the id you want here
action:register()
 
Solution
Try this out, you'll have to put the item id in at the bottom, let me know how it works.
Lua:
local config = {
    rewardItems = { {2160, 1}, {18337, 10}, {9971, 5}},
    minimumLevel = 8,

    exhaustTime = 24 * 60 * 60, -- 24 hours
    exhaustStorage = 31402
}

local function secondsToString(seconds)
    if not seconds or seconds < 1 then
        return false
    end

    local hours = math.floor(seconds / 3600)
    local minutes = math.floor((seconds - (hours * 3600)) / 60)
    seconds = seconds - (hours * 3600) - (minutes * 60)

    local hour_string = hours > 0 and (hours .. (hours == 1 and " hour " or " hours ")) or ""
    local minute_string = minutes > 0 and (minutes .. (minutes == 1 and " minute " or " minutes ")) or ""
    local second_string = seconds > 0 and (seconds .. (seconds == 1 and " second " or " seconds ")) or ""

    local string = hour_string .. minute_string .. second_string

    local words = {}
    for word in string:gmatch("%S+") do
        table.insert(words, word)
    end

    if #words > 2 then
        string = ""
        for key, word in pairs(words) do
            if key == (#words - 1) then
                string = string .. " and"
            end
            string = string .. " " .. word
        end
    end
    return string:trim()
end

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getLevel() < config.minimumLevel then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must have minimumLevel "..config.minimumLevel..".")
        return true
    end

    local exhaustStorage = player:getStorageValue(config.exhaustStorage)
    local currentTime = os.time()
    if exhaustStorage > currentTime then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait " .. secondsToString(exhaustStorage - currentTime) .. ".")
        return true
    end

    player:setStorageValue(config.exhaustStorage, currentTime + config.exhaustTime)
    for _, item in pairs(config.rewardItems) do
        player:addItem(item[1], item[2])
    end

    return true
end

action:id(9075) -- add the id you want here
action:register()
This how do I add it to the system? is it used in revscript or actions? because I tried in revscript I put the ID of the actionid but when I pulled the lever it did not work
 
This how do I add it to the system? is it used in revscript or actions? because I tried in revscript I put the ID of the actionid but when I pulled the lever it did not work
It's revscript. But if it's an aid then line 64 needs to be changed to:
Lua:
action:aid(your action id here)
 
Back
Top