Blocking gm_spawn binds

Hey,

I have seen afew servers with this, but basically when you try to use gm_spawn binds it says “gm_spawn binds are blocked” in the chat and I cant find how to do this anywhere.

Any help would be much appreciated. Thanks!

[del]It should be as simple as doing something like this in a serverside file:[/del]


concommand.Add( "gm_spawn", function( ply, cmd, args, argStr )
    ply:PrintMessage( HUD_PRINTTALK, "gm_spawn binds are blocked" )
end )

Unless you mean stictly running this from the console, not including trying to spawn things via the spawnmenu.

nope that doesnt even spawn the prop anymore it just says the text in chat but thanks anyways

[editline]13th September 2015[/editline]

o and yea thats what i meant mista t

Apologies, misunderstood what you were wanting.

Try this in a clientside file:



hook.Add( "PlayerBindPress", "BlockGMSpawnBinds", function( ply, bind, bool )

    local tbl = string.Explode( " ", bind:lower(), false )

    if ( tbl[1] and tbl[1] == "gm_spawn" ) then 
        LocalPlayer():PrintMessage( HUD_PRINTTALK, "gm_spawn binds are blocked" )
        return true
    end

end )

ok thanks heeps that works, the only problem is it prints that in the chat when you press and unpress the key so it just spams it in chat twice which is annoying, is there any work around fr that?



hook.Add( "PlayerBindPress", "Test", function( ply, bind, bool )

    if ( not bool ) then return end
    
    local tbl = string.Explode( " ", bind:lower(), false )

    if ( tbl[1] and tbl[1] == "gm_spawn" ) then 
        LocalPlayer():PrintMessage( HUD_PRINTTALK, "gm_spawn binds are blocked" )
        return true
    end

end )

Hadn’t used this hook before, sorry. This should make it only check when the bind has been activated (skipping deactivation).

I’m not sure if this handles people aliasing the gm_spawn command, so I’ll try to test it. If someone else has more experience with this sort of thing, maybe they can help out more.

Edit
Doesn’t appear to handle aliases since PlayerBindPress sees the alias instead of the actual command.

thanks man it really helped can i add u on steam?