Zikablood Posted May 26, 2022 Posted May 26, 2022 (edited) Hello, I'm a programming apprentice and... I would like to know how I do it to: The Marker checks if the PLAYER is inside a TRUCK with TRAILER. I'm doing a truck driver job Edited May 26, 2022 by Zikablood error
Tails Posted May 28, 2022 Posted May 28, 2022 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
Zikablood Posted May 30, 2022 Author Posted May 30, 2022 On 28/05/2022 at 13:01, Tails said: 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! Thanks a lot for the help :) I'm still new to programming so people like you help a lot. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now