Dear community,
this is the first time that i post here but i am need to do this ^^ I'm austrian, but i don get answers in german boards.
I have the following problem:
I want to check the correct combination of a truck and trailer - for example i only allow a Petrol Tanker with the Gas Trailer , otherwise i want to detach the trailer from the truck.
Here is my code, i used the onTrailerAttach - Event:
addEventHandler("onTrailerAttach",getRootElement(),
function(truck)
local truckid = getElementModel(truck)
local trailerid = getElementModel(source)
--outputChatBox("ERGEBNIS: "..tostring(trailerid))
if(truckid==515) then
if(trailerid==450) then
outputChatBox("Gute Fahrt")
else
outputChatBox("Deine Kupplung ist nicht fuer diesen Anhaenger ausgelegt - "..tostring(trailerid))
detachTrailerFromVehicle(truck,source)
end
end
end
)
This Code make this bug: The trailer detach from the truck, but reattach it immediatly. Please help how to avoid this bug!
greets