Jump to content

[HELP] ADD cammand for shaders on/off for players


Sr.black

Recommended Posts

HELLO!

Please help me add cammand in the scripts shaders so that it can Players disable or enable shaders ex :

i want enable shaders cammand add : shaders on / shaders off

scripts :

shader_dynamic_skyhttps://www75.zippyshare.com/v/MFGntuRx/file.html

shader_watershinehttps://www75.zippyshare.com/v/1vrRJUFt/file.html

shader_car_paint_reflect_fixhttps://www75.zippyshare.com/v/2NYTIZqt/file.html

Link to comment
function enable_shaders()
    if not shadersEnabled then
        -- code to enable shaders, for example:
        setWeather(15)
        setFogDistance(50)
        shadersEnabled = true
        outputChatBox("Shaders enabled.")
    else
        outputChatBox("Shaders are already enabled.")
    end
end

function disable_shaders()
    if shadersEnabled then
        -- code to disable shaders, for example:
        setWeather(0)
        setFogDistance(200)
        shadersEnabled = false
        outputChatBox("Shaders disabled.")
    else
        outputChatBox("Shaders are already disabled.")
    end
end

This example uses a global variable shadersEnabled to keep track of whether the shaders are currently enabled or disabled. The enable_shaders() function checks if the shaders are already enabled before enabling them, and the disable_shaders() function does the same for disabling the shaders.

You would also need to initialize the global variable shadersEnabled to keep track of the current state of shaders, for example: shadersEnabled = false

You would then need to add a command handler to listen for the "shaders on" and "shaders off" commands:

 

addCommandHandler("shaders", function(player, command, option)
    if option == "on" then
        enable_shaders()
    elseif option == "off" then
        disable_shaders()
    end
end)



Note that the code to actually enable and disable the shaders would depend on the specific technology you are using to implement the shaders, and in this example I provided an example of how to change the weather and fog distance, you may need to adjust that according to your needs.
 

  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...