Jump to content

Dzsozi (h03)

Members
  • Posts

    682
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Dzsozi (h03)

  1. https://community.multitheftauto.com/index.php?p=resources&s=details&id=15679 With this resource you are able to get/modify the position of a vehicle's cargo space. The position you get is the middle of for example a Bobcat's bed, so if you want to add lots of objects you will have to use some loops for positioning. Look at the exampleS.Lua in the resource. local function testFunction2() local vehicleObject if not isElement(vehicleObject) then local cargoPos = exports["vehiclecargo"]:getVehicleCargoPlacementPosition(source) if cargoPos then local x, y, z = getPositionFromElementOffset(source,cargoPos.x, cargoPos.y, cargoPos.z+0.285) local vehicleObject = createObject(1271, x, y, z, 0, 0, 0) setElementCollisionsEnabled(vehicleObject, false) setObjectScale(vehicleObject, 1.5) attachElements(vehicleObject, source, cargoPos.x, cargoPos.y, cargoPos.z+0.285) -- +value on Z because of the object scaling so the object doesn't collide with the vehicle addEventHandler("onVehicleExit", source, function() if isElement(vehicleObject) then destroyElement(vehicleObject) vehicleObject = nil end end ) end end end addEventHandler("onVehicleEnter", root, testFunction2)
  2. Thank you! I had to change some things up a little bit to match my needs and get it done correctly, it's working now just as I wanted to!
  3. Hello! While I was improving a resource, I came across a small problem; I would like to get the correct value based on vehicle health. I have a table similar like this: ["somekey"] = { [75] = "somevar1", -- view it as health limits, so when the health is lower or between the current and the next, more lower number, then I can add a property to my vehicle [50] = "somevar2", [25] = "somevar3", }, What I want to do is if the health of the vehicle goes under 75 then return "somevar1", when it goes under 50 then return "somevar2" and when it goes under 25 then return "somevar3" and so on. Basically I would like to check if the vehicle's health is between the given indexes/limits and return the correct table value for it. I am guessing that I will need a custom range function but I don't know how to get started and how to select between the indexes depending on a given number when calling the function. I hope I was understandable and someone can help me out, I really need to get this work, please help!
  4. I think the problem is the way you are trying to get the matching model id. In my opinion this would be a much simpler solution for this problem: local vehicleModelIDs = { [596] = true, [523] = true, } addEventHandler ("onVehicleExit", getRootElement (), function (thePlayer) if vehicleModelIDs[getElementModel(source)] then local passenger = getVehicleOccupant (source, 1) if passenger then removePedFromVehicle(passenger) end end end ) This way adding and removing vehicle ids in the future will be easier. Let me know if it works or not.
  5. I just noticed I didn't even use the given rotations at this line; setElementRotation(fx, rx-(elementRX+90)-180, elementRY-ry+90, elementRZ-rz) -- what do i actually write here? but I changed up the variables so many times, nothing seemed to work, probably I copied the wrong version of the script while I was trying to achieve what I wanted.
  6. Hello! I am asking for your help in rotation calculations, I am struggling to get done what I want. I made a script to attach effects to vehicles, but I noticed a problem with some specific effects (for example the one called "petrolcan", which is the effect you get when your character is peeing). I attached this effect to the position of the wheel_rb_dummy and wheel_lb_dummy, now the problem is that when my vehicle turns the effects do not keep their offset rotations, they turn in wrong directions. Here's my current calculations: vehicleEffectData = { ["smoke"] = { ["wheel_lb_dummy"] = { ["petrolcan"] = {x = -0.1, y = 0.3, z = 0.3, rx = -270, ry = 0, density = 1}, }, ["wheel_rb_dummy"] = { ["petrolcan"] = {x = 0.1, y = 0.3, z = 0.3, rx = 270, ry = 0, density = 1}, }, }, } local attachedEffects = {} local vehicleEffects = {} function attachEffect(effect, element, pos, rot) attachedEffects[effect] = { effect = effect, element = element, pos = pos, rot = rot } addEventHandler("onClientElementDestroy", effect, function() attachedEffects[effect] = nil end) addEventHandler("onClientElementDestroy", element, function() attachedEffects[effect] = nil end) return true end addEventHandler("onClientPreRender", root, function() for fx, info in pairs(attachedEffects) do local rx, ry, rz = info.rot.x, info.rot.y, info.rot.z local elementRX, elementRY, elementRZ = getElementRotation(info.element) local x, y, z = getPositionFromElementOffset(info.element, info.pos.x, info.pos.y, info.pos.z) setElementPosition(fx, x, y, z) setElementRotation(fx, rx-(elementRX+90)-180, elementRY-ry+90, elementRZ-rz) end end ) -- inside script: attachEffect(vehicleEffects[vehicle][effect][partName][effectName], vehicle, Vector3(partX+effectData.x, partY+effectData.y/(seatToEngineDifference*2), partZ+effectData.z), Vector3(effectData.rx or 0, effectData.ry or 0, effectData.rz or 0)) Images of the current version: This is the rotation I want to always achieve when I set the rotation inside the table, but this only happens when I am facing this or -(this) direction: When I face north (the effects rotate as well and they turn inside): Please help me out with the calculations!
  7. I think you could achieve something really similar to that single player feature by combining these functions: createProjectile setElementAlpha createObject setElementCollisionsEnabled attachElements
  8. I still got the scripts, I might continue and finish this project finally, I just have to plan what I want to do exactly. If you have any suggestions or ideas let me know!
  9. addEvent("UI.click", false) addEventHandler("UI.click", resourceRoot, function (widget) if widget == ui.playersList then local items = exports.UI:getItems(ui.playersList) local selectedItem = exports.UI:getActiveItem(ui.playersList) Panel.showPlayerInfo(items[selectedItem].player) elseif widget == ui.CanelButton then Panel.hide() elseif widget == ui.SendButton then local reason = UI:getText(ui.reasonInput) if client:getData("money") < reason then exports.UI:showMessageBox("Error", "Недостаточно средств") else triggerServerEvent("SendMoney", localPlayer, Panel.showPlayerInfo(items[selectedItem].player), reason) Panel.hide() end end end) addEvent("SendMoney",true) addEventHandler("SendMoney", root, function(selectedPlayer, reason) if not isElement(selectedPlayer) then return false end if type(reason) ~= "number" then return false end if client:getData("money") < reason then return end if not exports.Core:givePlayerMoney(client, -reason) then return false end if isElement(selectedPlayer) then exports.Core:givePlayerMoney(selectedPlayer, reason) end end) Try this one.
  10. @MrTasty helped me with the following useful function: https://wiki.multitheftauto.com/wiki/WordWrap I also needed it for a notification system. This could be useful if you want to do multiple line dx texts, this function also supports color codes going from the 1st line to the 2nd.
  11. Why don't you just use bone attach and attach a phone object to the player's hand?
  12. Very helpful, lots of beginner modellers will be grateful for your effort that you put into this video!
  13. ****Sighs**** Okay so you are trying to tell me to look up the wiki and community and basically the whole internet to create a new shader file, that - as I can see I must write it down again - can handle the replace of 4 textures at the same time. What kind of modeller are you if you couldn't find the default CJ textures in the game files bro? You are 100% right! But what does that have to do with my problem, nothing? It's a fact that peds vehicles and objects are being made in a modeling program bro, no sh#t! Have you ever checked this function on the wiki https://wiki.multitheftauto.com/wiki/EngineApplyShaderToWorldTexture ? I quote: so by that you probably already figured out that I am using the correct texture names, just because your HD downloaded CJ mod doesn't have its files named the same (let me guess they are called player_torso, player_legs, etc), it doesn't mean I am using the wrong textures, since MTA handles those texture names in a different way as we can see, with some quick semi enthusiastic research you could find the answer easy bro. Why are you linking me the MTA community site, I don't even know, so let's not talk about that. Well, about countless shader examples, I wouldn't say they are countless. But they are not examples for me in this case. Like you said, yes, those are shaders, and this is what I use them for in this case as well. REPLACE TEXTURES, which means I edit the default texture, for example the torso and REPLACE it with a shader. So what does modeling has to do with it, I still don't get it. I don't have to do any UV mapping nor any modeling, why would I? You yourself said that shaders are for applying a texture to an object ped or vehicle. Looks like you are not completely understanding how texture replacing works if you only edit the default texture(?) You can keep telling me to go on YouTube or MTA forum (well, in this case this is what I just did, and that's the reason for this topic being existent, so again, I don't understand you), but there's a reason I made this topic... Probably because I didn't find the proper help I need and I am hoping for someone to help me out, don't you think? I didn't create this topic because I was bored. So, from now on, please avoid telling me the same thing "over and over in different ways" bro. Because you are not helping me, you are just trying to prove me wrong, that I must go and learn from wiki and search up the whole internet for a solution to my problem. I just asked a simple question which is: HOW CAN I MAKE A SHADER THAT CAN HANDLE MULTIPLE TEXTURE REPLACES AT ONCE??? No modeling, no UV mapping, no Facebook or YouTube or Twitter search for help, just a simple question on MTA forum in a topic about shaders. You don't have to tell me that I am doing it wrong and must find a different way via modeling, (even if I already have my system ready, just willing to improve it) when you are the one who doesn't even know where to find the default game textures. And now, back to the main question again: HOW CAN I MAKE A SHADER THAT CAN HANDLE MULTIPLE TEXTURE REPLACES AT ONCE??? ???
  14. https://community.multitheftauto.com/index.php?p=resources&amp;s=details&amp;id=4413 https://community.multitheftauto.com/index.php?p=resources&amp;s=details&amp;id=6889
  15. Well, thanks for your help, that I way I could "just learn" HLSL shader programing and fix the problem on my own. Could you already please tell me what does the modeling has to do with my problem? Learn to do what in a modeling program? I don't even understand... I already made my system and it is working, I just want to improve it by minimizing the amount of shaders I use in my script and that's what I need help with, writing a new shader file that can handle multiple texture replacing.
  16. Yes, maybe it is not a big performance question at all, but it would be also easier to change the textures, I mean less lines in the script itself. For example not having to destroy all the shaders and such, just change the shader value. @Ren_712 Can you give me a helping hand regarding the question of this topic?
  17. Check if the player is in a vehicle and then set the vehicle’s position as well. local vehicle = getPedOccupiedVehicle(p) if vehicle then setElementPosition(vehicle, 0, 0, 5) end
  18. @Pirulax is right, it doesn't work, the feet texture is being put on every part of the character.
  19. I am not sure how I should use this with my code. I tried many ways of adding, substracting and calculating but it always happened that I got spawned outside the given area coordinates. This is my current script: spawnPositions = { ["Whetstone"] = {minPos = {-188.8860168457,267.83926391602}, maxPos = {-204.15943908691,251.66763305664}, z = 12.078125}, } function getRandomPositionInArea(minValue, maxValue) -- Be a number #1 local value1 = minValue local value2 = maxValue -- Be different! ;o local difference = (value1 - value2) -- Be positive! :D local positiveDifference = math.abs(difference) -- Be ra ndo m! local randomPositiveDifference = math.random(positiveDifference) local randomDifference if difference < 0 then -- Be negative :( randomDifference = -randomPositiveDifference else -- Stay positive! :DDDD randomDifference = randomPositiveDifference end -- Be famous print(value1+(randomDifference-value1)+value2) return value1+(randomDifference-value1)+value2 end function getRandomSpawnPoint(cityName) if spawnPositions[cityName] then local minX, minY = spawnPositions[cityName].minPos[1], spawnPositions[cityName].minPos[2] local maxX, maxY = spawnPositions[cityName].maxPos[1], spawnPositions[cityName].maxPos[2] local x, y = getRandomPositionInArea(minX, maxX), getRandomPositionInArea(minY, maxY) return x, y end end local cityName = "Whetstone" local x, y = getRandomSpawnPoint(cityName) setElementPosition(localPlayer, x, y, getGroundPosition(x, y, spawnPositions[cityName].z)+1)
  20. I would like to have random spawnpoints inside a given area. I have the positions for minimum and maximum positions, but for some reason I can't manage to get the script working properly. I am using math.random from min to max values, but sometimes I get spawned outside the area, it doesn't return the right values. How can I get it working properly, so I spawn only inside the given area? spawnPositions = { ["Los Santos"] = {minPos = {1127.3712158203,-1632.8560791016}, maxPos = {1139.2634277344,-1621.2121582031}, z = 18.610622406006}, ["Las Venturas"] = {minPos = {1460.0589599609,2615.3452148438}, maxPos = {1478.0885009766,2622.806640625}, z = 10.8203125}, ["San Fierro"] = {minPos = {-2253.4848632813,521.00201416016}, maxPos = {-2250.8369140625,544.48956298828}, z = 35.174301147461}, ["Tierra Robada"] = {minPos = {-2259.4995117188,2352.9875488281}, maxPos = {-2253.8283691406,2372.5617675781}, z = 4.9140625}, ["Bone County"] = {minPos = {-244.1667175293,1210.9313964844}, maxPos = {-214.33074951172,1223.3796386719}, z = 19.735198974609}, ["Red County"] = {minPos = {243.48251342773,-160.65313720703}, maxPos = {252.89712524414,-151.75907897949}, z = 1.5703220367432}, ["Flint County"] = {minPos = {19.591306686401,-2641.8295898438}, maxPos = {37.629207611084,-2632.4833984375}, z = 40.432315826416}, ["Whetstone"] = {minPos = {-2122.837890625,-2481.69921875}, maxPos = {-2118.30859375,-2466.0988769531}, z = 30.625}, } function getRandomSpawnPoint(cityName) if spawnPositions[cityName] then local realTime = getRealTime() math.randomseed(realTime.second + realTime.minute + realTime.hour) local minX, minY = spawnPositions[cityName].minPos[1], spawnPositions[cityName].minPos[2] local maxX, maxY = spawnPositions[cityName].maxPos[1], spawnPositions[cityName].maxPos[2] local x, y = math.random(minX, maxX), math.random(minY, maxY) return x, y end end I guess it is because of the negative values, how to do the calculations for math.random?
  21. That has nothing to do with my problem. My problem is that I don't know how to write the shader file properly to handle 4 textures that is being changed in the script.
  22. Link me the topic where I asked this question in a different way. If you are not trying to help then please avoid commenting.
×
×
  • Create New...