Need Help With Making A Chat Command!

I need to make a command similar to RTV.

I need the chat command to be !cleanup, and after a certain portion of the players on the server vote for it the server will cleanup.

If someone could please show me how to do this that would be great!

Command that needs to be run after the vote is successful needs to be

gmod_admin_cleanup

Use the PlayerSay hook, and when someone types in !cleanup, you have a variable that counts total amount of votes, and when the vote reaches a specific amount of times, you run the command gmod_admin_cleanup using game.ConsoleCommand.

Here’s an example which takes ! and / and turns them into console commands: https://dl.dropboxusercontent.com/u/26074909/tutoring/chat_commands/chat_commands.lua.html



local votes = {}

local vote_length = 60 --time that the required number of votes must be accured
local vote_ratio = .5 --ratio of players the must vote relative to current number in order to pass the vote

hook.Add( "PlayerSay", "cleanup_vote", function( ply, txt )

	if txt == "!cleanup" then
		
		if #votes == 0 then
				
			timer.Create("cleanup_vote", vote_length, 1, function() --create the timer that will fail the vote if it doesn't pass.
				
				votes = {} --clear the table
				PrintMessage( HUD_PRINTTALK, "The cleanup vote did not gather enough people in the required time. Try again!" )

			end )

               else

			if not votes[ply:SteamID()] then

				votes[ply:SteamID()] = true
				PrintMessage( HUD_PRINTTALK, #votes .. "/".. math.floor( #player.GetAll() * vote_ratio ) .." votes for cleanup" )
				
			end

			if #votes == math.floor( #player.GetAll() * vote_ratio ) then

				timer.Destroy( "cleanup_vote" ) --stop the timer checking for failed vote
				votes = {} --clear the table
				PrintMessage( HUD_PRINTTALK, "The cleanup vote has succeded. Cleanup commencing..." )

				--put your cleanup function here.

			end

		end

	end

end )


@CallMePyro thanks man!