Jump to content

IIYAMA

Moderators
  • Posts

    6,058
  • Joined

  • Last visited

  • Days Won

    208

Everything posted by IIYAMA

  1. Cold you explain to me, for which user interfaces/layout that method works well? I can understand that in case of text+box or gridlayout you want to give it a bit more space, but for a button would you use the X axis as well or rather the scaling method? (Both from that topic)
  2. IIYAMA

    marker bug

    Yes, understood. So use the solution I gave you for now.
  3. For those who haven't seen it yet. There is since yesterday a tutorial available about scaling DX components on the tutorial section.

     

     

    This tutorial can also be user for other types of user interfaces, like the MTA GUI or DX libraries.

     

     

  4. IIYAMA

    marker bug

    Use this function to check if the marker is visible to the player: https://wiki.multitheftauto.com/wiki/IsElementVisibleTo But why the marker hit event is still triggering in the first place, is even a mystery to me. Note: this is the tutorial section.
  5. [TUT] Scaling DX The reason why I am creating this topic, is because there are a lot of people asking this question: And to be honest there is no best practice for. But here you have my recommendation as guidance for display them the ~s~a~m~e~ for all screen formats. There are two important factors while dealing with screen formats 1. Pixel density Indication: PPI(Pixels Per Inch) and some also use the term DPI(Dots Per Inch) They do not have to be the same while talking about printing stuff. This indication tells us about how many pixels are used per inch. Which more or less tells us how sharp/smooth things like text can be looking. PPI doesn't really play a big role, but to display something nicely you need enough pixels to display it. Else it will be either too small or too crispy. So be careful to not scale things (especially text) too small. 2. Display aspect ratio Wiki The difference between resolution X and resolution Y as a ratio. A list of common ratios: 4:3 5:4 3:2 16:10 16:9 So for example if we take: fHD: 1920x1080 Which has the ratio 16:9 that is calculated like this: 1920 / 16 = 120 120 * 9 = 1080 Scaling without ratio Before I am going to explain any of this, I am going to ask you an important question: Like this: (vertical) ▮ Or horizontal? ▅ I assume most people would agree to play MTA horizontal, else you are probably reading a book or document. p.s If you play MTA on a vertical screen, then we developers do not like you at all, sorry. So what does this tell us? You can assume that the X-resolution is never going to be smaller than the Y-resolution. Useful? You will figure it out. Doing the scaling Note: This part is ABOUT SCALING and not positioning. So what we are going to do is: Calculating a scale which can display the same DX on multiple screen formats > without messing with the ratio. Example: A computer runs MTA at a resolution of 1920 x 1080. Lets define that! local devScreenX = 1920 local devScreenY = 1080 If this code is used by a different pc, we also need to know on which resolution it is running: local screenX, screenY = guiGetScreenSize() For the next step we have to look at this screenshot: I have cut out of the wide-screen format a square. Squares have the ratio 1:1, which means that we have removed our ratio difference from this screen resolution. It is very easy to do, as our Y * Y resolution makes exactly that beautiful square! The next thing we have to do is creating our scaling value. This value is required for adjust our resolution values so that they match to every screen format. So to use our ratio 1:1, we use the Y resolution to achieve that: local scaleValue = screenY / devScreenY And as last we can create a rectangle shape that is displayed at the center of every screen format, perfectly! local devScreenX = 1920 local devScreenY = 1080 local screenX, screenY = guiGetScreenSize() local scaleValue = screenY / devScreenY addEventHandler("onClientRender", root, function () -- create a scaled size local sizeX = scaleValue * 300 -- 300px local sizeY = scaleValue * 50 -- 50px -- get the center of the screen local centerX = screenX / 2 local centerY = screenY / 2 -- calculate the starting point of the rectangle local startRectangleX = centerX - (sizeX / 2) local startRectangleY = centerY - (sizeY / 2) dxDrawRectangle ( startRectangleX, startRectangleY, sizeX, sizeY, tocolor ( 255, 255, 255, 255 ) ) end) Lower limit What if we have a resolution of 800x600? And the text is getting too small? Making sure that the pixel density is OK, is very important. So to counter that we have to make sure that the text is not getting too small. Our development Y resolution is 1080 pixels. And we are dealing with an Y resolution 600 pixels. The first thing we are going to look at, is what the scale is going to be at that point. 600 / 1080 = 0.55555555555555555555555555555556 It is not very nice to have your text scaled to 55.5% of the original size, when having low resolution already. But without scaling, the DX stuff might fill up the entire screen and that is just as bad. So what we now need is a limit, in this case a lower limit. scaleValue = math.max(scaleValue, 0.65) The math.max function returns the highest value of all the arguments you put in to it. In this case it contains the: scaleValue: 0.555 And the lower limit of: 0.65 This will make sure that the DX stuff is not getting smaller than 65%. This might make text read able for a 800x600 resolution. Positioning Do you want to place your dx-effects at a specific place on your screen? See the following useful function: https://wiki.multitheftauto.com/wiki/GetScreenStartPositionFromBox
  6. How about you scale over the Y axis only? That solved all my problems. Because in most cases scaling shouldn't include the ration, but the pixel density only. (With some exceptions)
  7. IIYAMA

    question

    Those sites do not provide an API. You need that to not receiver their website junk. Instead you want clean JSON or XML! Search on Google for: free timezone api And pick the one that works best for you.
  8. Confusing Did you use this function perhaps? https://wiki.multitheftauto.com/wiki/DxSetAspectRatioAdjustmentEnabled Or did you not refresh the resource properly? Is the box at the right position? dxDrawRectangle (MiniMap_x, MiniMap_y, MiniMap["width"], MiniMap["height"]) Does the rendertarget actually capture the blips? (disable line 28 temporary) Where are the blips now located when the rendertarget doesn't capture?
  9. I do not know what you are doing or have done.
  10. Render them at the top + left corner instead of the bottom + left corner. That shouldn't be a problem, it is your code after all.
  11. The rendertarget will capture the image from the LEFT + TOP corner of the screen. As it is now, it will not be recorded within the rendertarget.
  12. addBlip(52, -1940.97986, 568.07715, "Bank", tocolor(255,255,255,255)) * Where on your screen? * local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY))
  13. IIYAMA

    [Help] Camera

    By editing the offset values of this function: https://wiki.multitheftauto.com/wiki/AttachElements
  14. IIYAMA

    [Help] Camera

    see this example with vehicle: https://wiki.multitheftauto.com/wiki/GetCamera
  15. Using a variable in this case might boost a very little performance. But not in a way that it will matter too much. A case where it will actually have a significant effect: local table = {value = 12000} -- onClientRender local value = table.value dxDrawText(value) dxDrawText(value) -- boost ! These steps will be reduced to 1x instead of 2x. (1. Using the table reference to find the table object. Not sure if this actually takes more time than a numeric value.) 2. Searching in the table. Which takes time.
  16. for i = 1, #playerTable.player.savedcols do local saved_col = playerTable.player.savedcols[i] if saved_col == playerTable.player.colshape then -- finding it playerTable.player.colshape = playerTable.player.savedcols[(i + 1) <= #playerTable.player.savedcols and (i + 1) or 1] -- set new col break end end I still not understand why you use the ~= operator. So I left that one out for now. This code will search for the actual col. Trigger: Matching Action: move to the next one. @majqq
  17. Do you mean moving the first colshape to last position in the table? And cycle that. Or do you mean going over the index from any given index: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 2, 3, etc. Or start cycle the index at the point where they match? 1, 2, 3, 4 = matching, 5, 6, 7, 8 ,9 10 Starting the cycle at index 4. 5, 6, 7, 8, 9, 10, 1, 2, 3 (stop)
  18. Then it would be fine.
  19. IIYAMA

    Script Problem

    @iRack I do not recommend posting ripped stuff, the owner might get mad at you. Just saying. local l_11_1, l_11_2, l_11_3 = getElementPosition(l_11_0)
  20. @majqq hmm I just wondering how your code works. Shouldn't this make more sense? -- loop with problem local insertCol = true for i = 1, #playerTable.player.savedcols do local saved_col = playerTable.player.savedcols[i] if saved_col == colshape then outputChatBox("saved_col == colshape, break") insertCol = false break -- uhm, should break and not add colshape to table? end end if insertCol then table.insert(playerTable.player.savedcols, colshape) -- in case of any questions, i tried to add condition here but that doesn't help end
  21. Because the addEventHandler + "onClientRender" will use more memory than a timer. Unless you have already attached an addEventHandler . Then it is more or less two function call's every frame vs a timer.
  22. Not possible unless you are actually running gta san on your server. Which I am not sure if virtual machines go that far. You are still missing that gpu after all. An extra home pc maybe? Which you can control with the server.
  23. 1 active timer = setTimer 1 active timer + dx countdown = getTickCount 500+ active timers = (getTickCount or 1 global setTimer ) passive timers = getTickCount It depends on the quantity, precision and the functionality you want to use next to it. And yes with onClientRender you have to mind reducing the check amount. I can send you an example how I build my global lua timer, if you want.
  24. The else statement does not help?
  25. The keyword break does not stop the code block from executing. It only stops the next loops.
×
×
  • Create New...