Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 28/02/21 in all areas

  1. [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
    1 point
  2. I'm excited to show you my latest tool. This time it is something different than my previous tools. It is a bigger project which came to my mind over 2 years ago. I failed at first time because I had trouble with rotations (built in mta function doesn't work well so I had to use quaternions which caused problems as well). Moreover one of devs was working on new editor and he was going to add multi selection option but he cancelled the project. After 2 years I decided to finally write it and also add few additional features. Many hours spent on the tool, thousands lines of code but here is it. I hope you like it and find it useful. Personally I think it should speed up your mapping a lot. Few features might look complicated (actually they are easy to use) so I advice watching or reading tutorial carefully. Features Let's see what this tool is capable of! Create groups of elements using various selection tools and element filters a. edit their position and rotation around all axes b. change their properties - all popular element types are supported c. clone / delete options d. large group support enables you to move / edit whole parts or even maps Duplicate 2 groups Change pivot position Add groups to library a. browser with search and sort options b. loading big groups enables you to join many maps into 1 c. import option which adds all MSTU groups from a given map Cover groups a. create your own cover variations or object compositions b. default cover settings makes covering even faster Customize tool settings on your own needs Download More info and full tutorial you will find here: https://www.thecrewgaming.com/forum/showthread.php?tid=2467&pid=12255#pid12255 Support me If you want to support me leave feedback and also you can buy me a coffee so I won't starving. Thanks a lot! Buy Coffee Feel free to ask questions below or via PM/discord. I'm also opened for script requests. I will keep updating the tool in case you find some bugs. Discord: https://discordapp.com/invite/C4TRxr8
    1 point
  3. Ok, servicing sounds like a good idea. It seems there is something off but I cannot point to the problem with my low knowledge. For example tasklist errored and returned no tasks, which is not normal.
    1 point
  4. I can't look if the code work
    1 point
  5. try adding debug lines such as outputChatBox(tostring(getElementData(ped, "status"))) sometimes things gets clog up in such old and complex scripts
    1 point
×
×
  • Create New...