Jump to content

Patrick

Moderators
  • Posts

    1,143
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by Patrick

  1. Hello! Send me a private message and I can help you in Hungarian.
  2. I see. local sx, sy = guiGetScreenSize() local selectStartCursorX, selectStartCursorY = false, false function getElementsWithinScreenZone(elementType, x, y, w, h) local streamedElements = getElementsByType(elementType, root, true) local inZoneElements = {} for i, element in ipairs(streamedElements) do local elementX, elementY, elementZ = getElementPosition(element) local screenX, screenY = getScreenFromWorldPosition(elementX, elementY, elementZ) if (screenX >= x and screenX <= x+w and screenY >= y and screenY <= y+h) then table.insert(inZoneElements, element) end end return inZoneElements end function render() if isCursorShowing() then local cx, cy = getCursorPosition() local cx, cy = cx * sx, cy * sy local selectZoneX, selectZoneY, selectZoneW, selectZoneH if (cx < selectStartCursorX) then selectZoneX, selectZoneW = cx, selectStartCursorX - cx else selectZoneX, selectZoneW = selectStartCursorX, cx - selectStartCursorX end if (cy < selectStartCursorY) then selectZoneY, selectZoneH = cy, selectStartCursorY - cy else selectZoneY, selectZoneH = selectStartCursorY, cy - selectStartCursorY end dxDrawRectangle(selectZoneX, selectZoneY, selectZoneW, selectZoneH, tocolor(20,20,20,80)) local selectedVehicles = getElementsWithinScreenZone("vehicle", selectZoneX, selectZoneY, selectZoneW, selectZoneH) for i, vehicle in ipairs(selectedVehicles) do local elementX, elementY, elementZ = getElementPosition(vehicle) local screenX, screenY = getScreenFromWorldPosition(elementX, elementY, elementZ) dxDrawCircle(screenX, screenY, 6) end end end function startSelect() local cx, cy = getCursorPosition() selectStartCursorX, selectStartCursorY = cx * sx, cy * sy addEventHandler("onClientRender", root, render) end function stopSelect() removeEventHandler("onClientRender", root, render) end addEventHandler("onClientKey", root, function(key, state) if key == "mouse1" then if state and isCursorShowing() then startSelect() else stopSelect() end end end)
  3. http://lua-users.org/wiki/DebugLibraryTutorial
  4. -- CLIENT SIDE local w, h = 25, 25 local screenWidth, screenHeight = guiGetScreenSize() function selecting() if isCursorShowing() then local cursorX, cursorY = getCursorPosition() -- Its returns relative positions local cursorX, cursorY = cursorX*screenWidth, cursorY*screenHeight -- so you need to multiply with your screen sizes (So this is now the absolute positions, the pixels.) dxDrawLinedRectangle(cursorX - w/2, cursorY - h/2, w, h, tocolor(255,255,255,255), 2) for i, v in ipairs(getElementsByType("vehicle")) do local vx, vy, vz = getElementPosition(v) local sx, sy = getScreenFromWorldPosition(vx, vy, vz) if (cursorX >= (sx - w/2) and cursorX <= (sx + w/2) and cursorY >= (sy - h/2) and cursorY <= (sy + h/2)) then dxDrawLinedRectangle(sx - w/2, sy - h/2, w, h, tocolor(255,50,50,255), 2) -- Cursor in rectrangle else dxDrawLinedRectangle(sx - w/2, sy - h/2, w, h, tocolor(255,255,255,255), 2) end end end end function dxDrawLinedRectangle( x, y, width, height, color, _width, postGUI ) _width = _width or 1 dxDrawLine ( x, y, x+width, y, color, _width, postGUI ) -- Top dxDrawLine ( x, y, x, y+height, color, _width, postGUI ) -- Left dxDrawLine ( x, y+height, x+width, y+height, color, _width, postGUI ) -- Bottom return dxDrawLine ( x+width, y, x+width, y+height, color, _width, postGUI ) -- Right end function select_event() addEventHandler("onClientRender", root, selecting) end bindKey("mouse1", "down", select_event) function select_event_disable() removeEventHandler("onClientRender", root, selecting) end bindKey("mouse1", "up", select_event_disable) Something like that?
  5. This script is horrible and resource demanding. What you want to do? Do something when the player is right clicked on a car? If so, try this: function onVehicleRightClick(vehicleElement) outputChatBox("You are right clicked on " .. getVehicleName(vehicleElement)) end addEventHandler("onClientClick", root, function(button, state, _, _, _, _, _, clickedElement) if button == "right" and state == "up" and isElement(clickedElement) and getElementType(clickedElement) == "vehicle" then onVehicleRightClick(clickedElement) end end) But the answer to your question is, you are trying to multiply a boolean with a number. The boolean are the sx and sy, because getScreenFromWorldPosition returns false. (getScreenFromWorldPosition returns false when the element dont showing on your screen.)
  6. Insert this line somewhere your code: -- SERVER SIDE setTimer(restartResource, 600000, 1, getThisResource())
  7. No killTimer needed, because the setTimer runs once. (And the check is a function and not a timer)
  8. You need to create a separeted resource, and make you sure this resource starts before all. You can make it with <download_priority_group>. (Link: https://wiki.multitheftauto.com/wiki/Meta.xml) So, here is the script: -- CLIENT SIDE local sx, sy = guiGetScreenSize() function loadingScreen() dxDrawImage(0, 0, sx, sy, "loadingimage.png") end addEventHandler("onClientResourceStart", resourceRoot, function() addEventHandler("onClientRender", root, loadingScreen) local function check() if isTransferBoxActive() then setTimer(check, 1000, 1) else removeEventHandler("onClientRender", root, loadingScreen) end end setTimer(check, 1000, 1) end) And the meta: -- META <meta> <download_priority_group>10</download_priority_group> <!-- IMPORTANT --> <script src="client.lua" type="client"/> <file src="loadingimage.png"/> </meta>
  9. Yes, but make you sure, you are using correct name. function createEffects(_, effectName) createEffect(effectName, Vector3(getElementPosition(getLocalPlayer())), Vector3(getElementRotation(getLocalPlayer()))) end addCommandHandler("createEffect", createEffects)
  10. Patrick

    help

    You need to change vehicle's position what use the player. Use this function to get the player's vehicle: https://wiki.multitheftauto.com/wiki/GetPedOccupiedVehicle
  11. You can get the broken parts with the 'getVehiclePanelState' function. Only way if you scan all part's state on every damage.
  12. Patrick

    Help

    -- SERVER SIDE local blockTimers = {} local blockDuration = 5000 addCommandHandler("health", function(player) if blockTimers[player] then local leftSec = getTimerDetails(blockTimers[player]) / 1000 local leftMin = math.floor(leftSec / 60) local leftSec = math.floor(leftSec - (leftMin * 60)) outputChatBox("You already got health. Please wait "..leftMin.." minuntes and "..leftSec.." seconds.", player, 255, 0, 0, true) return false end setElementHealth(player, 100) outputChatBox("Done", player, 0, 255, 0, true) blockTimers[player] = setTimer(function() blockTimers[player] = nil -- destroy timer old details -- information about limit expiration, or something like that -- example: outputChatBox("You can use /health again.", player, 255, 0, 0, true) end, blockDuration, 1) end)
  13. You can get sound's lenght with this function: https://wiki.multitheftauto.com/wiki/GetSoundLength But I don't know it's working with URL.
  14. Patrick

    Help

    You tried to get details for a number. -- SERVER SIDE local blockTimers = {} local blockDuration = 5000 addCommandHandler("health", function(player) if blockTimers[player] then outputChatBox("You already got health. Please wait "..(getTimerDetails(blockTimers[player]) / 1000).."s.", player, 255, 0, 0, true) return false end setElementHealth(player, 100) outputChatBox("Done", player, 0, 255, 0, true) blockTimers[player] = setTimer(function() blockTimers[player] = nil -- destroy timer old details -- information about limit expiration, or something like that -- example: outputChatBox("You can use /health again.", player, 255, 0, 0, true) end, blockDuration, 1) end)
  15. https://wiki.multitheftauto.com/wiki/SetWorldSpecialPropertyEnabled setWorldSpecialPropertyEnabled("randomfoliage", false)
  16. Használd a 'enter_exit'-et, mert a 'enter_passenger'-re csak bindet tudsz tenni ami a settingsbe beállított gombhoz "illeszkedik". (Use 'enter_exit', because 'enter_passenger' is an MTA hard-coded command and you can only bind a function to that.)
  17. I made it. https://community.multitheftauto.com/?p=resources&amp;s=details&amp;id=15863
  18. MTA does not change the weather automatically. Find the resource what change and remove IDs from it.
  19. I think you can not destroy the leaves like an object. You can use shaders. Try to load empty (alpha) shader to leaves.
  20. You want to disable jumping? Use this function: https://wiki.multitheftauto.com/wiki/ToggleControl -- server side function disablePedJumping(player) if isElement(player) then return toggleControl(player, "jump", false) end return false end
  21. You can only get the cursor's position if cursor is showing. https://wiki.multitheftauto.com/wiki/IsCursorShowing local sx, sy = guiGetScreenSize() function getpos() if isCursorShowing() then local cx, cy = getCursorPosition() return sx*cx, sy*cy end return false end
  22. Patrick

    All about peds

    1. If you create the ped on client side, the ped only visible for the client. But you create it on server side, the ped visible for everybody. 2. Both 3. Server.
  23. Set outputChatBox 6th argument to true, after it you can use html (hex) color codes. outputChatBox("#ffffffA skin do ped foi definida para: #ff0000" .. model, root, 255, 255, 255, true) Here you can find the colorcodes: https://htmlcolorcodes.com/
×
×
  • Create New...