Jump to content

Moony

Members
  • Posts

    96
  • Joined

  • Last visited

Everything posted by Moony

  1. I heard about shaders, but I don't have enough knowledge yet. Would you please explain a bit more about shaders?
  2. I already have such script. I just wanted to add more variety to the wheel models. I haven't found I way to change the color of the object, so I thought I could add more models while learning about colors.
  3. The wheel upgrades have a limited amount of wheels. Replacing those can give you a limited amount of options. I was thinking that if I could "preload" more skins, I could make functions that also replace the .txd and .dff for each wheel, thus, surpassing the amount of changable wheels.
  4. After a lot of work and several tests, we managed to fix it. Case dismissed.
  5. I apologize for the format. I hope you can see the video correctly. The only thing that changed with the line provided (and also happened with the previous line) is that the width modifier now is modifying the height as seen in the video. I'm certain this is happening because there are values being read when they shouldn't. I'll try to fix that in the meantime. Regardless, they wheels are still not on ground level. I'll mess around with the values to see if I find anything weird.
  6. Here it is: function wheel1Move() local px1, py1, pz1 = getVehicleComponentPosition(vehicle, "wheel_lf_dummy") local vehicle = getPedOccupiedVehicle (localPlayer) if not vehicle then return end -- Gets ride of a couple of DB 3 errors. local wrx1, wry1, wrz1 = getVehicleComponentRotation (vehicle, "wheel_lf_dummy") attachElements (wheel1, vehicle, px1, py1, pz1, wrx1, wry1, wrz1) -- attachElements(wheel1, vehicle, px1, py1, pz1+getElementDistanceFromCentreOfMassToBaseOfModel(wheel1)*getObjectScale(wheel1)-getElementDistanceFromCentreOfMassToBaseOfModel(wheel1), wrx1, wry1, wrz1) -- Alternating between both 'attachElements' gives the same result show in the picture. end addEventHandler ("onClientPreRender", getRootElement(), wheel1Move) [IMAGE] * Ignore the excessive brightness. That's another issue I'll have to resolve.
  7. I've placed everything but the resizing in the 'onClientPreRender'. The resizing has the "stick to ground" function as well as the 'setObjectScale' only modifying the two necessary values. This is on a separate 'onClientGUIScroll'. I'm playing around with the functions, but I can't figure it out. I either get the glitchy will that is still anchored to the center, or no wheel at all. Sometimes the wheel flashes as it is rescaled, sometimes it looks clear. What's certain is that I can't find the correct setting to keep the wheels grounded. I've made sure there are no new instances of the wheels. I've placed the "stick to ground" function inside the 'onClientPreRender' function so it always updates the Z value. The scrollbar only modifies the scale of the wheel. [IMAGE]
  8. I apologize for the multiple posts; everytime I finish posting, I dare myself to test some more... As of this moment, the following function lets my set the diameter of the wheels. However, the wheels are pivoting from their center; if the size is small enough, they float; if they are big enough, they clip through the ground. fdiam = guiCreateScrollBar (0.09, 0.66, 0.375, 0.06, true, true, wheelWnd) local function setScaleFront () local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle then return end local fdim = guiScrollBarGetScrollPosition(fdiam) local fx1, fy1, fz1 = getObjectScale (wheel1) local fx2, fy2, fz2 = getObjectScale (wheel2) setObjectScale (wheel1, fx1, fdim/100+0.5, fdim/100+0.5) setObjectScale (wheel2, fx2, fdim/100+0.5, fdim/100+0.5) local x1, y1, z1 = getElementPosition (wheel1) -- attachElements(wheel1, vehicle, x1, y1, z1+2+getElementDistanceFromCentreOfMassToBaseOfModel(wheel1)*getObjectScale(wheel1)-getElementDistanceFromCentreOfMassToBaseOfModel(wheel1), 0, 0, 180) -- [Notice the above function disabled] end addEventHandler("onClientGUIScroll", fdiam, setScaleFront, false) Everything else works correctly: rotation, suspension, width and position relative to the center of the wheel dummy.
  9. Here's the function that used to handle the diameter of the wheels, one for both front wheels, and one for the rear wheels: fdiam = guiCreateScrollBar (0.09, 0.66, 0.375, 0.06, true, true, wheelWnd) local function setScaleFront () local vehicle = getPedOccupiedVehicle (localPlayer) local valueFront = guiScrollBarGetScrollPosition (fdiam) local sx1, sy1, sz1 = getObjectScale (wheel1) local sx2, sy2, sz2 = getObjectScale (wheel2) local px1, py1, pz1 = getVehicleComponentPosition (vehicle, "wheel_lf_dummy") local px2, py2, pz2 = getVehicleComponentPosition (vehicle, "wheel_rf_dummy") -- setObjectScale (wheel1, valueFront/100+0.5) -- setObjectScale (wheel2, valueFront/100+0.5) -- attachElements (wheel1, vehicle, px1, py1, pz1+getElementDistanceFromCentreOfMassToBaseOfModel(wheel1)*getObjectScale(wheel1)-getElementDistanceFromCentreOfMassToBaseOfModel(wheel1)) -- attachElements (wheel2, vehicle, px2, py2, pz2+getElementDistanceFromCentreOfMassToBaseOfModel(wheel2)*getObjectScale(wheel2)-getElementDistanceFromCentreOfMassToBaseOfModel(wheel2)) -- setObjectScale (wheel1, valueFront/100, valueFront/100, valueFront/100) -- setObjectScale (wheel2, valueFront/100, valueFront/100, valueFront/100) -- local position1 = getElementPosition (wheel1) -- local position2 = getElementPosition (wheel2) -- setElementPosition (wheel1, 0, 0, valueFront+0.01) -- setElementPosition (wheel2, 0, 0, valueFront+0.01) end addEventHandler("onClientGUIScroll", fdiam, setScaleFront, false) RESULT ** I've disabled everything. I tried to find the error but couldn't. The front train is the one available right now. I've disabled the rear train. As the bar is scrolled, the wheel jumps in a glitchy manner following an imaginary line that goes from the center of the car to the right top front corner. For every pixel that the bar is moved, the wheel jumps into this imaginary line and then returns to its ideal position. I think I know what the problem is. 'onClientPreRender' is constantly updating the position of the wheels. The wheel is kept on the ground only when the scrollbar is moved because the function is triggered by said event. When the bar is static again, the wheels' position is then updated again by the 'onClientPreRender'. In other words, I've got two 'attachElements' that are bumping eachother trying to fit in a very narrow door.
  10. Thought I could try a few things. Now that I know about 'onClientPreRender', I tried adding the suspension effect. You can do it the same way you used the handler for the rotation. I used your same format and 'getElementPosition' and 'attachElements' to set the position. It's hard to notice, but the front wheel is pressing up, while the rear wheel is almost hanging. [IMAGE]. Those are the custom wheels. If I only press the button to apply the set of wheels, they will show the noinclination mistake. Strangely, if I scroll the bar, they will light-speed move between a normal state and the no-inclination state. As if the commands were happing both everytime the scroll moves one point. I've managed to get a single frame by spamming the F12 to get the screenshot: [IMAGE] That screenshot also shows that the scrollbar updates not only the inclination, but the position as well. The scrolling also calls for the ground level. As soon as I lift the mouse off the bar, the wheels lose the ground effect and starts floating. I'll try to fix how the size effect works on the wheels and the angle/wobble with your last comment. Do you want me to show you the script? ---- ---- ---- ---- UPDATE: I tried your last suggestion, and it worked perfectly. I had to remove the "+rotz" to get rid of the vehicle's rotation adding to the wheels rotation. It all works perfectly UPDATE_2: keep ground level while resizing has stop working. Now there is a glitchy wheel that starts off from the center of the car and explodes off and get bigger as I increase the value of the scrollbar. As for the wheels, they glitchily increase size while staying anchored to their center.
  11. I've managed to: - Set the wheels at ground level at all times when resizing. - Set the rotation to follow the dummies' rotation (including the steering). - Add an extra resize width scrollbar. After reading a few posts, I fell victim of the same strange effect mentioned in them: if the cars have either the McPhearson suspension or the Reverse suspension applied, or the wheels change their Y rotation for any reason, a strange wobble effect appears on the wheels-object. Apparently, the wheels-object, as it constantly grabs the position of the wheels-dummy, when these change their Y rotation, the wheels-object do so too, but this Y rotation axe spins as well, giving the effect of a severely uncentered wheel. Is there any way to fix this? I read something about locking the Y and X rotation... Additionally, I've noticed that when changing the cars inclination, the wheels do not get this inclination. Instead, they stay perpendicular to the ground: [IMAGE] Also, there is no suspension on the wheels-object. Could this be fixed with an "onClientPreRender" applied to a function that gets the position of the dummies and then setting said position to the objects? Finally, and out of context, how can I stop the script from running when there are no custom wheels applied? DB 3 goes nuts because it is not finding any wheels to apply all these functions. This also applies to a button that removes the wheels: there is no wheel to remove, so the script throws a warning. Thanks for all the help so far! I can't think you enough.
  12. I'm pretty sure I'm not getting the functions. Nothing happens. Wheels are still static. I don't get how they both work, and how they have to be used to give the desired effect. I tried: local vehicle = getPedOccupiedVehicle(localPlayer) local x1, y1, z1 = getVehicleComponentPosition(vehicle, "wheel_lf_dummy") local a1, b1, c1 = getGroundPosition (x1, y1, z1) wheel1 = createObject (1097, a1, b1, c1, rx1, ry1, rz1) attachElements (wheel1, vehicle, a1, b1, c1, rx1, ry1, rz1) DB 3 returns "attempt to call global 'getGroundPosition' (a nil value) My thought process was (while hardly understand how the functions work): Get the ground position of the coordinates of the left front wheel of the vehicle being driven by the local player. Apply that position to the creation of the object and the attachment of the element.
  13. UPDATE: I've managed to set a minimum size to the wheels. However, I'm still having trouble getting the wheels to stay at ground level. Additionally, are there any functions to apply the rotation and steering visuals of the original wheels to the attached objects?
  14. Alrighty! Big progress has been made. Would you mind helping me a bit more? I've managed to set all 4 wheels in the appropiate place and apply a function to them to set the size. IMAGE I'd like to know if there is a way to keep the wheels grounded; they are anchored to the center. Is there a function that can help me in such way? Also, as soon as the scrollbar is moved, the wheels begin from practically a zero size, and scale 100 points (scroll value was divided by 100). Would it be possible to set the lowest limit? Here's the function that handles the size: -- Parent function that creates everything fdiam = guiCreateScrollBar(0.09, 0.66, 0.752, 0.06, true, true, wheelWnd) local function setScaleFront() local vehicle = getPedOccupiedVehicle(localPlayer) local valueFront = guiScrollBarGetScrollPosition(fdiam) local size = getObjectScale (wheel1) setObjectScale (wheel1, valueFront/100, valueFront/100, valueFront/100) setObjectScale (wheel2, valueFront/100, valueFront/100, valueFront/100) -- local position1 = getElementPosition (wheel1) -- local position2 = getElementPosition (wheel2) -- setElementPosition (wheel1, 0, 0, valueFront+0.01) -- setElementPosition (wheel2, 0, 0, valueFront+0.01) -- Failed attempt to set a dynamic position that increases -- 0.01 the position. end addEventHandler("onClientGUIScroll", fdiam, setScaleFront, false) -- Everything else.
  15. I've been working on a script that realistically manipulates the wheels. I've gotten to the point I can hide the original wheels, in hopes I can later attach a new set in the same place. I'm aware I might have to use attachElements, and several other functions. For the moment, I'd like to attach a single wheel. I've got this: -- All GUI elements. local vehicle = getPedOccupiedVehicle(localPlayer) local x1, y1, z1 = getVehicleComponentPosition(vehicle, "wheel_lf_dummy") local x2, y2, z2 = getVehicleComponentPosition(vehicle, "wheel_rf_dummy") local x3, y3, z3 = getVehicleComponentPosition(vehicle, "wheel_lb_dummy") local x4, y4, z4 = getVehicleComponentPosition(vehicle, "wheel_rb_dummy") local function replace1 () attachElements (1097, vehicle, x1, y2, z1, 0, 0, 0) end addEventHandler ("onClientGUIClick", set1, replace1, false) -- Function runs when button called 'set1' is clicked. -- Everything else. Here's my thought process: First, I get the player's vehicle. Then, I get the position of all four wheels in the player's vehicle, and represent them with x1, y1 and z1. With all wheels hidden by another function, I then attach the wheel model in the same place as the front left wheel. At the moment, I'm only aiming at the position; I'll handle the rotation later. DB 3 can't identify '1097', and thus asks for a valid element. Am I on the right path?
  16. I wanted to revive this little command since I never got it to work. After tens of small changes, I got it to work. I had to use an old format from another script I had. Here's the command majqq made: function myCommand(player, cmd) outputChatBox("player: "..inspect(player).." cmd: "..inspect(cmd), source) end addCommandHandler("testcmd", myCommand) This is what I did: function msgServer () outputChatBox ("player: "..inspect(player).." cmd: "..inspect(cmd)) end addCommandHandler ("sayserver", msgServer) If I leave the function's arguments empty, it sends: "player nil cmd nil". If I put what majqq put (player, cmd), it sends: "player: elem:player[Moony] cmd: "sayserver"" Let's see if I get it right: The inspect function is inspecting the element that triggered the command, which in this case is a player, and that player's name is "Moony". As for the command, it is throwing the simple string that was used to trigger the function. I don't quite get the "..have a different string representation". Do you mean that the string "player" is represented as "elem:player[Moony]"?
  17. I've been working on my own server for a few weeks now. After adding mods for vehicles, weapons and skins rocketed it to aproximatelly 500mb. I've found servers that are filled with skins, great mappings, scripts and more, and they weight around 200mbs. They have more skins, a lot more scripts and complex functions, new textures for buildings; basically, a complete make-over. I've only heard about the word "compiling". I'm confident there are other ways to reduce the weight for the client. Is there such thing as "server-side mods"? These are the heaviest. Maybe moving them server-side reduces the downloaded content significantly.
  18. I didn't know you could assign more than 1 argument when doing a local whatev = getSomething(argument 1, argument 2...) I know now. Thanks! So what you're doing is assigning the function 'getVehicleComponentVisible' to the string 'alreadyVisible'. Additionally, you're also saying that 'alreadyVisible' includes the dummy of the car that the localPlayer is driving. That way, when you say not alreadyVisible, you're inverting the value of the visibility state, correct? Which is the very first command that tells the system the boolean of the visibility? For example: If you constantly multiply a number by 1 and -1, alternating between them, you need to have a first number so you know the ending result. Otherwise, you'll never figure if the ending result is positive or negative x * 1 = x ---> x * -1 = -x ---> x * 1 = x ---> x * -1 = -x But if I tell you that x = 2, you'll know the ending result. Taking this concept to this script, how does the system figure out the initial state of the dummy?
  19. I made this: -- All other functions and GUI creation. -- [...] -- Created button called "fbumper". local function setFBumper() local theVeh7 = getPedOccupiedVehicle(localPlayer) if theVeh7 then setVehicleComponentVisible(theVeh7, "bump_front_dummy", false) end end addEventHandler("onClientGUIClick", fbumper, setFBumper, false) -- Everything else... It works. Then I wanted to have the button switch between true to false when clicked. Something like: local function setFBumper() local theVeh7 = getPedOccupiedVehicle(localPlayer) if theVeh7 then setVehicleComponentVisible(theVeh7, "bump_front_dummy", false) elseif getVehicleComponentVisible(theVeh7) == "false" then setVehicleComponentVisible(theVeh7, "bump_front_dummy", true) end end addEventHandler("onClientGUIClick", fbumper, setFBumper, false) guiSetVisible (vehmod, false) It doesn't work correctly. It sets it invisible, but it doesn't return the state to visible. I also thought about using the setVehicleComponentVisible (not setVehicleComponentVisible) to make it a little bit more compact. I'm using a setEngineState script to help myself, but I don't know how to use it with these arguments. DB 3 throws nothing. What am I doing wrong?
  20. I decided to dive into the complex system of the freeroam GUI MTA brings by default. After making it a standalone resource, I began changing a few things. I noticed a few particularities that I wanted to understand. As the first particularity, I noticed that the bottons do not have a fixed position. They change its position and size depending on the position and size of the other bottons, as well as the length of the text inside. They follow the same order as the text: left to right first, then top to botton. I wanted to add a new button to change the walking style, but I'm having trouble finding the specific part where the buttons are created and told to behave as mentioned above (so I can recreate the same thing myself) Inside the resource, there is a 'data' folder that manages the lists of the elements the player can choose with several .xml files: weapons, vehicles, skins, etc. I could create a similar list, but I don't know how to tell the .Lua to call a list from a different file. I'm not sure how this resource is creating all the elements of the GUI; I'm used to a different style (I use 'guieditor' to create GUIs). I still need to do some research. But in the mean time, what do I need to create a button that remotely calls of a .xml list with walking styles?
  21. I'm aware it should throw some kind of string result about some player. But nothing's happening. DB 3 is not throwing any errors. Out of context: It's funny how some of my replies have quotes of things I supposedly said.
  22. I'm certian my issue is that I'm not understanding what goes inside parentheses in the function header. Sometimes it's empty, other it's filled with arguments. This is what leaves me absolutely clueless and confused. I thought that the parentheses had to have the same arguments as the handler, which in this case is: addCommandHandler ( string commandName, function handlerFunction [, bool restricted = false, bool caseSensitive = true ] ) -- That turns into: addCommandHandler ( "cleana", Warning1 [, bool restricted = false, bool caseSensitive = true ] ) Which would leave us with a header similar to: function Warning1 (string commandName, function handlerFunction [, bool restricted = false, bool caseSensitive = true ] )) -- That turns into: function Warning1 ("cleana", Warning1 [, bool restricted = false, bool caseSensitive = true ] )) And that it serves as the same as stating the values beforehand: command = "cleana" function Warning1 (command) -- The function -- end addCommandHandler (command, Warning1) And finally, supposing that my thought process is correct, why would I need to clarify 'p' if 'p' is already being clarified in local acc = getPlayerAccount (p)? I'm struggling a bit putting these doubts into words. If you don't understand, let me know and I'll try to explain myself better. I've seen DB 3 throw a "got boolean" at the end of the error. I noticed you mentioned "false". Does this mean that everytime DB 3 talks about boolean, it's talking about a false statement? I ask this because I learned that boolean can either be 'true' or 'false'.
  23. I can't believe it was that easy. It works now! How did you detect it between so many things in the script? The knowledge I had seems to be incorrect. I thought that the arguments inside the parentheses next to the function name (header) didn't have an important effect, other than to set the names of the arguments. I had imagined that leaving it blank would be the same as saying "anything can go there". So why was it stopping the script from workingç?
  24. I've got this: I made the timers and the chatbox warnings: function Warning1() outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: #FF0000Todos los vehículos explotados y vacíos serán removidos en 30 segundos.", getRootElement(), 0, 0, 0, true) setTimer(function () outputChatBox("#D2691E[#FF7F50INFO#D2691E]#FFFFFF: #FF0000Todos los vehículos explotados y vacíos serán removidos en 5 segundos.", getRootElement(), 0, 0, 0, true) setTimer(loopVehicles, 5000, 1) end, 25000, 1) end Translation: 1. "All blown and empty vehicles will be removed in 30s". 2. "All blown and empty vehicles will be removed in 5s". The 2nd message waits 25 seconds before appearing, and then it should trigger the 'loopVehicles' function. So I thought that by replacing the <loopVehicles> in the timer above with the entire fuction, I'd get the desired script: In other words, I've got a cleaning function that happens 5 seconds after an output chatbot that happens 25 seconds after the command is entered. I've got: - Bad argument at line 6 ('local acc = getPlayerAccount (p)'). Expected element at argument 1, got nil. - Bad argument at line 7 ('if not isGuestAccount (acc) and [...] then'). Expected element at argument 1, got boolean. - Bad argument at line 7 ('("user."..getAccountName (acc), aclGetGroup ( "Admin" )'). Expected element at argument 1, got boolean. - Line 7: attempted to concatenate a boolean value. Those errors are thrown as soon as the 30 seconds pass (25 + 5 from both warnings). The warnings are visible. I pictured that if the warnings work and the cleaning script works, joining them as such would work. Why am I getting those errors?
×
×
  • Create New...