Skip to content

Weird interraction between RunConsoleCommand and ply:ConCommand() causes RunConsoleCommand to fail #6325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wrefgtzweve opened this issue May 4, 2025 · 0 comments

Comments

@wrefgtzweve
Copy link

Details

For some reason, RunConsoleCommand doesn't work when it's indirectly called by ply:ConCommand

] version
Protocol version 24
Exe version 2025.03.26 (garrysmod)
Exe build: 18:16:47 May  1 2025 (9662) (4000)
GMod version 2025.05.03, branch: x86-64, multicore: 0
Windows 64bit

Steps to reproduce

Here "gmod_mcore_test changed from " will never print, as the convar never changes

if CLIENT then
    RunConsoleCommand( "gmod_mcore_test", 0 )
    concommand.Add( "testcommand", function()
        print( "ran?", GetConVarNumber( "gmod_mcore_test" ) )
        RunConsoleCommand( "gmod_mcore_test", 1 )
    end )

    cvars.AddChangeCallback( "gmod_mcore_test", function( name, oldValue, newValue )
        print( "gmod_mcore_test changed from " .. oldValue .. " to " .. newValue )
    end, "gmod_mcore_test_cvartest" )
end

if SERVER then
    timer.Simple( 3, function()
        me:ConCommand( "testcommand" )
    end )
end

Here for whatever reason it does seem to run when i add a 0 tick timer:

if CLIENT then
    RunConsoleCommand( "gmod_mcore_test", 0 )
    concommand.Add( "testcommand", function()
        print( "ran?", GetConVarNumber( "gmod_mcore_test" ) )
        timer.Simple( 0, function()
            RunConsoleCommand( "gmod_mcore_test", 1 )
        end )
    end )

    cvars.AddChangeCallback( "gmod_mcore_test", function( name, oldValue, newValue )
        print( "gmod_mcore_test changed from " .. oldValue .. " to " .. newValue )
    end, "gmod_mcore_test_cvartest" )
end

if SERVER then
    timer.Simple( 3, function()
        me:ConCommand( "testcommand" )
    end )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant