Jump to content

Shader visible to everyone


HunT

Recommended Posts

Posted

Hi guys.

I'm working on new script and I need info about visibility shader.

I have make this:

With edit box the player enter the URL image.

Get the URL - trigger server - fetchRemote - callback - trigger client - engineApplyShaderToWorldTexture

Well, the script work fine, but this is visible on for the client.

How I can make this visible to everyone?

Posted

easy , when you trigger client, use "root" or "getRootElement" on "element sendTo" and "element theElement" .

Send the data from fetchRemote to every client and from there every client genrate the texture->shader->apply it

Posted
easy , when you trigger client, use "root" or "getRootElement" on "element sendTo" and "element theElement" .

Send the data from fetchRemote to every client and from there every client genrate the texture->shader->apply it

Tnx for now,test later.

Edit:

But I don't want replace the texture to everyone.

I want replace the texture on player click but visible to everyone.

You understand ?

Posted

But I don't want replace the texture to everyone.

I want replace the texture on player click but visible to everyone.

You understand ?

To make a texture visible for everyone it must be replaced at everyone.

Posted

Tnx for now,test later.

Edit:

But I don't want replace the texture to everyone.

I want replace the texture on player click but visible to everyone.

You understand ?

in "engineApplyShaderToWorldTexture" is a value called "element targetElement" , so let's say it's about a car, when you trigger the client's with the downloaded texture you send over the car element to. And set it as "targetelement" , so the Shader will be applyed only on that car or object.

Posted

Yes i know this,but i no need replace the texture to vehicle.

My script is "replace u skin by url"

Example :

This is the link image - http://i.imgur.com/K1Slj.png

if i press the button =

cmo.png

if i press the button work fine for me,but other player lock me with the default skin.

I post the code but this is realy "raw" version,why i want make first the version work fine.

  
--Client  
  
--onClientGUIClick 
link = guiGetText (the edit box) 
triggerServerEvent("downloadFile", getLocalPlayer(), link) 
-- Server 
  
addEvent("downloadFile", true ) 
function fileDownload(link,playerToReceive) 
 fetchRemote ( link ,myCallback, "", false, playerToReceive ) 
end 
addEventHandler( "downloadFile", getRootElement(), fileDownload ) 
  
function myCallback( responseData, errno, playerToReceive ) 
if errno == 0 then     
triggerClientEvent( root, "onClientGotImage", resourceRoot, responseData ) 
end 
end 
  
-- client 
  
addEvent( "onClientGotImage", true ) 
addEventHandler( "onClientGotImage", resourceRoot, 
function(pixels) 
theShader = dxCreateShader("material/effect.fx", 0, 0, true, "ped"  )    
myTexture = dxCreateTexture( pixels ) 
if  theShader and myTexture then 
dxSetShaderValue(theShader,"gTexture",myTexture) 
engineApplyShaderToWorldTexture(theShader,"army",localPlayer) 
    end 
    end 
)    
  

Posted (edited)
--Client 
  
--onClientGUIClick 
link = guiGetText (the edit box) 
triggerServerEvent("downloadFile", root, link, getLocalPlayer()) 
-- Server 
  
addEvent("downloadFile", true ) 
function fileDownload(link, sPlayer) 
fetchRemote ( link ,myCallback, "", false,sPlayer ) 
end 
addEventHandler( "downloadFile", getRootElement(), fileDownload ) 
  
function myCallback( responseData, errno, sPlayer ) 
if errno == 0 then     
triggerClientEvent( root, "onClientGotImage", resourceRoot, responseData, sPlayer ) 
end 
end 
  
-- client 
  
addEvent( "onClientGotImage", true ) 
addEventHandler( "onClientGotImage", resourceRoot, 
function(pixels, sPlayer) 
theShader = dxCreateShader("material/effect.fx", 0, 0, true, "ped"  )    
myTexture = dxCreateTexture( pixels ) 
if  theShader and myTexture then 
dxSetShaderValue(theShader,"gTexture",myTexture) 
engineApplyShaderToWorldTexture(theShader,"army",sPlayer) 
    end 
    end 
)    

I sended the player elemnt from the server to the client, so everyone will get the player element on the client side, because "localPlayer" isn't shared.

Edited by Guest
Posted
--Client 
  
--onClientGUIClick 
link = guiGetText (the edit box) 
triggerServerEvent("downloadFile", getLocalPlayer(), link) 
-- Server 
  
addEvent("downloadFile", true ) 
function fileDownload(link) 
    fetchRemote(link ,myCallback, "", false, source) 
end 
addEventHandler("downloadFile", root, fileDownload) 
  
function myCallback(responseData, errno, playerToReceive) 
    if errno == 0 then     
        triggerClientEvent(root, "onClientGotImage", playerToReceive, responseData) 
    end 
end 
  
-- client 
  
addEvent("onClientGotImage", true) 
addEventHandler( "onClientGotImage", root, 
function(pixels) 
    theShader = dxCreateShader("material/effect.fx", 0, 0, true, "ped")    
    myTexture = dxCreateTexture(pixels) 
    if  theShader and myTexture then 
        dxSetShaderValue(theShader, "gTexture", myTexture) 
        engineApplyShaderToWorldTexture(theShader, "army", source) 
    end 
end)    
  

Posted
--Client 
  
--onClientGUIClick 
link = guiGetText (the edit box) 
triggerServerEvent("downloadFile", root, link, getLocalPlayer()) 
-- Server 
  
addEvent("downloadFile", true ) 
function fileDownload(link, sPlayer) 
fetchRemote ( link ,myCallback, "", false,sPlayer ) 
end 
addEventHandler( "downloadFile", getRootElement(), fileDownload ) 
  
function myCallback( responseData, errno, sPlayer ) 
if errno == 0 then     
triggerClientEvent( root, "onClientGotImage", resourceRoot, responseData, sPlayer ) 
end 
end 
  
-- client 
  
addEvent( "onClientGotImage", true ) 
addEventHandler( "onClientGotImage", resourceRoot, 
function(pixels, sPlayer) 
theShader = dxCreateShader("material/effect.fx", 0, 0, true, "ped"  )    
myTexture = dxCreateTexture( pixels ) 
if  theShader and myTexture then 
dxSetShaderValue(theShader,"gTexture",myTexture) 
engineApplyShaderToWorldTexture(theShader,"army",sPlayer) 
    end 
    end 
)    

I sended the player elemnt from the server to the client, so everyone will get the player element on the client side, because "localPlayer" isn't shared.

Realy Tnx now work fine :mrgreen:

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