cuervox123 Posted March 19, 2016 Share Posted March 19, 2016 (edited) como puedo hacer que este script al yo usarlo ya que es un shader lo vean los demás -- -- c_ped_shell.lua -- local myShader local startTickCount = 0 addEventHandler( "onClientResourceStart", resourceRoot, function() -- Version check if getVersion ().sortable < "1.3.1-9.04939" then outputChatBox( "Resource is not compatible with this client." ) outputChatBox( "Please update MTA:SA." ) return end -- Create shader myShader, tec = dxCreateShader ( "fx/ped_shell_layer.fx", 0, 0, true, "ped" ) if not myShader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Using technique " .. tec ) -- 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 ) outputChatBox( "Press 'm' to see the effect" ) -- Fire effect at startup startEffect(); end end ) ---------------------------------------------------------------- -- Start effect here ---------------------------------------------------------------- function startEffect() startTickCount = getTickCount() end bindKey("m", "down", 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 Edited March 30, 2016 by Guest Link to comment
Tomas Posted March 19, 2016 Share Posted March 19, 2016 (edited) Client: local data = { shader = {}, tick = {} } addEvent("ped_shell", true) addEventHandler("ped_shell", root, function (w) if ( data.shader[w] ) then destroyElement(data.shader[w]) data.tick[w] = nil return end data.shader[w] = dxCreateShader ( "fx/ped_shell_layer.fx", 0, 0, true, "ped" ) engineApplyShaderToWorldTexture ( data.shader[w], "*", w ) setElementAlpha( w, 254 ) startEffect(w) end ) ---------------------------------------------------------------- -- Start effect here ---------------------------------------------------------------- function startEffect(w) data.tick[w] = getTickCount() end ---------------------------------------------------------------- -- Update effect here ---------------------------------------------------------------- addEventHandler( "onClientRender", root, function() for key, value in pairs(data) do for k, v in pairs(value) do local shader = k local tick = v local timeElapsed = getTickCount() - tick 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 ) dxSetShaderValue( shader, "sMorphSize", size, size, size ) dxSetShaderValue( shader, "sMorphColor", 1, 0, 0, alpha ) end end end ) ---------------------------------------------------------------- -- Math helper functions ---------------------------------------------------------------- function math.lerp(from,to,alpha) return from + (to-from) * alpha end Server addCommandHandler("ped_effect", function (p) triggerClientEvent(root, "ped_shell", root, p) end ) Edited March 25, 2016 by Guest Link to comment
cuervox123 Posted March 19, 2016 Author Share Posted March 19, 2016 c_ped_shell.lua30:table index is nil Link to comment
Tomas Posted March 19, 2016 Share Posted March 19, 2016 c_ped_shell.lua30:table index is nil Corregido. Link to comment
cuervox123 Posted March 19, 2016 Author Share Posted March 19, 2016 de verdad aprecio mucho tu ayuda pero no corre el shader que es osea el shader q se debe activar es este https://wiki.multitheftauto.com/wiki/Shader_examples#Ped_shell pero al usarlo queda algo como esto un ped brillante con la rafaga de las armas. Link to comment
Tomas Posted March 20, 2016 Share Posted March 20, 2016 de verdad aprecio mucho tu ayuda pero no corre el shader que es osea el shader q se debe activar es este https://wiki.multitheftauto.com/wiki/Shader_examples#Ped_shellpero al usarlo queda algo como esto un ped brillante con la de las armas. Agrega esto en el render: outputChatBox( (tostring(tick) and tick or "nope") ) Link to comment
cuervox123 Posted March 20, 2016 Author Share Posted March 20, 2016 lo puse en el render pero sigue igual Link to comment
Tomas Posted March 20, 2016 Share Posted March 20, 2016 lo puse en el render pero sigue igual ... ¿Qué sale en el chat? Link to comment
cuervox123 Posted March 20, 2016 Author Share Posted March 20, 2016 si lo pongo al inicio de la función sale un spam de nope,si lo pongo entre el if o el for no sale nada. Link to comment
Tomas Posted March 20, 2016 Share Posted March 20, 2016 si lo pongo al inicio de la función sale un spam de nope,si lo pongo entre el if o el for no sale nada. Reintentalo. Link to comment
cuervox123 Posted March 20, 2016 Author Share Posted March 20, 2016 ya lo hice pero sigue igual. Link to comment
Tomas Posted March 25, 2016 Share Posted March 25, 2016 ya lo hice pero sigue igual. Intenta ahora. Link to comment
Tomas Posted March 25, 2016 Share Posted March 25, 2016 Te recomiendo hacerlo con getElementData, así evalúas quiénes son los jugadores que tendrán el shader y quiénes no. No es necesario. Link to comment
MisterQuestions Posted March 28, 2016 Share Posted March 28, 2016 -- -- c_ped_shell.lua -- local myShader local startTickCount = 0 addEventHandler( "onClientResourceStart", resourceRoot, function() if getVersion ().sortable < "1.3.1-9.04939" then outputChatBox( "Resource is not compatible with this client." ) outputChatBox( "Please update MTA:SA." ) return end myShader, tec = dxCreateShader ( "fx/ped_shell_layer.fx", 0, 0, true, "ped" ) if not myShader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Press 'm' to see the effect" ) startEffect(); end end ) function startEffect() for t,thePlayer in ipairs(getElementsByType("player")) do if getElementData (thePlayer, "eszaraki") then if getElementData (thePlayer, "eszaraki" == true then engineApplyShaderToWorldTexture ( myShader, "*", thePlayer ) setElementAlpha( thePlayer, 254 ) end end end startTickCount = getTickCount() end bindKey("m", "down", startEffect ) 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 ) dxSetShaderValue( myShader, "sMorphSize", size, size, size ) dxSetShaderValue( myShader, "sMorphColor", 1, 0, 0, alpha ) end ) function math.lerp(from,to,alpha) return from + (to-from) * alpha end Tengo entendido, sería así. Link to comment
Tomas Posted March 29, 2016 Share Posted March 29, 2016 (edited) Esto es innecesario: if getElementData (source, "eszaraki") then if getElementData (source, "eszaraki" == true then Y para qué querrías remover el shader de los jugadores que se supone que no lo tienen? engineRemoveShaderFromWorldTexture ( myShader, "*", thePlayer) Edited March 30, 2016 by Guest Link to comment
cuervox123 Posted March 30, 2016 Author Share Posted March 30, 2016 solucionado muchas gracias a todos. Link to comment
Tomas Posted March 30, 2016 Share Posted March 30, 2016 Esto no es innecesario: Claro que sí campeón. Entonces, if is not innecesary then end engineRemoveShaderFromWorldTexture ( myShader, "*", thePlayer) Para remover el shader a jugadores que no tenga el dato del elemento. Cuando se use el comando. Si sería un dato que se va actualizar, eso haría el trabajo de eliminar el shader a ese jugador en específico desde el lado cliente de un usuario. ------------------------------------------------------------ Cuervox123 ponele [sOLUCIONADO] al nombre del tema. Claro que no, si el ped no tiene el shader y tampoco la data la función se triggea de todas formas y eso no debería pasar. Link to comment
Recommended Posts