ice_brasil Posted May 17, 2013 Posted May 17, 2013 I want the effect to start every 1 second I tried What not worked: function startEffect() startTickCount = getTickCount() end addCommandHandler("droga", startEffect ) can add the set timer for me ? plis. sorry my bad english I'm Brazilian
RaceXtreme Posted May 17, 2013 Posted May 17, 2013 Here's the solution: function drugEffect() -- script here end addCommandHandler("droga", function () drugTimer = setTimer ( drugEffect, 1000, 0 ) -- 0 for infinite repetitions end)
ice_brasil Posted May 17, 2013 Author Posted May 17, 2013 Not Worked if you need the entire script: -- local myShader local startTickCount = 0 addEventHandler( "onClientResourceStart", resourceRoot, function() -- Version check if getVersion ().sortable < "1.3.1-9.04939" then return end -- Create shader myShader, tec = dxCreateShader ( "fx/ped_shell_layer.fx", 0, 0, true, "ped" ) if not myShader then else -- Apply shader to local player engineApplyShaderToWorldTexture ( myShader, "*", localPlayer ) -- Hack to make GTA render the ped last, so our shell effect appears on top of the background setElementAlpha( localPlayer, 254 ) -- Fire effect at startup startEffect(); end end ) ---------------------------------------------------------------- -- Start effect here ---------------------------------------------------------------- function startEffect() startTickCount = getTickCount() end addCommandHandler("droga", startEffect ) ---------------------------------------------------------------- -- Update effect here ---------------------------------------------------------------- addEventHandler( "onClientRender", root, function() if not myShader then return end local timeElapsed = getTickCount() - startTickCount local f = timeElapsed / 750 f = math.min( f, 1 ) local alpha = math.lerp ( 1.0, 0.0, f ) local size = math.lerp ( 0, 0.3, f ) -- Expand shell dxSetShaderValue( myShader, "sMorphSize", size, size, size ) -- Fade out shell dxSetShaderValue( myShader, "sMorphColor", 1, 0, 0, alpha ) end ) ---------------------------------------------------------------- -- Math helper functions ---------------------------------------------------------------- function math.lerp(from,to,alpha) return from + (to-from) * alpha end
Blaawee Posted May 17, 2013 Posted May 17, 2013 engineApplyShaderToWorldTexture( element shader, string textureName [, element targetElement = nil, bool appendLayers = true ] ) Required Arguments - shader: The shader which is to be applied - textureName: The name of the world texture to apply the shader to. Wildcard matching e.g. "ro?ds*" can be used to apply to more than one texture at a time.
Castillo Posted May 17, 2013 Posted May 17, 2013 Mind explaining what has that to do with his problem? he got all the required arguments filled: engineApplyShaderToWorldTexture ( myShader, "*", localPlayer )
ice_brasil Posted May 18, 2013 Author Posted May 18, 2013 Should I remove it? engineApplyShaderToWorldTexture ( myShader, "*", localPlayer )
RaceXtreme Posted May 18, 2013 Posted May 18, 2013 Is there a texture called '*' ? This means that the shader has to be applied to all textures related to ped element. Solidsnake14, i think he want the highlighting ped surface shader to be "flashing" every 1 second
ice_brasil Posted May 18, 2013 Author Posted May 18, 2013 Just got this texture, could not someone add the command in the script to me I can not
Castillo Posted May 18, 2013 Posted May 18, 2013 local myShader local startTickCount = 0 local lastEffectTic = 0 addEventHandler( "onClientResourceStart", resourceRoot, function() -- Version check if getVersion ().sortable < "1.3.1-9.04939" then return end -- Create shader myShader, tec = dxCreateShader ( "fx/ped_shell_layer.fx", 0, 0, true, "ped" ) if not myShader then else -- Apply shader to local player engineApplyShaderToWorldTexture ( myShader, "*", localPlayer ) -- Hack to make GTA render the ped last, so our shell effect appears on top of the background setElementAlpha( localPlayer, 254 ) end end ) ---------------------------------------------------------------- -- Start effect here ---------------------------------------------------------------- function startEffect ( ) startTickCount = getTickCount() lastEffectTic = getTickCount ( ) end addCommandHandler ( "droga", startEffect ) ---------------------------------------------------------------- -- Update effect here ---------------------------------------------------------------- addEventHandler ( "onClientRender", root, function ( ) if ( not myShader ) then return end local timeElapsed = ( getTickCount ( ) - startTickCount ) local f = ( timeElapsed / 750 ) local f = math.min ( f, 1 ) local alpha = math.lerp ( 1.0, 0.0, f ) local size = math.lerp ( 0, 0.3, f ) -- Expand shell dxSetShaderValue ( myShader, "sMorphSize", size, size, size ) -- Fade out shell dxSetShaderValue ( myShader, "sMorphColor", 1, 0, 0, alpha ) if ( startTickCount ~= 0 and getTickCount ( ) - lastEffectTic >= 1000 ) then startTickCount = getTickCount ( ) lastEffectTic = getTickCount ( ) end end ) ---------------------------------------------------------------- -- Math helper functions ---------------------------------------------------------------- function math.lerp(from,to,alpha) return from + (to-from) * alpha end
ice_brasil Posted May 19, 2013 Author Posted May 19, 2013 function stopEffect() stopTickCount = getTickCount () lastEffectTic = getTickCount ( ) end addCommandHandler("parar", stopEffect) Use this function to stop the effect?
Castillo Posted May 19, 2013 Posted May 19, 2013 No, use this one: local myShader local startTickCount = 0 local lastEffectTic = 0 addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) -- Version check if getVersion ().sortable < "1.3.1-9.04939" then return end -- Create shader myShader, tec = dxCreateShader ( "fx/ped_shell_layer.fx", 0, 0, true, "ped" ) if not myShader then else -- Apply shader to local player engineApplyShaderToWorldTexture ( myShader, "*", localPlayer ) -- Hack to make GTA render the ped last, so our shell effect appears on top of the background setElementAlpha( localPlayer, 254 ) end end ) ---------------------------------------------------------------- -- Start effect here ---------------------------------------------------------------- function startEffect ( ) startTickCount = getTickCount ( ) lastEffectTic = getTickCount ( ) addEventHandler ( "onClientRender", root, renderEffect ) end addCommandHandler ( "droga", startEffect ) function stopEffect ( ) startTickCount = 0 lastEffectTic = 0 removeEventHandler ( "onClientRender", root, renderEffect ) end addCommandHandler ( "parar", stopEffect ) ---------------------------------------------------------------- -- Update effect here ---------------------------------------------------------------- function renderEffect ( ) if ( not myShader ) then return end local timeElapsed = ( getTickCount ( ) - startTickCount ) local f = ( timeElapsed / 750 ) local f = math.min ( f, 1 ) local alpha = math.lerp ( 1.0, 0.0, f ) local size = math.lerp ( 0, 0.3, f ) -- Expand shell dxSetShaderValue ( myShader, "sMorphSize", size, size, size ) -- Fade out shell dxSetShaderValue ( myShader, "sMorphColor", 1, 0, 0, alpha ) if ( startTickCount ~= 0 and getTickCount ( ) - lastEffectTic >= 1000 ) then startTickCount = getTickCount ( ) lastEffectTic = getTickCount ( ) end end ---------------------------------------------------------------- -- Math helper functions ---------------------------------------------------------------- function math.lerp(from,to,alpha) return from + (to-from) * alpha end
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