Jump to content

About Saving engineApplyShaderToWorldTexture


Annas

Recommended Posts

I have made a script , replace shader for ped (player) by a command.

so when that player did the command , the shader will been applied in his skin.

it works perfect.

but when a player quit , and then come back , he wont see that shader until he applied the shader to world texture again by the command..

there is no function or anything to save it?

Exemple(Using engineApplyShaderToWorldTexture):

1- player did /customskin

2- shader of the skin been applied , all can see it.

3- it works perfect. the player who got the shader texture can go far and come back , others can see it as well.

4- when a player reconnect. (not the player who make the texture)

5- all can see that shader cauz they were online , ingame when he did the command to apply the shader. but who reconnected after he applied the shader to world texture , he wont see it , until the player who did the command , disable the shader and apply it back.

I WISH YOU UNDERSTAND :'(

Link to comment

You can use a bool variable which you'll set to true when the player uses the command. Then when he leave you'll save the variable's value to his account and when he logs in the value will be loaded again. Then you can use onPlayerSpawn and check if the variable's value is true, if yes, you'll apply the shader and if not then not.

Link to comment

Client:

  
addCommandHandler("mycommand", 
    function() 
        setElementData(getLocalPlayer(), "shaderEnabled", 1) 
         
        engineApplyShaderToWorldTexture(...) 
    end 
) 
  
addEvent("applyShader", true) 
addEventHandler("applyShader", getRootElement(), 
    function() 
        engineApplyShaderToWorldTexture(...) 
    end 
) 
  

Server:

  
addEventHandler("onPlayerLogin", getRootElement(), 
    function() 
        setAccountData(acc, "isShaderEnabled", 0) 
    end 
) 
  
addEventHandler("onPlayerLogout", getRootElement(), 
    function() 
        local value = getElementData(source, "shaderEnabled") 
         
        local acc = getPlayerAccount(source) 
        setAccountData(acc, "isShaderEnabled", value) 
    end 
) 
  
addEventHandler("onPlayerSpawn", getRootElement(), 
    function() 
        local acc = getPlayerAccount(source) 
        local value = getAccountData(acc, "isShaderEnabled") 
         
        if value == 1 then 
            triggerClientEvent(source, "applyShader", source) 
        end 
    end 
) 
  

Ofcourse you have to edit it yourself. May contain erros because it was written out of my mind.

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