• 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!

TFS 1.X+ tfs 1.2 onUse, to register event

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,210
Solutions
35
Reaction score
206
Hi, im using tfs 1.2... how can i do that?
i need if player have storageActive with activeValue = 1, then register event.
Code:
local events = {
["ratkill"] = {storActive = 100, activeValue = 1},
["rotwormkill"] = {storActive = 120, activeValue = 1},
["scarabkill"] = {storActive = 150, activeValue = 1}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)


    for i = 1, #events do
            if player:getStorageValue(storActive,activeValue) == 1 then -- I THINK ERROR IS HERE
                player:registerEvent(events[i])
            end
    end


end
 
Last edited:
Well, you have to set the storage to 1 first. You can have one value per storage.
player:setStorageValue(storActive, activeValue)
you do not understand...
i need if player get storage value (storActive) == 1, the script will register a event
and if storActive ~= 1 the script will not register event
 
I just posted that for you, just change activeValue to 1
player:getStorageValue(storActive) == 1
have some error, because dont enter in this part
Code:
for i = 1, #events do

they printed only
"First Part"
don`t print (i) and dont print Final Part

Code:
local events = {
["ratkill"] = {storActive = 100, activeValue = 1},
["rotwormkill"] = {storActive = 120, activeValue = 1},
["scarabkill"] = {storActive = 150, activeValue = 1}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
print("First Part")

    for i = 1, #events do
 
    print(i)
 
            if player:getStorageValue(storActive) == 1 then -- I THINK ERROR IS HERE
         
                    print("Final Part")
                 
                player:registerEvent(events[i])
            end
    end


end
 
# won't work for tables that are not build with numbers only. You will have to use custom function.
LUA:
local function table.size(t)
  local size = 0
  for i, n in pairs(t) do
    size = size + 1
  end

  return size
end

for i = 1, table.size(events) do
 ...
 
Back
Top