Kareem92 Posted May 24, 2016 Share Posted May 24, 2016 السلام عليكم انا ارجو اي احد يصحح لي هذا الكود وشكرا myShader = dxCreateShader( "shader.fx" ) function shader() engineApplyShaderToWorldTexture( myShader, "wmyclot.txd" ) end addCommandHandler("on", shader) addEventHandler("onClientResourceStart", root, shader) Link to comment
#|_oskar_|# Posted May 24, 2016 Share Posted May 24, 2016 وضح : ايش تبي تسوي بالضبط ؟ Link to comment
Kareem92 Posted May 24, 2016 Author Share Posted May 24, 2016 وضح : ايش تبي تسوي بالضبط ؟ ابي اعمل سكن شخصي هل هذا الكود صحيح؟ Link to comment
#|_oskar_|# Posted May 24, 2016 Share Posted May 24, 2016 وضح : ايش تبي تسوي بالضبط ؟ ابي اعمل سكن شخصي هل هذا الكود صحيح؟ لا + شوف الرابط دا فى شخصيات بشادر https://wiki.multitheftauto.com/wiki/Shader_examples#Texture_names Link to comment
Kareem92 Posted May 24, 2016 Author Share Posted May 24, 2016 وضح : ايش تبي تسوي بالضبط ؟ ابي اعمل سكن شخصي هل هذا الكود صحيح؟ لا + شوف الرابط دا فى شخصيات بشادر https://wiki.multitheftauto.com/wiki/Shader_examples#Texture_names ما فهمت انا نزلت "Texture_Names" لكن مافهمت ماذا افعل؟ Codes: -- -- c_tex_names.lua -- --------------------------------------- -- Local variables for this file --------------------------------------- local myShader local bShowTextureUsage = false local uiTextureIndex = 1 local m_SelectedTextureName = "" local scx, scy = guiGetScreenSize () local usageInfoList = {} local textureName = "wmyclot.txd" --------------------------------------- -- Startup --------------------------------------- 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 tec myShader, tec = dxCreateShader ( "tex_names.fx", 1, 0, false, "all" ) if not myShader then outputChatBox( "Could not create shader. Please use debugscript 3" ) else outputChatBox( "Using technique " .. tec ) outputChatBox( "Utility to help find world texture names", 255, 255, 0 ) outputChatBox( "Press num_8 to view list", 0, 255, 255 ) outputChatBox( "Press num_7 and num_9 to step list", 0, 255, 255 ) outputChatBox( "Press k to copy texture name to clipboard", 0, 255, 255 ) end end ) --------------------------------------- -- Draw visible texture list --------------------------------------- addEventHandler( "onClientRender", root, function() usageInfoList = engineGetVisibleTextureNames () local iXStartPos = scx - 200; local iYStartPos = 0; local iXOffset = 0; local iYOffset = 0; if bShowTextureUsage then for key, textureName in ipairs(usageInfoList) do local bSelected = textureName == m_SelectedTextureName; local dwColor = bSelected and tocolor(255,220,128) or tocolor(224,224,224,204) if bSelected then dxDrawText( textureName, iXStartPos + iXOffset + 1, iYStartPos + iYOffset + 1, 0, 0, tocolor(0,0,0) ) end dxDrawText( textureName, iXStartPos + iXOffset, iYStartPos + iYOffset, 0, 0, dwColor ) iYOffset = iYOffset + 15 if iYOffset > scy - 15 then iYOffset = 0; iXOffset = iXOffset - 200; end end end end ) --------------------------------------- -- Handle keyboard events from KeyAutoRepeat --------------------------------------- addEventHandler("onClientKeyClick", resourceRoot, function(key) if key == "num_7" then moveCurrentTextureCaret( -1 ) elseif key == "num_9" then moveCurrentTextureCaret( 1 ) elseif key == "num_8" then bShowTextureUsage = not bShowTextureUsage elseif key == "k" then if m_SelectedTextureName ~= "" then setClipboard( m_SelectedTextureName ) outputChatBox( "'" .. tostring(m_SelectedTextureName) .. "' copied to clipboard" ) end end end ) --------------------------------------- -- Change current texture --------------------------------------- function moveCurrentTextureCaret( dir ) if #usageInfoList == 0 then return end -- Validate selection in current texture list, or find closest match for key, textureName in ipairs(usageInfoList) do if m_SelectedTextureName <= textureName then uiTextureIndex = key break end end -- Move position in the list uiTextureIndex = uiTextureIndex + dir uiTextureIndex = ( ( uiTextureIndex - 1 ) % #usageInfoList ) + 1 -- Change highlighted texture engineRemoveShaderFromWorldTexture ( myShader, m_SelectedTextureName ) m_SelectedTextureName = usageInfoList [ uiTextureIndex ] engineApplyShaderToWorldTexture ( myShader, m_SelectedTextureName ) end -- -- c_key_auto_repeat.lua -- ------------------------------------------------------------- -- Keyboard auto-repeat ------------------------------------------------------------- KeyAutoRepeat = {} KeyAutoRepeat.repeatDelay = 500 -- Wait before 1st repeat KeyAutoRepeat.repeatRateInitial = 100 -- Delay between repeats (initial) KeyAutoRepeat.repeatRateMax = 10 -- Delay between repeats (after key held for repeatRateChangeTime) KeyAutoRepeat.repeatRateChangeTime = 2700 -- Amount of time to move between repeatRateInitial and repeatRateMax KeyAutoRepeat.keydownInfo = {} -- Result event - Same parameters as onClientKey addEvent( "onClientKeyClick" ) -- Update repeats function KeyAutoRepeat.pulse() for key,info in pairs(KeyAutoRepeat.keydownInfo) do local age = getTickCount () - info.downStartTime age = age - KeyAutoRepeat.repeatDelay -- Initial delay if age > 0 then -- Make rate speed up as the key is held local ageAlpha = math.unlerpclamped( 0, age, KeyAutoRepeat.repeatRateChangeTime ) local dynamicRate = math.lerp( KeyAutoRepeat.repeatRateInitial, ageAlpha, KeyAutoRepeat.repeatRateMax ) local count = math.floor(age/dynamicRate) -- Repeat rate if count > info.count then info.count = count triggerEvent("onClientKeyClick", resourceRoot, key ) end end end end addEventHandler("onClientRender", root, KeyAutoRepeat.pulse ) -- When a key is pressed/release function KeyAutoRepeat.keyChanged(key,down) KeyAutoRepeat.keydownInfo[key] = nil if down then KeyAutoRepeat.keydownInfo[key] = { downStartTime=getTickCount (), count=0 } triggerEvent("onClientKeyClick", resourceRoot, key ) end end addEventHandler("onClientKey", root, KeyAutoRepeat.keyChanged) ------------------------------------------------------------- -- Math extentions ------------------------------------------------------------- function math.lerp(from,alpha,to) return from + (to-from) * alpha end function math.unlerp(from,pos,to) if ( to == from ) then return 1 end return ( pos - from ) / ( to - from ) end function math.clamp(low,value,high) return math.max(low,math.min(value,high)) end function math.unlerpclamped(from,pos,to) return math.clamp(0,math.unlerp(from,pos,to),1) end 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