Fanbox Posted January 18, 2018 Share Posted January 18, 2018 --Client local shader = dxCreateShader("tex.fx",0, 0, true, 'ped') addEvent("broadcastEnableShader", true) -- allow remotely triggered (from server) addEventHandler("broadcastEnableShader", root, function(some_data) -- receive broadcast from the server local img = dxCreateTexture(""..math.random(1,3)..".png") dxSetShaderValue(shader, "tex", img) engineApplyShaderToWorldTexture(shader, "Hoodie_green_co",some_data) end ) addEventHandler( 'onClientResourceStart', resourceRoot, function() for _, p in ipairs(getElementsByType('ped')) do if isElementStreamedIn(p) then local clothing = getElementData(p, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, p) end end end for _, p in ipairs(getElementsByType('player')) do if isElementStreamedIn(p) then local clothing = getElementData(p, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, p) end end end end) addEventHandler( 'onClientElementStreamIn', root, function() if getElementType(source) == 'player' or getElementType(source) == 'ped' then local clothing = getElementData(source, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, source) end end end) addEventHandler( 'onClientElementDataChange', root, function(name) if (getElementType(source) == 'player' or getElementType(source) == 'ped') and isElementStreamedIn(source) and name == 'blood' then if getElementData(source, 'blood') then triggerServerEvent("announceEnableShader", localPlayer, source) end end end) --SERVER addEvent("announceEnableShader", true) addEventHandler("announceEnableShader", root, function (some_data) -- triggerClientEvent(root, "broadcastEnableShader", source, some_data) end ) Ita not Synchronization(( Link to comment
URBAN Posted January 18, 2018 Share Posted January 18, 2018 --Client local shader = dxCreateShader("tex.fx",0, 0, true, 'ped') addEvent("broadcastEnableShader", true) -- allow remotely triggered (from server) addEventHandler("broadcastEnableShader", root, function(some_data) -- receive broadcast from the server local img = dxCreateTexture(""..math.random(1,3)..".png") dxSetShaderValue(shader, "tex", img) engineApplyShaderToWorldTexture(shader, "Hoodie_green_co",some_data) end ) addEventHandler( 'onClientResourceStart', resourceRoot, function() for _, p in ipairs(getElementsByType('ped')) do if isElementStreamedIn(p) then local clothing = getElementData(p, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, p) end end end for _, p in ipairs(getElementsByType('player')) do if isElementStreamedIn(p) then local clothing = getElementData(p, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, p) end end end end) addEventHandler( 'onClientElementStreamIn', root, function() if getElementType(source) == 'player' or getElementType(source) == 'ped' then local clothing = getElementData(source, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, source) end end end) addEventHandler( 'onClientElementDataChange', root, function(name) if (getElementType(source) == 'player' or getElementType(source) == 'ped') and isElementStreamedIn(source) and name == 'blood' then if getElementData(source, 'blood') then triggerServerEvent("announceEnableShader", localPlayer, source) end end end) --SERVER addEvent("announceEnableShader", true) addEventHandler("announceEnableShader", root, function (some_data) -- for i,player in ipairs(getElementsByType("player")) do triggerClientEvent("broadcastEnableShader", player, some_data) end end ) I didnt test it but i hope it will work. Link to comment
Fanbox Posted January 19, 2018 Author Share Posted January 19, 2018 2 hours ago, URBAN said: --Client local shader = dxCreateShader("tex.fx",0, 0, true, 'ped') addEvent("broadcastEnableShader", true) -- allow remotely triggered (from server) addEventHandler("broadcastEnableShader", root, function(some_data) -- receive broadcast from the server local img = dxCreateTexture(""..math.random(1,3)..".png") dxSetShaderValue(shader, "tex", img) engineApplyShaderToWorldTexture(shader, "Hoodie_green_co",some_data) end ) addEventHandler( 'onClientResourceStart', resourceRoot, function() for _, p in ipairs(getElementsByType('ped')) do if isElementStreamedIn(p) then local clothing = getElementData(p, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, p) end end end for _, p in ipairs(getElementsByType('player')) do if isElementStreamedIn(p) then local clothing = getElementData(p, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, p) end end end end) addEventHandler( 'onClientElementStreamIn', root, function() if getElementType(source) == 'player' or getElementType(source) == 'ped' then local clothing = getElementData(source, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, source) end end end) addEventHandler( 'onClientElementDataChange', root, function(name) if (getElementType(source) == 'player' or getElementType(source) == 'ped') and isElementStreamedIn(source) and name == 'blood' then if getElementData(source, 'blood') then triggerServerEvent("announceEnableShader", localPlayer, source) end end end) --SERVER addEvent("announceEnableShader", true) addEventHandler("announceEnableShader", root, function (some_data) -- for i,player in ipairs(getElementsByType("player")) do triggerClientEvent("broadcastEnableShader", player, some_data) end end ) I didnt test it but i hope it will work. The problem is that I see the texture on me, but I also see it on other players (instead of seeing them) Link to comment
Slim Posted January 19, 2018 Share Posted January 19, 2018 18 hours ago, Fanbox said: It's not synchronization NOT TESTED. shader = dxCreateShader("tex.fx",0, 0, true, 'ped') addEvent("broadcastEnableShader", true) -- allow remotely triggered (from server) addEventHandler("broadcastEnableShader", root, function(some_data) -- receive broadcast from the server img = dxCreateTexture(""..math.random(1,3)..".png") dxSetShaderValue(shader, "tex", img) engineApplyShaderToWorldTexture(shader, "Hoodie_green_co",thePlayer) end ) addEventHandler( 'onClientResourceStart', resourceRoot, function() for _, p in ipairs(getElementsByType('ped')) do if isElementStreamedIn(p) then local clothing = getElementData(p, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, p) end end end for _, p in ipairs(getElementsByType('player')) do if isElementStreamedIn(p) then local clothing = getElementData(p, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, p) end end end end) addEventHandler( 'onClientElementStreamIn', root, function() if getElementType(source) == 'player' or getElementType(source) == 'ped' then local clothing = getElementData(source, 'blood') if clothing then triggerServerEvent("announceEnableShader", localPlayer, source) end end end) addEventHandler( 'onClientElementDataChange', root, function(name) if (getElementType(source) == 'player' or getElementType(source) == 'ped') and isElementStreamedIn(source) and name == 'blood' then if getElementData(source, 'blood') then triggerServerEvent("announceEnableShader", localPlayer, source) end end end) --SERVER addEvent("announceEnableShader", true) addEventHandler("announceEnableShader", root, function (some_data) -- triggerClientEvent(root, "broadcastEnableShader", source, some_data) end ) I think the above code should work, but if it doesn't, try replacing all "localPlayer" with "thePlayer". If that also doesn't work, replace all the "source" with "thePlayer" also. Also from my experience, shaders don't effect MTA performance, I'm not sure though. 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