Deagle Posted November 20, 2011 Share Posted November 20, 2011 Hey, I want to use this script in a map. -- -- c_uv_scroll.lua -- addEventHandler( "onClientResourceStart", resourceRoot, function() -- Version check if getVersion ().sortable < "1.1.0" then outputChatBox( "Resource is not compatible with this client." ) return end -- Create shader local shader, tec = dxCreateShader ( "uv_scroll.fx" ) if not shader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Using technique " .. tec ) -- Apply to world texture engineApplyShaderToWorldTexture ( shader, "bobo_2" ) -- Create object with model 4729 (billboard) local x,y,z = getElementPosition( getLocalPlayer() ) createObject ( 4729, x-15, y, z+3 ) end end ) I mean, I used it already and it's working, but I want to make it shorter, by deleting this part, because I dont need outputChatBox : if not shader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Using technique " .. tec ) But when I delete it, the script is not working. I tried to delete the "tec" from here : local shader, tec = dxCreateShader ( "uv_scroll.fx" ) local shader, dxCreateShader ( "uv_scroll.fx" ) This is my shorter script which is working : function() local shader, tec = dxCreateShader ( "uv_scroll.fx" ) if not shader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Using technique " .. tec ) engineApplyShaderToWorldTexture ( shader, "bobo_2" ) end end ) Link to comment
Castillo Posted November 20, 2011 Share Posted November 20, 2011 If it's working, then what's the problem? Link to comment
Deagle Posted November 20, 2011 Author Share Posted November 20, 2011 I want to delete this too, because I dont need the text in the chat. But when I delete it, the script it's not working : if not shader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Using technique " .. tec ) Link to comment
Aibo Posted November 20, 2011 Share Posted November 20, 2011 addEventHandler( "onClientResourceStart", resourceRoot, function() -- Version check if getVersion().sortable < "1.1.0" then outputChatBox( "Resource is not compatible with this client." ) return end -- Create shader local shader, tec = dxCreateShader ( "uv_scroll.fx" ) if shader then -- Apply to world texture engineApplyShaderToWorldTexture ( shader, "bobo_2" ) -- Create object with model 4729 (billboard) local x,y,z = getElementPosition( getLocalPlayer() ) createObject ( 4729, x-15, y, z+3 ) end end ) Link to comment
Deagle Posted November 20, 2011 Author Share Posted November 20, 2011 Thanks Aibo, you could say only that I have to leave this part : if shader then Oh, I forgot to say that I am using this in the race mode. Maybe that's why you wrote me the entire script. Now the script is working and it's way more shorter : addEventHandler( "onClientResourceStart", resourceRoot, function() local shader, tec = dxCreateShader ( "uv_scroll.fx" ) if shader then engineApplyShaderToWorldTexture ( shader, "bobo_2" ) end end ) Link to comment
Aibo Posted November 20, 2011 Share Posted November 20, 2011 well you're discarding the version check, not sure if it's a good idea. addEventHandler( "onClientResourceStart", resourceRoot, function() if getVersion().sortable >= "1.1.0" then local shader, tec = dxCreateShader ( "uv_scroll.fx" ) if shader then engineApplyShaderToWorldTexture ( shader, "bobo_2" ) end end end ) Link to comment
Deagle Posted November 20, 2011 Author Share Posted November 20, 2011 Hmm ... But why would I need it if I am using the script already on 1.1 ? Link to comment
12p Posted November 20, 2011 Share Posted November 20, 2011 You could delete that addEventHandler ( "onClientResourceStart" ), I don't use that event handler as the whole script is already executed when the resource starts. Link to comment
BinSlayer1 Posted November 21, 2011 Share Posted November 21, 2011 You could delete that addEventHandler ( "onClientResourceStart" ), I don't use that event handler as the whole script is already executed when the resource starts. No, it's executed when the file has been downloaded (the .lua file) This means that while the lua file has been downloaded, the shader files may have not been and executing them will not work However, this should not be a problem if the resource was already downloaded somehow Link to comment
AGENT_STEELMEAT Posted November 21, 2011 Share Posted November 21, 2011 You don't need a version check, use tags. Also, no need for onClientResourceStart in this example, as you do not depend on other functions from other scripts in the resource. Link to comment
12p Posted November 21, 2011 Share Posted November 21, 2011 No, it's executed when the file has been downloaded (the .lua file) I know. I spoke bad. 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