Jump to content

marcelluss

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by marcelluss

  1. Hello guys, I want to implement an interesting feature in MTA for heating up the brake discs. I'm not sure where to start; how do you actually change the textures of specific car brake discs? Do I need a shader for this? If yes, what kind could serve as a base? Maybe there are already ready-made examples (systems)?
  2. Hello, I would like to know if it is possible to somehow make a normal blur effect (glass) in mta? I know that there are shaders in the likeness of BlurBox, but they do not give enough blur and glass effect, is it possible to somehow achieve such an effect as in the screenshot below? Using a shader? I don't really know how to work with shaders if someone knows how to upgrade my shader, please help me please here is a variant of my shader code texture ScreenSource; float BlurStrength; float2 UVSize; sampler TextureSampler = sampler_state { Texture = <ScreenSource>; MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = Wrap; AddressV = Wrap; }; static const float2 poisson[16] = { float2(-0.326212f, -0.40581f), float2(-0.840144f, -0.07358f), float2(-0.695914f, 0.457137f), float2(-0.203345f, 0.620716f), float2(0.96234f, -0.194983f), float2(0.473434f, -0.480026f), float2(0.519456f, 0.767022f), float2(0.185461f, -0.893124f), float2(0.507431f, 0.064425f), float2(0.89642f, 0.412458f), float2(-0.32194f, -0.932615f), float2(-0.65432f, -0.87421f), float2(-0.456899f, -0.633247f), float2(-0.123456f, -0.865433f), float2(-0.664332f, -0.25680f), float2(-0.791559f, -0.59771f) }; float4 PixelShaderFunction(float2 TextureCoordinate : TEXCOORD0) : COLOR0 { float4 color = tex2D(TextureSampler, TextureCoordinate); for(int i = 0; i < 14; i++) { float2 coord= TextureCoordinate.xy + (poisson[i] / UVSize * BlurStrength); color += tex2D(TextureSampler, coord); } return(color/17); } technique BlurShader { pass Pass1 { PixelShader = compile ps_2_0 PixelShaderFunction(); } } and here are two options for the result of my blurring the picture before and after applying the shader picture before picture after
  3. I tried to use this function, but unfortunately I didn't quite understand how to use it :((( local rawSvgData = [[ <svg viewBox="0 0 600 600" xmlns="http://www.w3.org/2000/svg"> <defs> <linearGradient id="gradient"> <stop offset="5%" stop-color="#FF0000" /> <stop offset="95%" stop-color="#00FF00" /> </linearGradient> </defs> <path id="progress" fill="none" stroke="url(#gradient)" d="M300,50 A250,250,0,1,1,299.99,50" stroke-width="20" /> </svg> ]] local svgs = {} local function render(svg) if (not isElement(svg)) or (getElementType(svg) ~= "svg") then removeEventHandler("onClientRender", root, svgs[svg].handler) svgs[svg] = nil end local width, height = svgGetSize(svg) dxDrawImage(500, 500, 430, 430, svg, 0, 0, 0, tocolor(255, 255, 255), false) end local function onUpdate(svg) print("fe") if (not svgs[svg]) then svgs[svg] = { state = true, handler = function() render(svg) end } addEventHandler("onClientRender", root, svgs[svg].handler) end iprint("SVG texture updated", svg, getTickCount()) end addEventHandler("onClientResourceStart", root, function() mySvg = svgCreate(430, 430, rawSvgData, onUpdate) end) bindKey("l", "down", function() local newPath = updateState(100, 100, 300); addSVGRectNode(mySvg, path) end) function addSVGRectNode(svg, path) local svgXML = svgGetDocumentXML(svg) local rect = xmlCreateChild(svgXML, "rect") xmlNodeSetAttribute(rect, "d", path) local status = svgSetDocumentXML(svg, svgXML) print(status) end function updateState(value, total, R) local center local alpha = 360 / total * value local a = (90 - alpha) * math.pi / 180 local x = 300 + R * math.cos(a) local y = 300 - R * math.sin(a) local path if (total == value) then path = "M300,"..(300 - R).." A"..R..","..R..",0,1,1,299.99,"..(300 - R) else if (alpha > 180) then center = 1 else center = 0 end path = "M300,"..(300 - R).." A"..R..","..R..",0,"..center..",1,"..x..","..y end return path end The problem is that for some reason I can't change the source data of the svg file already (I tried to do as you said, well, for some reason it doesn't work) - besides, I didn't quite understand working with the arguments of this function, let's say I tried to manually call the function and replace the arguments the same as from the debug, but this it didn't work quite correctly, maybe I didn't quite understand the principle of these arguments of this function, what is responsible for what. Please help me
  4. hello, I really liked your idea with the work of svg, is it possible to find out how to make the progress of reducing the strip in the svg code?
  5. Hello, I ran into a problem with the dxDrawCircle function, I have a shader that allows you to apply a gradient to a texture, but the problem is that I need to make a gradient to a level system where there is a round strip with a gradient and I would like to attach a gradient there, but the problem is that dxDrawCircle does not accept a texture and I would like to somehow attach it there, or if possible, help me!
  6. Hello, I would like to know if it is possible to make a countdown timer without using the SetTimer function? I wanted to do this in a more optimized and correct way because the usual SetTimer does not work quite in time. And I would like to make a dynamic function in which I can enter, say, 60 minutes into the arguments and a countdown timer will start with the output of minutes and seconds and at the same time use getRealTime. I tried to use many ways with this function, but they were all unsuccessful + I have already tried to find solutions on the forum and on the Internet, but all used SetTimer - unfortunately, it will not work to provide a ready-made code for my solution, because not one of them was even close to the solution I was moving towards
  7. Hello, I've been trying to figure out for a very long time how to make a smooth 3d line? In terms of I know that there is a dxDrawLine3D, but this function allows you to create flat lines or to be more precise straight lines, and I need to make a smooth line in the likeness of drawing with a brush in the 3d world, but I can't figure out how to make such a smooth line, I wanted to make it for traces of players and cars
  8. I want to find out how to implement the effect of the web on the screen. I've seen this on websites, in principle I have no idea how to do this, but just how optimized will it be? And is it even possible to implement it using a shader?
  9. create a colshape and track the contact of both colshapes
  10. The speed must be constantly set for this function to work. To do this, use a timer or a render to constantly maintain the speed. I don 't know for sure if it is possible to replace the shooting effect , but I can offer an option to create an object and count the trajectory of the bullet ( and already apply your shader to the object itself )
  11. local cursorShowing = false bindKey("f2", "down", function() cursorShowing = not cursorShowing showCursor(cursorShowing) end) local nameColor = white local nameSize = 1.2 local nameFont = "pricedown" local ped = createPed(0, 0, 0, 3); addEventHandler( "onClientRender", getRootElement(), function( ) --for _, plr in ipairs( getElementsByType( "player" ) ) do -- if not (plr == localPlayer) then local x, y, z = getPedBonePosition( ped, 8 ) local sX, sY = getScreenFromWorldPosition( x, y, z ) if sX then --local id = setElementData(plr, "id") local text if id then text ="Player ["..id.."]" else text = "Player" end local leftX = sX- dxGetTextWidth(text, nameSize, nameFont )/2 local topY = sY-60 local rightX = leftX local buttonY = topY dxDrawText( text, leftX, topY, rightX, buttonY, nameColor, nameSize, nameSize, nameFont, "left", "top", false, false, false, false, false) end -- end --end local w, h = guiGetScreenSize () local tx, ty, tz = getWorldFromScreenPosition ( w/2, h/2, 50 ) local px, py, pz = getCameraMatrix(localPlayer) -- test line -- local line = dxDrawLine3D(px, py, pz, x, y, z) local hit, x, y, z, elementHit = processLineOfSight ( px, py, pz, tx, ty, tz ) if hit then if elementHit then local sX, sY = getScreenFromWorldPosition( x, y, z ) dxDrawText("G", sX, sY, sX, sY, tocolor(255, 255, 255), 1, "default") end end end ) If I understood your idea correctly, then here is the script
  12. it all depends on the animation itself, if the animation itself allows you to walk, then yes, you can walk with animation enabled, but this is not available to all animations. And also you can import your own animations into the game. The Internet is full of guides for creating animations for a character in the game.
  13. use the following functions for this: dxDrawLine, getCameraMatrix
  14. from personal experience, I do not advise you to use СEF - or to be more precise html interfaces (they are resource-intensive and very buggy since the browser version itself is also old to use). I talked to a lot of people on this topic and many of them claimed me and even gave many examples that this is really a senseless idea. + also, not everyone can load these interfaces
  15. I apologize for my English, maybe I expressed myself incorrectly. I'm not trying to get the code from the client side to the server side or vice versa! the file from where I got the code and the code from the file from where I used it were both on the client side. But I have already fixed these errors, and to be more precise, somehow the error disappeared after restarting the server, but after that I ran into the problem of loading loadstring using the function, but I solved this problem as well. For some reason, when using the register_bridge function, I kept a path with a different resource name example [my resource was called shadow_fonts] - and it placed shadowfonts in the table. Well, again, I fixed that, too.
  16. if you need a unique key, then why not generate it? For example, get the player's time and add a random value to it at the end? or the player element itself? And then hase it all in md5? md5(toJSON(getRealTime())..""..math.random(0, 5000)) else md5(toJSON(getRealTime())..""..localPlayer) -- client side else element player for server side
  17. Hello, I made a system in the likeness of a bridge - the essence is to get functions and so on from one resource for use in another (I did this in order to use my libraries) - the problem is that there are two functions for registering a file and getting it ( using) I do this and debaging everything, the path she gets an example :shadow_fonts/client.lua - but when using this path, file Open gives an error that it cannot find the path to the file, I rechecked the correctness of the name 100 times when registering the file and the path to the folder, but not to which one. ShadowBridge = { ShadowBridgeData = {}; --[[void]] ShadowBridge = function(this) print("[ShadowBridge] Bridge constructor succesfull started!"); end, --[[bool]] Export = function(this, p_tree, src, path) local fullpath_to_file = (":"..p_tree.name.."/"..path); --print(fullpath_to_file); if not (fileExists(fullpath_to_file)) then return false; end this.ShadowBridgeData[src] = { --[[Resource]] parent = p_tree, --[[String]] src = src, --[[String]] full_path = fullpath_to_file, } print(inspect(this.ShadowBridgeData)) return true; end, --[[string]] Import = function(this, src) local file = fileOpen(this.ShadowBridgeData[src].full_path); print(this.ShadowBridgeData[src].full_path) local rawdata = fileRead(file, fileGetSize(file)); fileClose(file); return rawdata; end, } --[[Raw Code]] function GetBridge() return [[ function using(src_name) loadstring(exports.shadow_framework:Import(src_name))(); end function bridge_register(src_name, file_path) return exports.shadow_framework:Export(src_name, file_path) end ]] end --[[String]] function Import(src_name) return ShadowBridge:Import(src_name); end --[[Bool]] function Export(src_name, file_path) return ShadowBridge:Export(sourceResource, src_name, file_path); end example usage : imagine that I have a fonts client resource and a client.lua file -- client -- loadstring(exports.shadow_framework:GetBridge())(); bridge_register("fonts", "client.lua"); function test() print("hello world") end now the second example in another script, let's say main and the client.lua file - ( note that the client part is also where I want to use functions from another script ) -- client -- loadstring(exports.shadow_framework:GetBridge())(); using "fonts" but it gives the following errors https://imgur.com/a/TOYMa7k and yes, by the way, here are more places of the bridge resource <meta> <script src="framework_bridge.lua" type="shared" /> <export function="Import" type="server" /> <export function="Import" type="client" /> <export function="Export" type="server" /> <export function="Export" type="client" /> <export function="GetBridge" type="server" /> <export function="GetBridge" type="client" /> <oop>true</oop> </meta>
  18. Hello, I have been tormented for a long time by a question related to blurring, namely on texture. I tried many methods to implement blur on a graphic element, but they all failed, and the fact is that in all shaders or resources, the player's screen is used for the blur texture and a shader is applied to it. And if you apply a blur to a transparent texture, then the blur will not work, and a black texture will be in the background in its place. After reading a lot of information on the implementation of blurring on different sources, I realized that blurring works in such a way that several images are taken that overlap each other and the transparency and position of the texture change and thus the blur effect is created, but here's the catch is it possible to implement this through a shader at all? Namely, to apply a blur to a transparent texture? Because I needed to create a 3d transparent image on which a blur will be superimposed and so that looking at the picture you can see the background behind it from the map well, this is more specific - below is an example of what exactly I wanted to implement. As you could see in the picture you can see a blurred box with glass effect blur, I need to do the same blur on a 3d element, but again, how can I apply a blur if the texture is transparent?
  19. Hello, I would like to know how you can apply a blur effect on a 3d picture in the world? I tried to use a shader from the blur_box resource, but for some reason it gives me a black texture if I apply a blur effect to a transparent image, and only allows you to apply a blur to a dxCreateScreenSource, and I would like to know how you can apply a blur effect to a 3d transparent image? And which shader is suitable for this?
  20. you can determine the state of the player's life every time in the onClientRender render and make a check if the player has less than 1 hp, then constantly install 1 hp for him and set animation for him. this is a crutch option
  21. make a check on the distance between two players and hide his nickname at a certain distance!
  22. Hello again, I did this rotation animation a little differently and even added a 3d looking animation when the mouse is clamped, but there is only one problem that I can't fix for a long time... Namely, it is associated with rotation. The fact is that after turning the interpolation from 0 to -180 degrees and after that, when I hold down the key to view the plate, I have a mirror image on the other side, well, the problem is that in two versions of dxSetShaderTransform, I use different rotation. If possible, help me with an approximate solution, because I've tried many options and I can't figure out how to make it work better. here is an example video local screen = Vector2(guiGetScreenSize()); local px = ( screen.x / 1920 ); local size = Vector2(634*px, 376*px) local position = Vector2(screen.x / 2 - size.x / 2, screen.y / 2 - size.y / 2); local target = dxCreateRenderTarget( size.x, size.y, true ); local backTarget = dxCreateRenderTarget( size.x, size.y, true ); local stateRotation = false; local rotationX = 0; local tick = nil; local swithState = false; local stateRotationHover = true; function render() if isCursorShowing() then mx, my = getCursorPosition(); local rotX = (screen.x / 2) - mx * screen.x; local rotY = (screen.y / 2) - my * screen.y; if not stateRotation then if getKeyState("mouse1") then dxSetShaderTransform(maskShader, rotX / 100, -rotY / 100, 0 ) print(rotX) end else if tick then if not stateRotationHover then rotationX = interpolateBetween( 0, 0, 0, -180, 0, 0, ( getTickCount() - tick ) / 1000, "Linear" ) else rotationX = interpolateBetween( -180, 0, 0, 0, 0, 0, ( getTickCount() - tick ) / 1000, "Linear" ) end dxSetShaderTransform(maskShader, rotationX, 0, 0 ) end end end dxSetRenderTarget(target, true); if rotationX <= -90 then dxDrawImage(size.x, 0, -size.x, size.y, "assets/rect_box2.png", 0, 0, 0); else dxDrawImage(0, 0, size.x, size.y, "assets/rect_box.png", 0, 0, 0); end dxSetRenderTarget() dxDrawImage(position.x, position.y, size.x, size.y, maskShader); end addEventHandler("onClientClick", root, function(btn, state) if state == "down" then else return end; if isCursor(position.x, position.y, size.x, size.y) then if stateRotationHover then if not swithState then swithState = true; stateRotation = true; tick = getTickCount(); stateRotationHover = false; setTimer(function() swithState = false; stateRotation = false; end, 1000, 1) end elseif not stateRotationHover then if not swithState then swithState = true; stateRotation = true; tick = getTickCount(); stateRotationHover = true; setTimer(function() swithState = false; stateRotation = false; end, 1000, 1) end end end end) addEventHandler("onClientResourceStart", root, function() maskShader = dxCreateShader("assets/mask3d.fx"); maskTexture = dxCreateTexture("assets/rect_box.png"); dxSetShaderValue( maskShader, "sPicTexture", target ); dxSetShaderValue( maskShader, "sMaskTexture", maskTexture ); addEventHandler("onClientRender", root, render); showCursor(true); end) function isCursor(x, y, w, h) if not isCursorShowing() then return false end; local mx, my = getCursorPosition(); mx = mx * screen.x; my = my * screen.y; if ( mx >= x ) and ( mx <= x + w ) and ( my >= y ) and ( my <= y + h ) then return true end; end
  23. oh, I'm sorry that I'm bothering you, of course, at the moment I was able to figure out this function and I'm already starting to create the animation I need, as soon as I'm done with this work, I will definitely share my work in this article so that in the future someone will also be able to use it
×
×
  • Create New...