Jump to content

Dzsozi (h03)

Members
  • Posts

    696
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by Dzsozi (h03)

  1. Okay, so I realised that this only happens when I use the createEffect function, but I tried it with fxAddFootSplash and it was working. My question is why it doesn't work with the createEffect function and how can I make it work with that function?
  2. Hello! I would like to do a simple function which allows me to create GTA SA effects at the position of the vehicle's wheels. For some reason the effect is being created only at one wheel, which is the right front wheel in case of cars, and the front wheel in case of bikes. I don't know what am I doing wrong, I would be grateful if someone could help me solve the problem, here's my script: Client Side: local effectAtWheels = {} function createEffectAtWheels(vehicle, effect) if not tostring(effect) then return false end if vehicle and isElement(vehicle) and getElementType(vehicle) == "vehicle" then local vehicleType = getVehicleType(vehicle) if vehiclesWithWheels[vehicleType] then local vehicleX, vehicleY, vehicleZ = getElementPosition(vehicle) local _, _, vehicleRotation = getElementRotation(vehicle) for component in pairs(getVehicleComponents(vehicle)) do if wheelComponents[component] then for i=1, #component do local wheelX, wheelY, wheelZ = getVehicleComponentPosition(vehicle, component, "world") local groundZ = getGroundPosition(wheelX, wheelY, wheelZ) if wheelZ <= groundZ+0.5 then -- if the wheel is on the ground effectAtWheels[component] = createEffect(effect, wheelX, wheelY, wheelZ-0.225, 0, 0, vehicleRotation, 150, false) end if effectAtWheels[component] and isElement(effectAtWheels[component]) then return effectAtWheels[component] end end end end end end end Global/Shared script: wheelComponents = { ["wheel_lf_dummy"] = true, ["wheel_lb_dummy"] = true, ["wheel_rf_dummy"] = true, ["wheel_rb_dummy"] = true, ["wheel_front"] = true, ["wheel_rear"] = true, } vehiclesWithWheels = { ["Automobile"] = true, ["Bike"] = true, ["Trailer"] = true, ["BMX"] = true, ["Monster Truck"] = true, ["Quad"] = true, } What could be the problem? I don't understand why is it happening, there is nothing seems to be wrong for me, also, debugscript doesn't output any errors. Thank you for your reply in advance!
  3. From my perspective, it requires more shader knowledge than I have, I wouldn't be able to do it by myself yet. Maybe later, when I get more experienced with shaders, for now I stick to the method that can be seen here.
  4. If you can remember and explain how it must be done, I might remake it.
  5. After the base system is done it could be done easily by adding more textures and lowering the time values. -- current local grungeTextures = {} grungeTextures[1] = dxCreateTexture("files/images/nogrunge.png") grungeTextures[2] = dxCreateTexture("files/images/lowgrunge.png") grungeTextures[3] = dxCreateTexture("files/images/defaultgrunge.png") grungeTextures[4] = dxCreateTexture("files/images/biggrunge.png") grungeTextures[5] = dxCreateTexture("files/images/megagrunge.png") You can add as many textures as you want. But I don't know how adding more textures would affect the performance. Right now this is the only way I could think of a solution for what you wrote.
  6. Thank you! And thanks for your feedback!
  7. Added video and a few more content!
  8. I found a solution by myself, but thank you for your time, I appreciate it! Since I am using onClientRender event I could make my own "timer"/progress thing. I don't know how it doesn't came into my mind faster, it works perfectly.
  9. Thank you for your reply, but this doesn't work as well. I tried using outputChatBox to see the tick count, and I get a wrong tick number and also, the process doesn't start from the tick where it was paused. Is there any other way to make something similar? Or is there any solution for this one?
  10. Hello! The title almost explains everything I want to do. I can't get my script working, I would like to freeze/get a specific time whenever a vehicle stops, and when it starts again continue counting back from that time. Something like storing the "time" whenever a vehicle stops and when it starts moving again start from where it stopped. Here's my partial function: if isVehicleOnGround(vehicle) then if getVehicleSpeed(vehicle) >= 10 then currentTime = -- return from the stored time/tick count, how can I do that?!?!? if currentTime - lastTimeAdded[vehicle] >= 5000 then if someVariable < #someTable then someVariable = someVariable+1 lastTimeAdded[vehicle] = getTickCount() else someVariable = #someTable end end else -- how can i store and freeze currentTime variable? it is a getTickCount(), how can I store and then return it above????? end end This is a kind of timer, since I am using onClientRender I thought that this would be the most efficient, also, setTimer functions look ugly to me so I didn't even try them. Is there any other way to do this inside an onClientRender function? I am cracking my head over this since like 2 days but can't get the result I want. How can I do that? Here's an example: Let's say I go forward with the vehicle and the currentTime variable starts counting from 0, when the counter is at 2500 (milliseconds) I stop with the vehicle. I want the timer to stay 2500 and then when I move again start the timer from 2500 until it reaches 5000. Hope you understand my problem! Thank you for your reply in advance!
  11. If you still need it: http://gta.wikia.com/wiki/Jester
  12. Hello! I would like to show you my current project I am working on. This is about vehicles getting dirtier while you are driving them (something you can see in GTA IV and GTA V). It is currently in beta, I may release if after I finished it! Here you can see some pictures of the current features of the script: Every vehicle that has the vehiclegrunge256 texture on it is compatible with this script (you can add your own textures in the script you would like to change, for example if the modded vehicle doesn't have the vehiclegrunge256 texture, but has a texture named only grunge, you can add this in a table, so it will work with that one as well). replaceTextures = { {"vehiclegrunge256"}, {"grunge"}, } The script contains car washes (you go into a car wash --> your vehicle gets cleaned). You can enable/disable custom car wash garage maps via script when adding a new car wash. carwashes = { -- x, y, z, rotation (for garage only), garage {2454.51343, -1461.01477, 24.00000, 0, false}, {1911.29041, -1776.22644, 13.38281, 0, false}, {1017.74756, -917.59283, 42.17969, 0, false}, {1574.125, -2350, 13.56247, 90, true}, } When the weather is rainy or you go into water with your vehicle it gets cleaner over time. Every vehicle is affected in this case, for example if there are vehicles parked around on the map with dirt on it and it is raining, they will get cleaner slowly. There are 5 states of dirt level, 1 is fully clean and 5 is the dirtiest. The script currently has 2 export functions which with you can change and get the dirt level of a vehicle (you can also get the dirt level of a vehicle with getElementData, but can't change it with setElementData, I will add dirt level changing with setElementData in further updates). Vehicles will get dirty faster if you drive on grass, sand, dirt, etc. They will get dirty anyways, but it is faster on materials that is not concrete or something similar. I will upload a video soon of the script so you can see it in progress. As I mentioned before, I might release it after it's done. Not much to add/improve, this means it will more likely to happen sooner than later. VIDEO: This is still a beta version! The video doesn't show real values of time and other intervals, everything is because of testing and showing a pre-version of the script. Work is currently in progress regarding this script / project! TO DO: [GREEN] = Done [ORANGE] = In progress [RED] = Need to be done - Fix any appearing bugs, requires a few more testing to make sure there are none [ * ] - Make it compatible with car paint shaders (I don't know yet if it is possible, I will try to do it) [ * ] - Add useful custom events (on[Client]VehicleDirtLevelChange, on[Client]VehicleWashed, etc. everything that is useful for further scripting and for developers) [ * ] - Make a better handler for getting vehicle dirty, right now the script uses onClientRender, there might be another solution that is more client friendly, I don't know, I will play around with possibilities [ * ] WHAT'S NEW: * 2017. 10. 13. - Custom dirt textures - Vehicle streaming optimization - Useful, dynamic debug panel, outputs and values for testing - You can switch between debug mode in game - Fixed syncing bugs / errors between client and server (some things still need to be fixed) - Improved car washes (far from done, still needs improving and adding some extras) - Improved "dirt-add-handling-progress" (can't say it better ) * 2017. 10. 14. - Fixed various present bugs (a few of them can be seen in the video) - Vehicles now store the current dirt progress when they are streamed out and streamed in - Rewritten dirt progress handling, more dynamic and 0 (didn't found any yet) bugs, depending on conditions (is it raining, is vehicle in water, etc.) - Client side event now triggers when server side event is triggered but not the opposite way - Improved debug display - Shortened and more optimized script Client side is about 350 lines (with debug) and server side is about 50 lines (with debug and commands) of code. * 2017. 10. 26. - Fixed a bug where the vehicles' dirt progress wasn't synchronized between players. - More optimized script - Custom functions: * getVehicleDirtLevel (shared) * setVehicleDirtLevel (server) * * getVehicleDirtProgress (shared) * setVehicleDirtProgress (server) * * getNextDirtTime (shared) * setVehicleDirtTime (server) * - Custom events: * onClientVehicleDirtLevelChange (client) * onVehicleDirtLevelChange (server) * * 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. EDIT: I would appreciate if somebody could tell me a simple but interesting name for the resource, that is not "Vehicles Get Dirty" (it is too long). I was thinking about VGD, but this is not good enough, nobody will know what does that mean if it gets uploaded to the community. Download: https://community.multitheftauto.com/?p=resources&s=details&id=14960 Note that you will have to give up on car paint shaders if you would like to use this resource, unless you know how to make both work, since I couldn't figure it out. But if you know, please let me know as well and I will fix this problem with a quick update on this resource!
  13. I don't think that this is what I need, also I didn't read your code carefully since I got it working. Here's the solution (or at least the way I made it working): if indicatorState then indicatorX = indicatorX + indicatorSpeed else indicatorX = indicatorX - indicatorSpeed end if indicatorX >= posX + sizeX - indicatorSize/2 then indicatorState = false end if indicatorX <= posX - indicatorSize/2 then indicatorState = true end local changeValue = (indicatorSpeed)/(sizeX) colorProgress = indicatorState and math.min(colorProgress + changeValue, 1) or math.max(colorProgress - changeValue, 0) local colorR, colorG, colorB = interpolateBetween(150, 0, 0, 75, 150, 20, colorProgress, "SineCurve") It is working, when the colorProgress is 0.5 (green color) the indicator is at the middle of the bar, no matter what the bar X size is. Thank you for your help pa3ck and I appreciate you trying to help Xero~.
  14. After I made the topic I was thinking about using math.abs function and making it work with -1, 0 and 1 value, I don't know if this would be easier to do, also, I didn't test it since I made the post. What do you think?
  15. I changed the shader file to this and changed the shader values in the script to be correct, but I have the same problem. Here's a picture what I currently have: What I would like it to be: Without the black background, but with the fading on the sides.
  16. Hello! I have a little problem with render targets that I don't know how to solve. I made a render target with alpha channel enabled, so I won't see the black background. If I draw the render target itself it works fine, I can't see the black background, only problem now is that I am missing a fading effect from the edges. So I applied a mask shader and made a mask for this render target, but if I apply this mask shader on the render target the black background appears. I don't think there is a problem in my script, more likely in the shader file, but I don't know how to edit shaders, I don't know how I could fix it, I guess I would have to change up some things in connection with the source alpha, but I know nothing about shaders. I would appreciate if someone with shader knowledge could help me out with this! Here's my mask shader file: texture tex0; // texture texture maskTex0; // mask float finalAlpha; sampler sBase = sampler_state { Texture = (tex0); MinFilter = Linear; MagFilter = Linear; AddressU = Clamp; AddressV = Clamp; }; sampler sAlpha = sampler_state { Texture = (maskTex0); }; float4 ps( float2 Base : TEXCOORD0 ) : COLOR { float4 color; float4 alpha; color = tex2D( sBase, Base.xy ); alpha = tex2D( sAlpha, Base.xy ); color.a = alpha.r*finalAlpha; return color; } technique mask { pass p0 { AlphaBlendEnable = TRUE; DestBlend = INVSRCALPHA; SrcBlend = SRCALPHA; VertexShader = null; PixelShader = compile ps_2_0 ps(); } } And here's how I use it in scripts: -- on resource start local shader = dxCreateShader("_files/mask.fx") local mask = dxCreateTexture("_files/images/mask.png") dxSetShaderValue(shader,"maskTex0",mask) dxSetShaderValue(shader,"finalAlpha",1) -- inside the render function dxSetRenderTarget(showAreaRenderTarget, true) dxSetBlendMode("modulate_add") -- bla bla drawing stuff dxSetBlendMode("blend") dxSetRenderTarget() dxSetShaderValue(shader,"tex0",showAreaRenderTarget) dxSetBlendMode("add") dxDrawImage(showAreaPosX, showAreaPosY-iconSize/4, showAreaSizeX, showAreaSizeY, shader) dxSetBlendMode("blend") So, as I wrote, the mask shader works fine, my only problem is that I can see the render target's black background, even when the alpha channel is enabled when creating the render target. How I could solve this?
  17. Here you go, if this is what you need (check description for download link): EDIT: You need this resource if you want to make the above script work: https://community.multitheftauto.com/index.php?p=resources&s=details&id=9398 and MAYBE this as well (I didn't try the resource yet): https://community.multitheftauto.com/index.php?p=resources&s=details&id=11071
  18. Hello! I would like to get the progress for an interpolation, but I don't know how to do it. I would like to make a rectangle green when an indicator going through it, so when the indicator is not at the rectangle I would like it to change color to red, and when it's getting closer to the rectangle then make it green. My only problem is that the rectangle is being on the middle and the indicator is going from left to right and then backwards, right to left. Here's what I would like to achieve, I created a gif for this, so it is easier to understand. I would like to reach this, but can't seem to find a solution. Here's what I currently have: local sx, sy = guiGetScreenSize() local sizeX, sizeY = 230, 30 local centerX, centerY = sx / 2 - sizeX / 2, sy / 2 - sizeY / 2 local posX, posY = centerX, centerY local barRange = 30 local barLeftSide, barRightSide = posX + sizeX/2 - barRange/2, posX + sizeX/2 local barMiddle = (barLeftSide + barRightSide)/2 local indicatorSize = 20 local indicatorX = posX - indicatorSize local indicatorState = true local colorProgress = 0 -- inside the render function if indicatorState then indicatorX = indicatorX + 5 else indicatorX = indicatorX - 5 end if indicatorX >= posX + sizeX then indicatorState = false end if indicatorX <= posX - indicatorSize then indicatorState = true end -- colorProgress = ? local colorR, colorG, colorB = interpolateBetween(125, 20, 20, 20, 125, 20, colorProgress, "Linear") dxDrawRectangle(posX + 2, posY + 2, sizeX - 4, sizeY - 4, tocolor(0, 0, 0, 150)) dxDrawRectangle(barLeftSide, posY + 2, barRange, sizeY - 4, tocolor(colorR, colorG, colorB, 255)) dxDrawImage(indicatorX, posY - indicatorSize, indicatorSize, indicatorSize, "files/indicator.png", 180) So, how can I get the colorProgress to get the same effect as on the gif?
  19. You can try using getVehiclePanelState
  20. I know about this resource, this is not what I would like to achieve.
  21. I don't think that it would work out as well, also this is lot of work for just a script that is I think is possible with dxDraw functions. I don't know if any of you have ever played on the Need For Speed SA server, like in the default NFS game, you can make magazine runs and magazine covers, and on this server, when you are making a magazine cover, you can select various backgrounds, but the making of the magazine simply happens in the free run mode, enabling just a kind of an editor for you. So there, you can change between various backgrounds, but when you changed a background it looks like there is just an image drawn on the screen behind your vehicle, it is the same effect that I would like to reach, but with a green background. Here's an example image: Without the background: With backgrounds: And I would like to reach this effect, but with a fully green background.
×
×
  • Create New...