Jump to content

IIYAMA

Moderators
  • Posts

    6,058
  • Joined

  • Last visited

  • Days Won

    208

Everything posted by IIYAMA

  1. I am not exactly sure what the raw mathematics are . But you can use for your first iteration this function: local screenPosX, screenPosY = getScreenFromWorldPosition ( x, y, z, 10, true ) if screenPosX and screenPosY then end It will flatten the complex 3D orientation and therefore allows you to calculate the rotation: https://wiki.multitheftauto.com/wiki/FindRotation
  2. Did you assign an ID to the object? Afaik you to add (manually) id's with setElementID.
  3. Nope, just the way you are doing it in your example. A flat structure, because each complexity in the structure will make it more complicated to save. You can later add a next layer on top of your table, to improve searching performance, if you so desire. Finding your item? Do it how a human would do, check every item in the list until you find the right one and stop searching.
  4. Options: A. use the command: /refreshall B. Empty your client cache MTA San Andreas X\mods\deathmatch\resources Source:
  5. hmm, it is kind of a strange error. Since freeroam doesn't request the files from the path /data/ rows={xml='stats.xml', attrs={'name', 'id'}}, File fr_client.Lua. Line 461 This error is showing when starting freeroam or always?
  6. Those files are located in: \[gameplay]\freeroam Try to unzip the resource (and delete the zip)
  7. IIYAMA

    [HELP]

    See example below this function: https://wiki.multitheftauto.com/wiki/DxDrawCircle
  8. @anlaltnay Download the latest freeroam resource from: (after downloading, located in [gameplay]) https://github.com/multitheftauto/mtasa-resources
  9. You can use the addCommandHandler. addCommandHandler ( "givemoney", function (responsibleElement, commandName, teamName, money) iprint("givemoney command used") if responsibleElement and getElementType(responsibleElement) == "console" then iprint("the one used the command is the console") money = tonumber(money) if teamName and money then iprint("parameters are valid!") -- do your stuff end end end)
  10. In most cases not. It does indeed reduce memory, but that only matters when the variable contains a lot of data. For example: A variable that contains a table reference with > 1000 items. Cleaning this data will not boost your performance directly, it will only allow your users to use less HDD memory when they do not have enough ram installed. Which will indirect result in improving the performance. People with 4 gb ram installed on a windows 10 computer, that is segment you are helping.
  11. You might be able to test that. Initial Put yourself or the vehicle you want to test in the air. Gravity to 0. Speed to 0. Start Write down the velocity for every frame. Set the default gravity and test how the speed is changing for the first few frames. Note: keep in mind that vehicles also have their own mass.
  12. Note: you can also apply the matrix of the ped to the projectile. It might not have the correct rotation in the beginning, but you can correct that. setElementMatrix
  13. Here some code snippets I ripped out of one of my scripts. The code was used to calculate the new projectile position based on frame time. This would terminate different projectile speeds based on FPS. -- add function findRotation local findRotation = function ( x1, y1, x2, y2 ) local t = -math.deg( math.atan2( x2 - x1, y2 - y1 ) ) return t < 0 and t + 360 or t end -- add function findPitch local findPitch = function (camerax,cameray,cameraz,pointx,pointy,pointz) local dX=camerax-pointx local dY=cameraz-pointz local dZ=cameray-pointy local pitch=math.atan2(dY,math.sqrt(math.pow(dZ,2) + math.pow(dX,2))); return pitch end local xr, yr, zr = getElementRotation(source, "ZXY") -- source is projectile -- xr, yr, zr is saved inside of projectileData.rotation local targetX, targetY, targetZ = getElementPosition(target) -- target is projectile local rotZ = findRotation(newX, newY, targetX, targetY) + 180 local pitch = findPitch(newX, newY, newZ, targetX, targetY, targetZ) local rotX = pitch*(180/math.pi) local newRotX = projectileData.rotation.x local newRotZ = projectileData.rotation.z local rotationDistanceX = (projectileData.rotation.x - rotX + 360) % 360; if (rotationDistanceX > 180) then rotationDistanceX = 360 - rotationDistanceX newRotX = newRotX + math.min(rotationDistanceX, behaviourData.rotationSpeed * speedMultiplier) else newRotX = newRotX + -math.min(rotationDistanceX, behaviourData.rotationSpeed * speedMultiplier) end local rotationDistanceZ = (projectileData.rotation.z - rotZ + 360) % 360; if (rotationDistanceZ > 180) then rotationDistanceZ = 360 - rotationDistanceZ newRotZ = newRotZ + math.min(rotationDistanceZ, behaviourData.rotationSpeed * speedMultiplier) else newRotZ = newRotZ + -math.min(rotationDistanceZ, behaviourData.rotationSpeed * speedMultiplier) end projectileData.rotation.x = newRotX projectileData.rotation.z = newRotZ local rotationZ = -projectileData.rotation.z if creatorVehicle then -- if the projectile creator was a vehicle, then add 180 to invert the rotation. rotationZ = rotationZ + 180 end setElementRotation(element, projectileData.rotation.x, projectileData.rotation.y, rotationZ, "ZXY")
  14. A local function is just the function value saved inside of a local variable. Like this (a local available before the function is defined): local test function test () end or this (a global, as well as a local after the local keyword): function test () end local test = test or this: (a local variable, available after the function) local test = function () end or this: (a local variable, available in and after the function) local function test() end So when do you need to use it? The same way as just a regular local variable. Variables that are accessed a lot of time. (onClientRender) Variables that are only available within it's scope. Variables that are temporary required. etc.
  15. @VaporZ Stop moving, you can easily ask that question here. Now you are just pushing other people their topics down, that deserve the same attention as yours.
  16. Nope, there are other methods, like checking if rectangles are colliding. But if you use 2, it doesn't mean it is more difficult. Infact it is a lot easier to create a computed version of your grid. It tells you exactly which cells are being used and you can throw it away when you do not need it any more. An item ID, which is the one of the item you want to move. This value is an integer, the first column located in your db table.
  17. Double id's are not allowed. Your database will never generate the same ID, if the column is correct set-up. If you move the item on top of the same item, it should consider those cells as empty. isSlotFree(x, y, w, h [[, ignoreID int ]]) The checking box is the computed version of the grid, where each cell has data applied. (Unlike just the start position)
  18. I do not know the best algorithm. But what you can do for now: - First get all open spaces. - Get the size of the item you want to place. Example: 3x2 - Go through each open space - Make a checking box, starting from the left-top corner. Left-top corner: XOOOOOO OOOOOOO OOOOOOO Checking box: XXXOOOO XXXOOOO OOOOOOO Next item: 3x3 XXXXOOO XXXOOOO OOOOOOO --- XXXXXXO XXXXXXO OOOXXXO This is just a way. I am sure you can optimise it in a way. For example items that start at a position that is going to be out of the box because of the width and height. 3X3 Is never going to fit here: (start point) OOOOOOO OOOOOOO OOOOOOO
  19. I have done this before, but think I would go for 2 grids. Every item has a startX, startY, width and height. Grid 1: contains only the start position of the added items. (Which is saved) Grid 2: A computed version of grid 1, where it is for each cell know which item is placed on it. This makes it easier to see if there is space. (unsaved) local grid1 = { { -- column / X1 { -- cell / Y1 width = 2, height = 3, type = "drink", name = "bottle", id = 1 }, nil, -- cell / Y2 nil, -- cell / Y3 nil, -- cell / Y4 { -- cell / Y5 width = 4, height = 3, type = "ammo", name = "bullets ...", id = 2 } }, nil, -- column / X2 { -- column / X3 { -- cell / Y1 width = 1, height = 1, type = "matches", name = "matches", id = 3 } } } Don't program it like this, this is how the computed version would looks like. (With only the bottle) local grid2 = { { -- column grid1[1][1], grid1[1][1], grid1[1][1] }, { -- column grid1[1][1], grid1[1][1], grid1[1][1] } } So if you want to place an item at: X2, Y3 print(grid2[2][3]) You would find the the bottle table. Therefore there is no space. Demo: https://www.Lua.org/cgi-bin/demo
  20. You are now loading the fish script 2x. 1 version serverside and 1 version clientside. That is not going to work. You need to separate those sides. So: 1 script/file serverside, with serverside code. (Running in the server application) 1 script/file clientside, with clientside code. (Running on each player his computer in the MTA game itself)
  21. Yes, your script is passing over arguments that are used within the rgbOpenPicker as parameters. In: rgbOpenPicker("left", "up") Out: function rgbClosePicker(button, state) --[[ ... ]] iprint(button) -- outputs "left" iprint(state) -- outputs "up" --[[ ... ]] For you the definition of an effect is apparently: Everything works fine! Which is for me not really useful, if it is positive, it only means that I do not have to help you any more. The effects that are relevant for me are: Are there errors/warnings from this script? Is this, this, this and this code executed? Are the values of a variable correct? And how would I get that relevant information? That is where you come in! So please help me too. Debug the code for me!
×
×
  • Create New...