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?
[code]concommand.Add( "speed", function( ply )
ply:SetWalkSpeed( 1000 )
timer.Simple( 10, function() ply:SetWalkSpeed( 300 ) end )
end )[/code]
[CODE]
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 )
[/CODE]
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?
[CODE]
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 )
[/CODE]
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
[QUOTE=DeadShotKillz;44834061]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[/QUOTE]
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
[QUOTE=DeadShotKillz;44834109]concommand.Add("menucommand", MyDermaMenu)
function MyDermaMenu()
local menu = vgui.Create( "DFrame" )
local speed = vgui.Create( "DButton" )
menu:SetPos( ScrW()/2 -150, ScrH()/2 -75 ) -- Position form on your monitor
menu:SetSize( 300, 150 ) -- Size form
menu:SetTitle( "Spades Test Derma" ) -- Form set name
menu:SetVisible( true ) -- Form rendered ( true or false )
menu:SetDraggable( false ) -- Form draggable
menu:ShowCloseButton( true ) -- Show buttons panel
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[/QUOTE]
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
Sorry, you need to Log In to post a reply to this thread.