Need to disable collision through context menu

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:



hook.Add( "CanProperty", "canproperty.blockcollision", function( ply, property, ent )
    if ( property == "collision" ) then return false end
end )


You can find the code for all of the context menu options in **garrysmod/garrysmod/lua/autorun/properties

**With collisions, it will call this hook prior to actually enabling/disabling them:



if ( !gamemode.Call( "CanProperty", ply, "collision", ent ) ) then return false end


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:



hook.Add( "CanProperty", "canproperty.blockcollision", function( ply, property, ent )
    if ( property == "collision" and !ply:IsAdmin() ) then return false end
end )

Or you can further restrict it to only users in the Super Admin user group:



hook.Add( "CanProperty", "canproperty.blockcollision", function( ply, property, ent )
    if ( property == "collision" and !ply:IsSuperAdmin() ) then return false end
end )

I don’t know which admin system you are using, but the Admin and SuperAdmin usergroups are in base garrysmod (garrysmod/garrysmod/lua/includes/extensions/player_auth.lua, 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).