Jump to content

Help


Snakegold

Recommended Posts

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

Link to comment
  • Moderators

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 by stPatrick
  • Thanks 1
Link to comment
  • Moderators
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 by stPatrick
  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...