Jump to content

Patrick

Moderators
  • Posts

    1,140
  • Joined

  • Last visited

  • Days Won

    41

Everything posted by Patrick

  1. This is not how it works. Tables are not affect element visibility. Probably you did it on client-side, where everything created only for "localPlayer".
  2. Since it's not client side, you can't create it only for "localPlayer". The only thing what you can do to make visible only for "player" who used the command. You have to use createMarker's 10th parameter.
  3. Are you sure? I think it's always on top.
  4. No, you have to use createColPolygon. Here is an editor addon which makes polygon colshape creation easier: https://github.com/Yamsha75/polygons
  5. I don't understand completely how you are trying to do it, so I just wrote an example code. I hope it helps. local screenWidth, screenHeight = guiGetScreenSize() local tooltips = { "adminonduty", "random1", "random2", "random3" } -- list with tooptips, I just define it here, you can mess with inserts local firstX, firstY = screenWidth/2-40, screenHeight/2-(#tooltips*50/2) -- position of first tooltip -- you have to split it up 2 parts, for drawing and checking -- drawing part addEventHandler("onClientRender", root, function() local offset = 0 -- position offset between tooltips, ofc this is 0 by default for i = 1, #tooltips do local tooltip = tooltips[i] local tipX, tipY = firstX, firstY -- base position tipY = tipY + offset -- shift -- get cursor's absolute position (stay at 0,0 if cursor not showing) local cursorX, cursorY = 0, 0 if isCursorShowing() then cursorX, cursorY = getCursorPosition() cursorX, cursorY = cursorX * screenWidth, cursorY * screenHeight end if isInBox(cursorX, cursorY, tipX, tipY, 80, 30) then -- active button dxDrawRectangle(tipX, tipY, 80, 30, tocolor(0,0,0,255)) dxDrawText(tooltip, tipX, tipY, tipX+80, tipY+30, tocolor(255,255,255,255), 1, "default-bold", "center", "center") else -- not active button dxDrawRectangle(tipX, tipY, 80, 30, tocolor(255,255,255,255)) dxDrawText(tooltip, tipX, tipY, tipX+80, tipY+30, tocolor(0,0,0,255), 1, "default-bold", "center", "center") end -- increase offset (to draw next one under the previous) offset = offset + 50 end end) -- cheking part -- here we calculate the tooltips positions again with the same method addEventHandler("onClientClick", root, function(key, state, cursorX, cursorY) if key == "left" and state == "up" then -- check only left-clicks local offset = 0 -- position offset between tooltips, ofc this is 0 by default for i = 1, #tooltips do local tooltip = tooltips[i] local tipX, tipY = firstX, firstY -- base position tipY = tipY + offset -- shift -- the event give us the cursor positions, we don't have to calculate them if isInBox(cursorX, cursorY, tipX, tipY, 80, 30) then -- clicking on this tooltip outputChatBox("Clicking on tooltip: " .. tooltip) return -- stop the for loop, not necessary to check others end -- increase offset offset = offset + 50 end end end) function isInBox(clickX, clickY, boxX, boxY, boxWidth, boxHeight) return (clickX >= boxX and clickX <= boxX + boxWidth ) and (clickY >= boxY and clickY <= boxY + boxHeight ) end
  6. Hi. Your thread has been moved to Scripting section, However, currently this is not possible, you can't create server-sided vehicle with freshly requested ID.
  7. 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.
  8. -- 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")
  9. Looks like this resource use my code, here you can find the original script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18006 - Custom plate-text depends on default plate, you can change it with: setVehiclePlateText
  10. 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)
  11. 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
  12. 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
  13. Show me the code or send me a test resource.
  14. Is ped (targetElement) created on server-side?
  15. Probably the easiest way if you check it on client-side, and trigger (triggerServerEvent) the server-sided function.
  16. You can manage users in phpMyAdmin, start MySQL and Apache too in XAMPP, then you can reach it on: http://localhost/phpmyadmin Select 'User accounts' menu, this is how it looks like by default:
  17. Okay, so you have 2 fields in the json. ok and result function newResult(getupdates) if getupdates then outputConsole("Start of iteration") local jsonUpdates = fromJSON(getupdates) local ok = jsonUpdates["ok"] -- is 'ok' true? if ok then -- yes it was successful, so loop trough results local result = jsonUpdates["result"] -- you can print out tables to debug console to check content, with: iprint(result) for i, v in ipairs(result) do outputConsole(i..": update_id: "..v["update_id"].." | message_id: "..v["message"]["message_id"]) end end outputConsole("End of iteration") outputConsole(getupdates) else outputDebugString("ERROR!", 3) end end fetchRemote(link, newResult) Here you can read about tables: https://forum.multitheftauto.com/topic/130181-lua-tables-as-sets-instead-of-arrays/
  18. How the string looks like? paste it here
  19. Hi. You have to convert JSON to Lua array with fromJSON. (probably callRemote do it automatically)
×
×
  • Create New...