• 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+ condition:getEndTime() how to use?

roriscrave

Advanced OT User
Joined
Dec 7, 2011
Messages
1,188
Solutions
34
Reaction score
200
Lua:
local condition = Condition(CONDITION_MUTED)
condition:setTicks(1000 * 60)
   
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getCondition(CONDITION_MUTED) then
        return print(condition:getEndTime())
    end
   
    player:addCondition(condition)
    return true
end

i muted a player for 1 minute (he cant talk), but this print, always print 0, how can i check the end time of a condition muted?
 
Last edited:
Solution
Lua:
local condition = Condition(CONDITION_MUTED)
condition:setTicks(1000 * 60)
  
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local playerCondition = player:getCondition(CONDITION_MUTED)
    if playerCondition then
        return print(playerCondition:getEndTime())
    end
  
    player:addCondition(condition)
    return true
end
getTimeEnd() on condition from player
condition object is not bound to player

probably you want to assign player:getCondition(...) to some local variable and only then check getEndTime()
 
condition object is not bound to player

probably you want to assign player:getCondition(...) to some local variable and only then check getEndTime()
i have edit first post, now it print a giant number:
Lua:
 return print(condition:getEndTime() - os.time())

Code:
1587724756795
1587724756795
1587724756794
1587724756794
1587724756794
1587724756794
1587724756794
1587724756791
1587724756791
1587724756791
1587724756791
1587724756787
 
Lua:
local condition = Condition(CONDITION_MUTED)
condition:setTicks(1000 * 60)
  
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local playerCondition = player:getCondition(CONDITION_MUTED)
    if playerCondition then
        return print(playerCondition:getEndTime())
    end
  
    player:addCondition(condition)
    return true
end
getTimeEnd() on condition from player
 
Solution
i have edit first post, now it print a giant number:
Lua:
 return print(condition:getEndTime() - os.time())

Code:
1587724756795
1587724756795
1587724756794
1587724756794
1587724756794
1587724756794
1587724756794
1587724756791
1587724756791
1587724756791
1587724756791
1587724756787
Condition time is in miliseconds. To convert it to seconds you need to divide it by 1000:
Code:
print((condition:getEndTime() / 1000) - os.time())
 
Back
Top