Overkillz Posted August 3, 2015 Share Posted August 3, 2015 (edited) Hey dear guys, Im having an issue which I tried to disabled it setTimer, events onPlayerJoin, onPlayerLogin ...etc but it didnt work. I want to disabled the water shader when the player join because it is toggeable from the userpanel. -- -- c_water.lua -- local enabled = false function checkWaterColor() if myShader then local r,g,b,a = getWaterColor() dxSetShaderValue ( myShader, "sWaterColor", r/255, g/255, b/255, a/255 ); end end myShader, tec = dxCreateShader ( "data/shader/water/water.fx" ) addEventHandler( "onClientResourceStart", resourceRoot, function() -- Version check if getVersion ().sortable < "1.1.0" then return end -- Create shader --myShader, tec = dxCreateShader ( "data/shader/water/water.fx" ) if not myShader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else --outputChatBox( "Using technique ") -- Set textures local textureVol = dxCreateTexture ( "data/shader/water/images/wavemap.dds" ); local textureCube = dxCreateTexture ( "data/shader/water/images/water_cube_env256.dds" ); dxSetShaderValue ( myShader, "sRandomTexture", textureVol ); dxSetShaderValue ( myShader, "sReflectionTexture", textureCube ); -- Apply to global txd 13 engineApplyShaderToWorldTexture ( myShader, "waterclear256" ) -- Update water color incase it gets changed by persons unknown setTimer( function() if myShader then local r,g,b,a = getWaterColor() dxSetShaderValue ( myShader, "sWaterColor", r/255, g/255, b/255, a/255 ); end end ,100,0 ) end end ) function toggleWaterShader ( ) enabled = not enabled if enabled then waterTimer = setTimer ( checkWaterColor, 1000, 0 ) engineApplyShaderToWorldTexture ( myShader, "waterclear256" ) else killTimer ( waterTimer ) engineRemoveShaderFromWorldTexture ( myShader, "waterclear256" ) end end function toggleWaterShaderByManager(bool) if enabled == bool then return false end enabled = bool if enabled then waterTimer = setTimer ( checkWaterColor, 1000, 0 ) engineApplyShaderToWorldTexture ( myShader, "waterclear256" ) else killTimer ( waterTimer ) engineRemoveShaderFromWorldTexture ( myShader, "waterclear256" ) end end I have tried to add this: addEventHandler( "onClientResourceStart", resourceRoot, function() killTimer ( waterTimer ) engineRemoveShaderFromWorldTexture ( myShader, "waterclear256" ) end) I added a setTimer before but it didnt work too. I hope u can help me. Thanks and Regards. Edited August 3, 2015 by Guest Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 This script is most likely stolen if not getElementData(localPlayer,"16091976AntiStealScriptbyShimu01022009") then return end Where's this? Link to comment
Overkillz Posted August 3, 2015 Author Share Posted August 3, 2015 This script is most likely stolen if not getElementData(localPlayer,"16091976AntiStealScriptbyShimu01022009") then return end Where's this? anything, experiment by myself xDD Edit: It isnt stolen, it was publicated on the community, u can check it, I can't remember the right name, but I think its tecnique water 2 or something like that. Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 Well, if you want to disable it, simply execute function: toggleWaterShader() When resource starts. Link to comment
Overkillz Posted August 3, 2015 Author Share Posted August 3, 2015 Well, if you want to disable it, simply execute function: toggleWaterShader() When resource starts. I tried to do this, but It didnt work function toggleWaterShaderByManager(bool) if enabled == bool then return false end enabled = bool if enabled then myShader, tec = dxCreateShader ( "data/shader/water/water.fx" ) else engineRemoveShaderFromWorldTexture ( myShader, "waterclear256" ) end end Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 function toggleWaterShaderByManager ( enabled ) if enabled then waterTimer = setTimer ( checkWaterColor, 1000, 0 ) engineApplyShaderToWorldTexture ( myShader, "waterclear256" ) else killTimer ( waterTimer ) engineRemoveShaderFromWorldTexture ( myShader, "waterclear256" ) end end Link to comment
Overkillz Posted August 3, 2015 Author Share Posted August 3, 2015 function toggleWaterShaderByManager ( enabled ) if enabled then waterTimer = setTimer ( checkWaterColor, 1000, 0 ) engineApplyShaderToWorldTexture ( myShader, "waterclear256" ) else killTimer ( waterTimer ) engineRemoveShaderFromWorldTexture ( myShader, "waterclear256" ) end end but If I define myshader, it will start when the resorce starts. I have tried it Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 Nope if you don't apply it. (Therefore don't use engineApplyShaderToWorldTexture when resource starts) Link to comment
Overkillz Posted August 3, 2015 Author Share Posted August 3, 2015 (edited) Nope if you don't apply it. (Therefore don't use engineApplyShaderToWorldTexture when resource starts) but it isn't in any function, even if I move it out of the function, without events, it get starts Sorry, I fixed it, I didn't was noticed that it was into the function. Sorry Edited August 3, 2015 by Guest Link to comment
GTX Posted August 3, 2015 Share Posted August 3, 2015 dxCreateShader only preloads shader... It doesn't actually create it. You must apply that shader to world to make it work. Remove engineApplyShaderToWorldTexture function from onClientResourceStart event and it will not start. Link to comment
Overkillz Posted August 3, 2015 Author Share Posted August 3, 2015 dxCreateShader only preloads shader... It doesn't actually create it. You must apply that shader to world to make it work. Remove engineApplyShaderToWorldTexture function from onClientResourceStart event and it will not start. You was in the correct, I didnt was noticed that the engine... was into the function, mybad, thanks man. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now