Setting a limit to a command?

Hello everyone, I’ve been trying to figure this out for the past two days and I can’t figure it out! I need to basically set a limit to using this command to 1 so they can only type it once instead of being able to spam it and it automatically going to a map-vote just because on person is spamming (!rtv)

Here’s the basic command:


        elseif lowtext == "!rtv" then
                RTV.AddVote(ply)


function RTV.AddVote(ply)
	if !RTV.rocks[ply:SteamID()] and !RTV.voting then
		table.insert(RTV.rocks, ply:SteamID())
		announcment({Color(204,102,0), ply:Name(), Color(255,255,255), " has rocked the vote!"})
		RTV.CheckIfReady()
	end
end

[lua] if !RTV.rocks[ply:SteamID()] and !RTV.voting then
table.insert(RTV.rocks, ply:SteamID())[/lua]

Looks like you already have something to prevent the player from doing it more than once. You’re just inserting the players into the RTV.rocks table wrong.
Don’t use table.insert in this case, do this instead:

[lua]RTV.rocks[ply:SteamID()] = true[/lua]

This should do what you want.

Sadly that doesn’t work. Even though it does limit how many times they can do it it doesn’t pop open the menu when 2/2 players have typed the command.

Then there’s probably a problem with your RTV.CheckIfReady function.