Simple timer Question

Ok so i want to make a simple timer that starts when i start a command but at first it sets the player speed to about 1000 then after 10 seconds it goes down to 300

And what’s the question?


concommand.Add( "speed", function( ply )
   ply:SetWalkSpeed( 1000 )
   timer.Simple( 10, function() ply:SetWalkSpeed( 300 ) end )
end )



concommand.Add( "speed", function( ply )
   ply:SetWalkSpeed( 1000 )
   if timer.Exists("SpeedCommandTimer") then
      timer.Destroy("SpeedCommandTimer")
   end
   timer.Create("SpeedCommandTimer", 10, 1, function() ply:SetWalkSpeed( 300 ) end )
end )


Fixed some bugs there. Now if they do the command again within 10 seconds, it won’t have strange effects.

and where do i put this?



concommand.Add( "speed", function( ply )
   ply:SetWalkSpeed( 1000 )
   if timer.Exists("SpeedCommandTimer") then
      timer.Destroy("SpeedCommandTimer")
   end
   timer.Create("SpeedCommandTimer", 10, 1, function() if IsValid( ply ) then ply:SetWalkSpeed( 300 ) end end )
end )


Now the player won’t glitch the timer by leaving.

Put it in autorun.

also every time i start my server it wont recognize my concommand to open the derma until I make a change to the file like press space or something then save it
Location:Cl_init

Let me just concentrate and read your code magically via the interwebs.

concommand.Add(“menucommand”, MyDermaMenu)

function MyDermaMenu()
local menu = vgui.Create( “DFrame” )
local speed = vgui.Create( “DButton” )
menu:SetPos( ScrW()/2 -150, ScrH()/2 -75 )
menu:SetSize( 300, 150 ) – Size form
menu:SetTitle( “Spades Test Derma” )
menu:SetVisible( true )
menu:SetDraggable( false )
menu:ShowCloseButton( true )
menu:MakePopup()

speed:SetParent( menu )
speed:SetText(“Click me for INSANE Speed”)
speed:Center()
speed:SetSize( 100, 50 )
function speed:DoClick( input )
RunConsoleCommand( “speed”, “arg1”, “arg2” );
end
end

That’s because when the code’s run, the concommand is added before the function exists. To fix it, put concommand.Add after the function.

well great the speed command doesnt work what is the location? and its not autorun its either init shared or cl_init

it says: unrecognized command

Nvm just saw the timer create