Trust aka Tiffergan Posted November 27, 2020 Share Posted November 27, 2020 Hello can someone tell me how i can attached colsphere to moving vehicle, i trying to do moving train and when train hitmarker train will stop but i dont really know how i can attach sphere to train Link to comment
Lergen Posted November 27, 2020 Share Posted November 27, 2020 (edited) I might be mistaken, but if you're looking to attach a colsphere to the vehicle itself you should be able to use attachElements Edited November 27, 2020 by Lergen 1 Link to comment
Trust aka Tiffergan Posted November 27, 2020 Author Share Posted November 27, 2020 O i have attached cuboid, but how i can make information when train hit marker i will have output on chat? Link to comment
Lergen Posted November 27, 2020 Share Posted November 27, 2020 What I would do is use OnColShapeHit and use GetElementModel to check the ID of the vehicle that hits the sphere. If the ID is the same as your train's have it output to the chatbox. (you can check vehicle ID's from here if you need.) 1 Link to comment
Trust aka Tiffergan Posted November 27, 2020 Author Share Posted November 27, 2020 so i did something like that but im to stupid to make it working local stop = createColRectangle ( 2541, 2557, 10, 25 ) function enter ( targetElem, matchingDimension ) getElementModel(targetElem) == 537 then outputChatBox ( "Train Stopped", getRootElement(), 255, 255, 109 ) end end addEventHandler ( "onColShapeHit", stop, enter ) and error is in this line @Lergen getElementModel(targetElem) == 537 then unexpected symbol near '==' Link to comment
Lergen Posted November 27, 2020 Share Posted November 27, 2020 (edited) You can give this a try (I think you just forgot the "if" statement): local stop = createColRectangle ( 2541, 2557, 10, 25 ) function enter ( targetElem, matchingDimension ) if getElementModel(targetElem) == 537 then outputChatBox ( "Train Stopped", getRootElement(), 255, 255, 109 ) end end addEventHandler ( "onColShapeHit", stop, enter ) Edited November 27, 2020 by Lergen Link to comment
Trust aka Tiffergan Posted November 27, 2020 Author Share Posted November 27, 2020 so there is no errors now when i add IF but this not working... this is video when my train ( cuboid ) hit rectangle there is no output on that https://streamable.com/hlmvld even try to do this on MARKER but not working too local marker = createMarker(2548.81494, 2573.95142, 14.99850-5, "cylinder", 15, 255, 0, 0, 50) function enter ( targetElem, matchingDimension ) if getElementModel(targetElem) == 537 then outputChatBox ( "Train Stopped", root(), 255, 255, 109 ) end end addEventHandler ( "onMarkerHit", marker, enter ) Link to comment
Lergen Posted November 27, 2020 Share Posted November 27, 2020 (edited) Can you give this a try? I gave it a test on my local server and it worked: local marker = createMarker(2548.81494, 2573.95142, 14.99850-5, "cylinder", 15, 255, 0, 0, 50) function enter ( targetElem, matchingDimension ) if getElementModel(targetElem) == 537 then outputChatBox ( "Train Stopped", root, 255, 255, 109 ) end end addEventHandler ( "onMarkerHit", marker, enter ) Edited November 27, 2020 by Lergen Link to comment
Trust aka Tiffergan Posted November 27, 2020 Author Share Posted November 27, 2020 Just remember that I mean that there is an outputChatBox when the train enters the marker itself, and we do not steer it, because when I create a train from the admin panel and drive it, I also have it in my chat Link to comment
Lergen Posted November 27, 2020 Share Posted November 27, 2020 If I'm understanding right, you want to have it only trigger the chatbox if it's not a player driving it? It's a bit ad-hoc but you could try this: local marker = createMarker(2548.81494, 2573.95142, 14.99850-5, "cylinder", 15, 255, 0, 0, 50) function isVehicleEmpty( vehicle ) if not isElement( vehicle ) or getElementType( vehicle ) ~= "vehicle" then return true end if getVehicleOccupant( vehicle, 0 ) then return false end return true end function enter ( targetElem, matchingDimension ) if isVehicleEmpty(targetElem) == true and getElementModel(targetElem) == 537 then outputChatBox ( "Train Stopped", root, 255, 255, 109 ) end end addEventHandler ( "onMarkerHit", marker, enter ) There's probably a better way of going about this, but this should only trigger the chatbox if the train has no driver. Link to comment
Trust aka Tiffergan Posted November 28, 2020 Author Share Posted November 28, 2020 no errors no working :~... To be clear and everyone understands what I want to do, so I have a train that runs by itself on the tracks and keeps going all by itself, and I just want to do at each station in the LS / SF / LV Marker where the train would he stopped for X time, but the first thing I wants to do is that when he hits the marker, although I have a message about it in this case, "Train Stopped", although even it does not work, the earlier solutions would work if I was driving this train, but it drives by itself so here's the problem. I gave it a cuboid that is "stuck" to the train and I wanted to do something on the principle that if the cuboid would hit the marker, but such things can't be done either ... I don't know what to do... Link to comment
Tekken Posted November 28, 2020 Share Posted November 28, 2020 May I know how do you manage trains? Do you have a resource? Link to comment
Trust aka Tiffergan Posted November 29, 2020 Author Share Posted November 29, 2020 im using setStreamable to make train move Link to comment
Trust aka Tiffergan Posted November 30, 2020 Author Share Posted November 30, 2020 anyone can help ? Link to comment
Trust aka Tiffergan Posted December 1, 2020 Author Share Posted December 1, 2020 Someone please help me i don't know what to do ;( Link to comment
Tekken Posted December 1, 2020 Share Posted December 1, 2020 Well you can try putting a ped in the train and check when the ped hits the marker and do whatever you want to do? Link to comment
Trust aka Tiffergan Posted December 2, 2020 Author Share Posted December 2, 2020 good idea with the ped that maybe will work, how i can get ped in vehicle using createped or what? @Tekken Link to comment
Tekken Posted December 2, 2020 Share Posted December 2, 2020 WarpPedIntoVehicle i think look on wiki Link to comment
Hydra Posted December 2, 2020 Share Posted December 2, 2020 35 minutes ago, LOOah said: good idea with the ped that maybe will work, how i can get ped in vehicle using createped or what? @Tekken warpPedIntoVehicle(thePed, theVehicle, 0) 1 Link to comment
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