Jump to content

Dzsozi (h03)

Members
  • Posts

    682
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Dzsozi (h03)

  1. Hello! I am trying to do a boundary system based on coordinates, so no col shapes or anything. Unfortunately I'm not that good at math, but I tried doing it based on found results on the internet. My problem is that this whole script is not working how it should, check it for yourself, it has debug outputs and visible markers for corners and the center. Why does the width and height return a much bigger number than the calculatedX and calculatedY? Why does the calculatedX and calculatedY return always the same? Why does the width and height change values as I move around? I would be really grateful if somebody could help me, this is for a community project, so others would be too! Here's my current full code: Global: customBoundaries = { -- this boundary is between the big brown building(s) and the skatepark on the road in LS ["test"] = { point1 = {x = 1842.2908935547, y = -1412.469360351}, point2 = {x = 1856.8596191406, y = -1412.555664062}, point3 = {x = 1851.5925292969, y = -1436.5225830078}, point4 = {x = 1842.0438232422, y = -1424.5217285156}, }, } Client: local debugEnabled = true function sum(n) return ((n+1) * n) / 2 end function isElementWithinBoundary(element, boundary) if element and isElement(element) then local elementX, elementY, elementZ = getElementPosition(element) boundary = tostring(boundary) if boundary and type(boundary) == "string" then if customBoundaries and customBoundaries[boundary] then local corner1 = {customBoundaries[boundary].point1.x, customBoundaries[boundary].point1.y} local corner2 = {customBoundaries[boundary].point2.x, customBoundaries[boundary].point2.y} local corner3 = {customBoundaries[boundary].point3.x, customBoundaries[boundary].point3.y} local corner4 = {customBoundaries[boundary].point4.x, customBoundaries[boundary].point4.y} local centerX, centerY = (corner1[1] + corner2[1] + corner3[1] + corner4[1])/4, (corner1[2] + corner2[2] + corner3[2] + corner4[2])/4 local originX, originY = elementX - corner1[1], elementY - corner1[2] local width = math.sqrt((corner2[1] - originX)^2 + (corner2[2] - originY)^2) local height = math.sqrt((corner4[1] - originX)^2 + (corner4[2] - originY)^2) local calculatedX = originX * (corner2[1] - originX)/width + originY * (corner2[2] - originY)/height local calculatedY = originX * (corner4[1] - originX)/width + originY * (corner4[2] - originY)/height outputChatBox("X: " .. math.floor(calculatedX) .. " | width: " .. math.floor(width)) outputChatBox("Y: " .. math.floor(calculatedY) .. " | height: " .. math.floor(height)) if (0 <= calculatedX and calculatedX <= width) and (0 <= calculatedY and calculatedY <= height) then outputChatBox("XD") end if debugEnabled then for points, coordinates in pairs(customBoundaries[boundary]) do local cornerMarker = createMarker(coordinates.x, coordinates.y, getGroundPosition(coordinates.x, coordinates.y, elementZ), "cylinder", 2, 140, 245, 20, 150) local centerMarker = createMarker(centerX, centerY, getGroundPosition(centerX, centerY, elementZ)+2, "arrow", 1, 245, 140, 20, 150) end end end end end end isElementWithinBoundary(localPlayer, "test") Here's the calculation I was trying to copy and make it work based on: https://math.stackexchange.com/a/190257 I hope you understand my problem, thank you for your reply in advance!
  2. Maybe a custom map editor to support self-customised JStreamer maps? Would be 10/10
  3. And better performance is what I am trying to achieve.
  4. I found this logo I made a while back on my computer while I was deleting unwanted files. I thought this might be useful for others who want to make a custom logo for their servers or just photoshop something. For example, this is the final logo I created it for: Original sizes Horizontal: 1900 x 350 Square: 1250 x 1250 DOWNLOAD (.rar file containing the full size original .png files. No quality loss.)
  5. First I was thinking about a custom launcher as well, and I wanted to do that but I don't know how. But what do you mean by it is useless? Can I do everything without making a custom launcher or anything, just by modifying MTA settings or what? Could you explain it a little bit better?
  6. Oh, alright, sorry I didn't know that. Could a moderator move this topic to the correct section?
  7. Thank you for your reply, but this is still not the effect I would like to reach. There's the cartoon shader, it has an outline shader that is being applied for everything, I just need to know how can I get this outline and apply it to an element I choose.
  8. Hi! I would like to do a custom MTA client. Here's the reason why I was thinking about it: I would like to change the map from SA to a different one, I know it is possibble with scripting, but I would like to go a little bit deeper and replace it in the "engine" if you know what I mean. I was thinking about replacing the gta3.img files and other ipl and xml and such files with the default ones, but I don't know how I should start doing it. I never did something like this. How I could achieve that MTA would load a different gta3.img for example, with the modded objects and vehicles and such, so whenever I start my custom client, I could only join to my own server and it wouldn't download and load the custom map, since the downloaded custom client already has the files by default and it loads it first, instead of the SA map. I would really appreciate if somebody could help me out which way I should start looking forward to do it or how to do it. I know that the SA:MP client requires you to choose the default GTA SA folder, and it also puts some stuff in there, maybe an img file if I remember correctly, since SAMP uses some custom objects. Also, that way (with the custom client/launcher) it may be possibble to add extra models/objects to the game in MTA? It would be nice if someone more experienced scripter or programmer could provide some information in connection with this. EDIT: I am also interested if using custom img and definition files for coordinates is more PC and FPS friendly than just using simple lua scripts in MTA SA to replace objects.
  9. I wouldn't have opened a topic here if I could do it by myself. That doesn't help me out much.
  10. This is not an outline, just scaled up textures which is not the same. I already tested it.
  11. I know about this resource and I get it, but | | V And I guess I would have to edit the .fx file, but I don't know what to do, edit where and what? I have no idea.
  12. Hello! I would like to make a shader which creates an outline for an element I choose to. Similar to this effect on the image (look at the right bottom corner and the desk, you can see a blue and a yellow outline for the objects): One more example: I have a .fx file and a few lines of code, but I am not sure what should I do with the shader file, I just started learning HLSL language and I almost know nothing about it. I found this shader on a tutorial website for HLSL, here: http://rbwhitaker.wikidot.com/toon-shader and I just copied the parts that I think I need, the outline part of the shader. But my script doesn't seem to work, I don't know what could be the problem and how to solve it, and also, debugscript 3 doesn't output any errors. It would be awesome if somebody could help me out with this one. Here's my current client side script: local outlineShader function createElementOutline(element, thickness, r,g,b,a) if element and isElement(element) then for _,name in ipairs(engineGetModelTextureNames(tostring(getElementModel(element)))) do dxSetShaderValue(outlineShader, "Texture", name) engineApplyShaderToWorldTexture(outlineShader, name, element) end dxSetShaderValue(outlineShader, "LineThickness", thickness) dxSetShaderValue(outlineShader, "LineColor", r/255, g/255, b/255, a/255) end end addEventHandler("onClientResourceStart", resourceRoot, function() if getVersion().sortable < "1.5" then outputChatBox("Resource is not compatible with this client.") return else outlineShader = dxCreateShader("shaders/outline.fx") createElementOutline(localPlayer, 1, 255,255,255,255) if (not outlineShader) then outputChatBox("Could not create Outline shader. Please use debugscript 3.") end end end) And the shader file: // The world transformation float4x4 World; // The view transformation float4x4 View; // The projection transformation float4x4 Projection; // The transpose of the inverse of the world transformation, // used for transforming the vertex's normal float4x4 WorldInverseTranspose; // The color to draw the lines in. Black is a good default. float4 LineColor = float4(0, 0, 0, 1); // The thickness of the lines. This may need to change, depending on the scale of // the objects you are drawing. float LineThickness = .03; // The texture being used for the object texture Texture; // The texture sampler, which will get the texture color sampler2D textureSampler = sampler_state { Texture = (Texture); MinFilter = Linear; MagFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; struct AppToVertex { float4 Position : POSITION0; // The position of the vertex float3 Normal : NORMAL0; // The vertex's normal float2 TextureCoordinate : TEXCOORD0; // The texture coordinate of the vertex }; // The structure used to store information between the vertex shader and the // pixel shader struct VertexToPixel { float4 Position : POSITION0; float2 TextureCoordinate : TEXCOORD0; float3 Normal : TEXCOORD1; }; // The vertex shader that does the outlines VertexToPixel OutlineVertexShader(AppToVertex input) { VertexToPixel output = (VertexToPixel)0; // Calculate where the vertex ought to be. This line is equivalent // to the transformations in the CelVertexShader. float4 original = mul(mul(mul(input.Position, World), View), Projection); // Calculates the normal of the vertex like it ought to be. float4 normal = mul(mul(mul(input.Normal, World), View), Projection); // Take the correct "original" location and translate the vertex a little // bit in the direction of the normal to draw a slightly expanded object. // Later, we will draw over most of this with the right color, except the expanded // part, which will leave the outline that we want. output.Position = original + (mul(LineThickness, normal)); return output; } // The pixel shader for the outline. It is pretty simple: draw everything with the // correct line color. float4 OutlinePixelShader(VertexToPixel input) : COLOR0 { return LineColor; } // The entire technique for doing toon shading technique Toon { // The first pass will go through and draw the back-facing triangles with the outline shader, // which will draw a slightly larger version of the model with the outline color. Later, the // model will get drawn normally, and draw over the top most of this, leaving only an outline. pass Pass1 { VertexShader = compile vs_2_0 OutlineVertexShader(); PixelShader = compile ps_2_0 OutlinePixelShader(); CullMode = CW; } } I guess I will need to use mta-helper.fx to get some positions, maybe the camera position, I am not sure, I don't really understand yet how shaders work. Thank you for your reply in advance!
  13. I have been trying to change the values, but these doesn't seem to work, well I can't make them functioning the way I would like to. But I have one more idea, I don't know if it is possibble, but is there any way to get the surface rotation or anything like this? I'm thinking about the default headlight shadow's functionality, is there any way to recreate the way it is working?
  14. Hello! I really need some math experts' help, I can't figure out what should I do. I am using the dxDrawMaterialLine3D function to draw light shadows on the ground, and these are attached to a vehicle. My only problem is that I don't know how should I make the light always face up, even when the vehicle is rotated and keep the rotation, so I won't experience problems like this: So as you can see, when I'm not on an even surface, the "light" goes through the ground, that's why I would like to make the image face upwards depending on the vehicle's rotation, or at least adjust it and not make it face always up. I hope you understand what I am trying to do. Here's what it should look like (it is on an even surface): So, I don't really know how should I calculate these numbers to make it work with the faceTowardX, faceTowardY and faceTowardZ parameters. Could somebody help me out with the calculations? local x, y, z = getElementPosition(matching.element) local rx, ry, rz = getElementRotation(matching.element) local faceX, faceY, faceZ = --?, ?, ? dxDrawMaterialLine3D(worldX, worldY-1, fixedGroundPosition, worldX, worldY+1, fixedGroundPosition, data.renderTarget, 2, tocolor(lightColor[1],lightColor[2],lightColor[3],lightColor[4]), faceX, faceY, faceZ) Thank you for your reply in advance!
  15. Hello! I have a simple question for people experienced with shaders. This might not be hard to do, but I am no expert when it comes to shaders. I would like to make a shader which allows me to add a texture on top of an existing texture. For example, let's say I want to make CJ's clothes dirty without replacing the actual clothing texture, but instead I could apply the shader on the player_torso (I guess), and if it is possibble, I could create a new texture which could be placed on the player_torso texture, but not replacing it, just adding the custom texture on top. I hope you understand me. So the question is, how can I make something like this possibble? If it's not a big favor, could somebody help me out with writing the fx shader file? I have 0 HLSL knowledge, so that would be really helpful. Thank you for your reply in advance!
  16. Yes I agree and I was also thinking about it.
  17. https://community.multitheftauto.com/index.php?p=resources&s=details&id=12903 This may help you out with the rotations.
  18. It works, thank you so much! I didn't even think about this kind of solution. Thanks again!
  19. Hello! I would like to make dxDrawTexts draw after each other with a little offset between them, like a horizontal menu thing. But I keep failing, I have been trying to solve this for hours now but I can't get the result I want. What am I doing wrong? local defaultButtonColor = tocolor(180,180,180,255) local normal = dxCreateFont("files/fonts/normal.ttf", 24, true, "antialiased") local buttonSize = 0.5 local marginOffset = 10 local menuButtons = { {"SADSADASWQETSADASG", defaultButtonColor, hover = false}, {"QRWRQW", defaultButtonColor, hover = false}, {"GDADSSASDFSASD", defaultButtonColor, hover = false}, {"FHDJRSDAD", defaultButtonColor, hover = false}, } function draw() for i=1, #menuButtons do if menuButtons[i] then local menuButtonTextWidth = dxGetTextWidth(menuButtons[i][1], buttonSize, normal) local menuButtonTextHeight = dxGetRealFontHeight(normal) local step = 50 + ((i - 1) * (menuButtonTextWidth + marginOffset)) -- problem is probably here somewhere, I guess dxDrawText(menuButtons[i][1], step, 400, 0, 0, menuButtons[i].hover and tocolor(255,255,255,255) or menuButtons[i][2], buttonSize, normal, "left", "top", false, false) end end end addEventHandler("onClientRender", root, draw) For some reason, this is the result I get: And this is what I would like to have: What is the problem, how should I do it?
  20. Check the modded vehicle's txd file if it has any light textures and replace them as well.
  21. addEventHandler("onClientResourceStart", resourceRoot, function() local shader1 = dxCreateShader("texreplace.fx") local lightsoff = dxCreateTexture("vehiclelights128.png") engineApplyShaderToWorldTexture(shader1,"vehiclelights128") dxSetShaderValue(shader1, "gTexture", lightsoff) local shader2 = dxCreateShader("texreplace.fx") local lightson = dxCreateTexture("vehiclelightson128.png") engineApplyShaderToWorldTexture(shader2,"vehiclelightson128") dxSetShaderValue(shader2, "gTexture", lightson) end) Try this and make sure that the paths for the textures in the script are correct. Also, did you add the textures in the meta file? What does the debugscript say?
  22. Hello! Today I am bringing you a new part/update of the Advanced Vehicle System project I am currently working on. This part of the project contains a simple, yet nice and effective reverse light system. It is not fully finished yet, still need some improvements and features, but I managed to get it done "partially", so I can show it to you. This is compatible with every vehicle that has the "vehiclelightson128" texture, which most of the time happens with modded vehicles. But it definitely does with default vehicles. [RED] = Unaffected lights [GREEN] = Affected lights In action: Currently this script has 3 custom functions and 2 custom events, these are: setVehicleLightsOn(vehicle, state) - This is a workaround for the default setVehicleOverrideLights function. [server] setVehicleReverseTexture(vehicle, state) - With this function you can toggle the reverse light texture on/off. [shared] isVehicleReversing(vehicle) - Returns true if the vehicle is reversing, false otherwise. [currently server only] onVehicleStartReverse - Parameters: driver, lightState [server] onVehicleStopReverse - Parameters: driver, lightState [server] driver: The player who drives the vehicle lightState: The light state of the vehicle (true/false). This returns the value set by setVehicleLightsOn function. Always returns something. The source of these events is the vehicle that starts/stops reversing. These events are triggered when a vehicle starts/stops reversing. More updates coming soon! I always like to read suggestions, so feel free to comment your thoughts and what should I add/remove! Thank you for reading, hope you like it! Part of the Advanced Vehicle System project.
  23. I think this resource has a pretty good and easy example for a dx scroll bar, this might help, I would take a look and give it a try if I was you. https://community.multitheftauto.com/index.php?p=resources&s=details&id=14403
×
×
  • Create New...