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