• Need to disable collision through context menu
    5 replies, posted
does anyone know how i can disable collision for player though the C menu
You can't disable collision for a player through the C menu.
so will they always be allowed to no-collide there cars or is there a way to stop it
He means blocking players from opening the context menu and disabling collisions on their props. You can use this hook to disable the collisions property entirely: [CODE] hook.Add( "CanProperty", "canproperty.blockcollision", function( ply, property, ent ) if ( property == "collision" ) then return false end end ) [/CODE] You can find the code for all of the context menu options in [B]garrysmod/garrysmod/lua/autorun/properties [/B]With collisions, it will call this hook prior to actually enabling/disabling them: [CODE] if ( !gamemode.Call( "CanProperty", ply, "collision", ent ) ) then return false end [/CODE]
will this stop the admins accessing the cont menu aswell or just players
The first snippet of code I posted will prevent all players, including admins, from disabling/enabling collisions on props through the content menu. If you want to give access to players in the Admin user group (which is set by ply:SetUserGroup( "admin" )), then you would change it to: [CODE] hook.Add( "CanProperty", "canproperty.blockcollision", function( ply, property, ent ) if ( property == "collision" and !ply:IsAdmin() ) then return false end end )[/CODE] Or you can further restrict it to only users in the Super Admin user group: [CODE] hook.Add( "CanProperty", "canproperty.blockcollision", function( ply, property, ent ) if ( property == "collision" and !ply:IsSuperAdmin() ) then return false end end )[/CODE] I don't know which admin system you are using, but the Admin and SuperAdmin usergroups are in base garrysmod ([B]garrysmod/garrysmod/lua/includes/extensions/player_auth.lua[/B], so unless your admin system does something drastically different, the two hook functions should work (depending on which user group you want to restrict it to).
Sorry, you need to Log In to post a reply to this thread.