Snakegold Posted February 8, 2019 Posted February 8, 2019 Hello community. i tried to work with this function but unfortunately i failed. i did alot of attemps but nothing happened getTimerDetails This is my code function test (player) local timer = 5000 if getElementData(player, "data1", true) then outputChatBox("You already got health. Please wait "..getTimerDetails(timer).."", player, 255,0,0) return end setElementHealth(player, 100) outputChatBox("Done",player,255,0,0,true) setElementData(player, "data1", true) setTimer(function () setElementData(player, "data1", false) end, timer,1) end addCommandHandler("health",test) debugscript: Bad argument @ 'getTimerDetails' [Expected lua-timer at argument 1, got number '5000'] Error: attempt to concatenate a boolean value
Moderators Patrick Posted February 8, 2019 Moderators Posted February 8, 2019 (edited) You tried to get details for a number. -- SERVER SIDE local blockTimers = {} local blockDuration = 5000 addCommandHandler("health", function(player) if blockTimers[player] then outputChatBox("You already got health. Please wait "..(getTimerDetails(blockTimers[player]) / 1000).."s.", player, 255, 0, 0, true) return false end setElementHealth(player, 100) outputChatBox("Done", player, 0, 255, 0, true) blockTimers[player] = setTimer(function() blockTimers[player] = nil -- destroy timer old details -- information about limit expiration, or something like that -- example: outputChatBox("You can use /health again.", player, 255, 0, 0, true) end, blockDuration, 1) end) Edited February 8, 2019 by stPatrick 1
Snakegold Posted February 8, 2019 Author Posted February 8, 2019 (edited) Thank you, do you know how to convert them to minutes and seconds? also without points like 3.487s Edited February 8, 2019 by Snakegold
Moderators Patrick Posted February 8, 2019 Moderators Posted February 8, 2019 (edited) 1 hour ago, Snakegold said: Thank you, do you know how to convert them to minutes and seconds? also without points like 3.487s -- SERVER SIDE local blockTimers = {} local blockDuration = 5000 addCommandHandler("health", function(player) if blockTimers[player] then local leftSec = getTimerDetails(blockTimers[player]) / 1000 local leftMin = math.floor(leftSec / 60) local leftSec = math.floor(leftSec - (leftMin * 60)) outputChatBox("You already got health. Please wait "..leftMin.." minuntes and "..leftSec.." seconds.", player, 255, 0, 0, true) return false end setElementHealth(player, 100) outputChatBox("Done", player, 0, 255, 0, true) blockTimers[player] = setTimer(function() blockTimers[player] = nil -- destroy timer old details -- information about limit expiration, or something like that -- example: outputChatBox("You can use /health again.", player, 255, 0, 0, true) end, blockDuration, 1) end) Edited February 8, 2019 by stPatrick 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now