Jump to content

[help] SetTimer


Recommended Posts

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 
  

Link to comment
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.

Link to comment
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 

Link to comment

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 

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...