Jump to content

commands time


Samking

Recommended Posts

As soon as the player types the command, you can store the tick count at this time and then based on that, you can check later whether the player used the command before the last 30 minutes. An example:

 

local antiSpam = { }

function someCommandHandler(plr)
  local lastCheck = antiSpam[plr]
  local currentTick = getTickCount()
  if (lastCheck and (currentTick - lastCheck) < (30 * 60000)) then -- Unless lastCheck is nil, get the current tick and subtract from it the last time the player used the command then check whether the result is smaller than 30 minutes and if so, return
    return false
  end
  antiSpam[plr] = currentTick -- Updates the antiSpam table with the new info
  -- Do whatever you want
end
addCommandHandler("somecommand", someCommandHandler)

 

Edited by Mqtyx
Link to comment
16 hours ago, Mqtyx said:

As soon as the player types the command, you can store the tick count at this time and then based on that, you can check later whether the player used the command before the last 30 minutes. An example:

 


local antiSpam = { }

function someCommandHandler(plr)
  local lastCheck = antiSpam[plr]
  local currentTick = getTickCount()
  if (lastCheck and (currentTick - lastCheck) < (30 * 60000)) then -- Unless lastCheck is nil, get the current tick and subtract from it the last time the player used the command then check whether the result is smaller than 30 minutes and if so, return
    return false
  end
  antiSpam[plr] = currentTick -- Updates the antiSpam table with the new info
  -- Do whatever you want
end
addCommandHandler("somecommand", someCommandHandler)

 

Not working

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...