Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 30/05/22 in all areas

  1. Hello @VortDyn, I moved your topic to the Scripting section. The Tutorials section is only for Scripting Tutorials, for scripting questions, use the Scripting section instead. Make sure to use this section for your next scripting questions.
    1 point
  2. You can use getVehicleTowedByVehicle to get the trailer attached to a truck. https://wiki.multitheftauto.com/wiki/GetVehicleTowedByVehicle First create your marker (serverside) local myMarker = createMarker(0, 0, 0, 'cylinder', 1, 255, 0, 0, 150) setElementID(myMarker, 'myMarker') Listen for hit event and check for petrol trailer for example (serverside) addEventHandler('onMarkerHit', myMarker, function(hitElement) if getElementType(hitElement) == 'vehicle' then local driver = getVehicleOccupant(hitElement) if driver then local trailer = getVehicleTowedByVehicle(hitElement) if trailer and getElementModel(trailer) == 584 then outputChatBox('You have a petrol trailer', driver, 0, 255, 0) else outputChatBox('You do not have a petrol trailer.', driver, 255, 0, 0) end end end end) Or listen for key press while inside the marker (clientside) addEventHandler('onClientKey', root, function(key, p) if key == 'e' and p then local vehicle = getElementVehicle(localPlayer) local myMarker = getElementByID('myMarker') if vehicle and isElementWithinColShape(vehicle, getElementColShape(myMarker)) then local trailer = getVehicleTowedByVehicle(vehicle) if trailer and getElementModel(trailer) == 584 then outputChatBox('You have a petrol trailer.', 0, 255, 0) else outputChatBox('You do not have a petrol trailer.', 255, 0, 0) end end end end) Hope this helps!
    1 point
  3. That's overloading, mate. No such thing here on Lua, mate. But you could simulate that behavior as @Patrickputs it, and then proceed to redirect the arguments to a specific range of functions. local function OutputText(text) -- code end local function OutputTextToPlayer(text, player) -- code end local function OutputTextToPlayerWithColor(text, player, r, g, b) -- code end -- Patrick's suggestion. function Output(...) -- "magic parameter" for all local args = {...} -- put them into a table local length = #args if length == 1 then -- 1 parameter passed to function local text = args[1] OutputText(text) elseif length == 2 then -- 2 parameter passed to function local text, player = args[1], args[2] OutputTextToPlayer(text, player) elseif length == 5 then -- 5 parameter passed to function local text, player, colorR, colorG, colorB = unpack(args) -- or you can use unpack instead of indexing table one by one OutputTextToPlayerWithColor(text, player, colorR, colorG, colorB) end end
    1 point
  4. I think this is what you want: CustomWindow:setMinimalWidth CustomWindow:setMinimalHeight CustomWindow:setMaximalHeight CustomWindow:setMaximalHeight https://wiki.multitheftauto.com/index.php?title=CustomWindow:setMinimalWidth&action=edit&redlink=1 https://wiki.multitheftauto.com/index.php?title=CustomWindow:setMinimalHeight&action=edit&redlink=1 https://wiki.multitheftauto.com/index.php?title=CustomWindow:setMaximalWidth&action=edit&redlink=1 https://wiki.multitheftauto.com/index.php?title=CustomWindow:setMaximalHeight&action=edit&redlink=1 Nvm you can delete the answer because only now I noticed that the functions are not implemented yet.
    1 point
×
×
  • Create New...