Dzsozi (h03)

  • Content Count

  • Joined

  • Last visited

  • Days Won


Dzsozi (h03) last won the day on December 25 2017

Dzsozi (h03) had the most liked content!

Community Reputation

71 Popular

About Dzsozi (h03)

  • Rank


  • Location

Recent Profile Visitors

4,391 profile views
  1. So no matter what, I will have to use at least 2 tables for the item positions? Btw sorry for the lots of questions, I’ve never created or worked with inventory systems by myself. Also, what should be the value of the ignoreID variable in this case?
  2. I came to the conclusion that I can basically use one table for the item list which holds the currently opened inventory’s items and the indexes of this table represent the items’ position, like this itemTable = { {name = "item1", size = {1, 1}}, -- 1 {name = "item2", size = {1, 3}}, -- 2 } ------------------ -- this should be the temporary item table which I don't save, because it is for drawing the items of an opened inventory(?) inventoryItems = { -- [x position/column] = {[y position/row] = {itemData}}, [2] = { [3] = {itemID = 1, value = 100}, }, } So in my mind I could use this for checking positions and use an utility function like isSlotFree(x, y, w, h) which would be similar to isMouseInPosition, that checks if the given variables match the item positions from the inventoryItems table, then if they are matching just return false. But then this raises another question for me, how can I change the index of a specified item, especially if there are 2 items of the same id, or what would be a way to identify items seperately? Sorry I got a little bit confused with this ”checking box” thing. Also these things are only in my head right now, but today when I get home I will start working on it based on the things and ideas in this topic and will see if this all is a good approach, but correct me please if there is something wrong with my “theories”.
  3. So based on this logic I assume that I should make utility functions like isSlotFree(x, y) and then check the indexes inside the table, then if an index is same as the given variable it should return false, am I correct? Then use this function to check movent of an item by player to a hovered slot. But when beginning the calculation and adding a new item, how do I set it’s first position if there are already items in the inventory, but lets say there is just enough space at the bottom of the inventory? What should be the criteria or logic behind checking for free positions anywhere inside an opened inventory?
  4. Hello MTA community! I would like to make an inventory system, which has different sized items (1*1, 2*1, 1*3, etc.), so the inventory space would matter based only on your space management. Here are some example photos of what I mean: I haven’t started coding yet, that is the reason I created this topic. First of all I am trying to put together a structure and I would like to hear your opinions and suggestions on how to make this type of inventory. I have some main questions but please let me know anything you think I might have to know regarding this topic. My main questions are: - How should I do the calculations for item positioning? (I would like players to be able to move the items within an inventory, that’s for sure) - Do I calculate a freshly added items’ position inside the dx drawing function? Or should I specify the new items’ position at the point when I give it to the player? - I would like to make it as simple, as efficient and as “automatic” as possible, so if it is an option, when I give an item to an element inventory I would like to only specify the element, item and item value variable. - Where or how should I store the items’ position or how can I return the position and other data of an item when clicking on a slot? Do I make a variable for each slot representing it’s space (true if free/false if taken)? Do I save the currently visible inventory’s content with item data inside a table on client side? - I would like to make inventories for vehicles peds and objects as well with a function, something like createInventory(element, slotNumber) for example. Should I make a new element for that using createElement or is there any other way to do that? As I mentioned above, right now I am putting together a plan about how I would like to start working on this inventory resource, so please let me know anything useful!
  5. These videos in this topic show a much more different system from what is currently done. Soon when I fix most of the known bugs and be ready with unfinished systems, I will be uploading a new video about it.
  6. 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)
  7. 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!
  8. 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!
  9. 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.
  10. 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.
  11. 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!
  12. I think you could achieve something really similar to that single player feature by combining these functions: createProjectile setElementAlpha createObject setElementCollisionsEnabled attachElements
  13. 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!
  14. addEvent("", false) addEventHandler("", 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.