Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/05/21 in all areas

  1. Of course this code doesn't handle 4:3 resolutions like 800x600, and HUDs will be stretched. You can find solution for that in the tutorial what srslyyyy linked above.
    1 point
  2. -- Okay, so you have to pick a base resolution, you should choose what you use. local baseWidth, baseHeight = 1920, 1080 -- I pick fullhd -- We'll need the current resolution local screenWidth, screenHeight = guiGetScreenSize() -- imageine this is 1366x768 now -- and now we have to calculate the difference ratio between the base- and current resolution local xDiffRatio, yDiffRatio = screenWidth/baseWidth, screenHeight/baseHeight -- this will be: (1920/1366=1.40556) and (1080/768=1.40625) -- then we have to multiply every (X-coordinate and Width with 'xDiffRatio') and every (Y-coordinate and Height with 'yDiffRatio') -> this will resize everything (ofcourse if base- and current resolution is equals, then it doesn't change) -- now draw the image local imageX, imageY = 1645, 500 local imageWidth, imageHeight = 64, 64 -- miltiply values with the right ratio dxDrawImage(imageX*xDiffRatio, imageY*yDiffRatio, imageWidth*xDiffRatio, imageHeight*yDiffRatio, "images/hud/adm_on.png") -- NOTE: you can make your life easier if you create a "custom" dxDrawImage event what do the math for you, call it 'myDrawImage' function myDrawImage(x, y, width, height, ...) -- three dot means (...) every parameter after 4th, this is a "magic parameter" dxDrawImage(x*xDiffRatio, y*yDiffRatio, width*xDiffRatio, height*yDiffRatio, ...) -- and don't forget the dots end -- and now you can use your new function myDrawImage(imageX, imageY, imageWidth, imageHeight, "images/hud/adm_on.png")
    1 point
  3. You need to get the screen resolution with guiGetScreenSize and use it to calculate the coordinates for that resolution. That page has examples for this particular purpose.
    1 point
  4. I think adminduty variable doesn't defined. Probably you wanted to use getElementData in IF statements. addEventHandler("onClientClick", root, function(button, state, clickX, clickY) if button == "left" and state == "up" then -- clicking with left button AND check only release if isClickingInsideArea(clickX, clickY, ax+5,ay+500,32,32) and exports.integration:isPlayerStaff(localPlayer) then -- check is click coordinates inside images zone? | AND player is staff if getElementData(localPlayer, 'duty_admin') == 0 then triggerEvent("accounts:settings:updateAccountSettings", localPlayer, "duty_admin", 1) setElementData(localPlayer, 'duty_admin', 1) elseif getElementData(localPlayer, 'duty_admin') == 1 then triggerEvent('accounts:settings:updateAccountSettings', localPlayer, 'duty_admin', 0) setElementData(localPlayer, 'duty_admin', 0) end end end end)
    1 point
  5. Mudei para server-side e funcionou perfeitamente. Obrigado pela ajuda e desculpe a falta de conhecimento, estou iniciando agora.
    1 point
  6. Here are some excellent resources to learn the basics of Lua scripting: - https://wiki.multitheftauto.com/wiki/Main_Page - https://wiki.multitheftauto.com/wiki/Scripting_Introduction - https://www.lua.org/manual/5.1/ - https://wiki.multitheftauto.com/wiki/Category:Tutorials - https://forum.multitheftauto.com/topic/34453-manuals - https://forum.multitheftauto.com/topic/64228-the-ultimate-lua-tutorial/ - https://forum.multitheftauto.com/topic/121619-lua-for-absolute-beginners - https://forum.multitheftauto.com/topic/95654-tut-debugging/ - https://forum.multitheftauto.com/topic/114541-tut-events/ - https://forum.multitheftauto.com/topic/117472-tut-scaling-dx/ - https://forum.multitheftauto.com/topic/130181-lua-tables-as-sets-instead-of-arrays/ Videos: https://www.youtube.com/watch?v=Goqj5knKLQM&list=PLY2OlbN3OoCgTGO7kzQfIKPj4tJbYOgSR
    1 point
  7. Thank you so much, i love this forum already. On youtube there aren`t that many tutorials and i`m trying to learn how to script 3-4 hours a day. Now i got a source that will make this process much easier. Appreciate it have a nice day dude!
    1 point
  8. Welcome! You have to use onClientClick event. This event triggers whenever the user clicks his mouse. All you have to do is check player clicking "over" the image, you get the coordinates from parameters. Something like that: local imageX, imageY = 500, 500 local imageWidth, imageHeight = 200, 100 addEventHandler("onClientClick", root, function(button, state, clickX, clickY) if button == "left" and state == "up" then -- clicking with left button AND check only release if isClickingInsideArea(clickX, clickY, imageX, imageY, imageWidth, imageHeight) then -- check is click coordinates inside image's zone? outputChatBox("Clicking inside of zone :)") else outputChatBox("Clicking outside of zone :(") end end end) function isClickingInsideArea(clickX, clickY, boxX, boxY, boxWidth, boxHeight) -- check is 'clickX and clickY' inside the image's zone (boxX, boxY, boxWidth, boxHeight)? -- returns 'true' if inside, false otherwise return (clickX >= boxX and clickX <= boxX + boxWidth ) and (clickY >= boxY and clickY <= boxY + boxHeight ) end
    1 point
  9. Olá. É realmente necessário utilizar o client-side para isso? Server-side ficaria melhor. Mas enfim, esse evento do client-side recebe dois argumentos, o primeiro é o player, que você já o usa, e o segundo é o assento em que o jogador entrou. Basta verificá-lo. Aquele FOR ali não faz sentido.
    1 point
  10. If you want to know that, then I recommend to take a closer look at the community resources (inspiration). https://community.multitheftauto.com/index.php?p=resources&s=list&name=&descr=inventory&category=
    1 point
×
×
  • Create New...