iiv03 Posted February 7, 2021 Share Posted February 7, 2021 (edited) hey i did not understand here, why vehicle "3" and "4" if it hit marker, nothing happens? only vehicle "1" and "2" work? I tried to make it through the ped that did not work for me, but if I changed botvehicle 2 -to-> botvehicle 3 it would work 3 I would like them to work all also i didn't get any error in debugscript my line: marker_auto_teleport_botscars = createMarker(-759.40002441406, 126.5, 41,"corona",4,0,0,0,0) botvehicle1 = createVehicle( 405, -688.45050048828, 132.56692504883, 41.400001525879, 0, 0, 95.99853515625) botvehicle2 = createVehicle( 547, -651.70001220703, 135.69999694824, 41.400001525879, 0, 0, 95.99853515625) botvehicle3 = createVehicle( 507, -615.09997558594, 138.89999389648, 41.400001525879, 0, 0, 95.99853515625) botvehicle4 = createVehicle( 585, -581.40002441406, 141.69999694824, 41.400001525879, 0, 0, 95.99853515625) addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(botvehicle1) -- element hit take from createVehicle. if getElementType ( botvehicle1 ) == "vehicle" and getElementModel ( botvehicle1 ) == 405 then print("vehicle touched 1") setElementPosition(botvehicle1,-414.1000061035, 157.19999694824, 41.400001525879) end end) addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(botvehicle2) -- element hit take from createVehicle. if getElementType ( botvehicle2 ) == "vehicle" and getElementModel ( botvehicle2 ) == 547 then print("vehicle touched 2") setElementPosition(botvehicle2,-414.1000061035, 157.19999694824, 41.400001525879) end end) addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(botvehicle3) -- element hit take from createVehicle. if getElementType ( botvehicle3 ) == "vehicle" and getElementModel ( botvehicle3 ) == 507 then print("vehicle touched 3") setElementPosition(botvehicle3,-414.1000061035, 157.19999694824, 41.400001525879) end end) addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(botvehicle4) -- element hit take from createVehicle. if getElementType ( botvehicle4 ) == "vehicle" and getElementModel ( botvehicle4 ) == 585 then print("vehicle touched 4") setElementPosition(botvehicle4,-414.1000061035, 157.19999694824, 41.400001525879) end end) Edited February 7, 2021 by xFabel forget to add line marker... Link to comment
iiv03 Posted February 7, 2021 Author Share Posted February 7, 2021 (edited) 35 minutes ago, Tekken said: Might be what you need: i shortened everything first time i used setElementParent and createElement. but I have a problem with the vehicles not moving now when i touch the marker and btw I used the triggerClientEvent to call the onControlState function and my code I did above correct or no? it did not give me any error --client side addEvent ( "onControlState", true ) addEventHandler ( "onControlState", resourceRoot, function () setPedControlState ( source, "accelerate", true ) end ) --server side marker_auto_teleport_botscars = createMarker(-759.40002441406, 126.5, 41,"corona",4,0,0,0,0) teleport_part = createMarker(-757.400390625, 109.099609375, 41.400001525879,"corona",4,0,0,0,0) function parts(teleport_part) -- take element hit from marker if teleport_part then triggerClientEvent ( root, "onControlState", pedveh1 ) -- start make vehicle walk triggerClientEvent ( root, "onControlState", pedveh2 ) -- start make vehicle walk triggerClientEvent ( root, "onControlState", pedveh3 ) -- start make vehicle walk triggerClientEvent ( root, "onControlState", pedveh4 ) -- start make vehicle walk print("touched by player") end end addEventHandler ( "onPlayerMarkerHit", root, parts) local group = createElement("VehicleBots") setElementParent(botvehicle1, group) setElementParent(botvehicle2, group) setElementParent(botvehicle3, group) setElementParent(botvehicle4, group) addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(group) -- take hit elements from group if getElementType ( botvehicle1 ) == "vehicle" and getElementModel ( botvehicle1 ) == 405 then print("vehicle touched 1") setElementPosition(botvehicle1,-414.1000061035, 157.19999694824, 41.400001525879) elseif getElementType ( botvehicle2 ) == "vehicle" and getElementModel ( botvehicle2 ) == 547 then print("vehicle touched 2") setElementPosition(botvehicle2,-414.1000061035, 157.19999694824, 41.400001525879) elseif getElementType ( botvehicle3 ) == "vehicle" and getElementModel ( botvehicle3 ) == 507 then print("vehicle touched 3") setElementPosition(botvehicle3,-414.1000061035, 157.19999694824, 41.400001525879) elseif getElementType ( botvehicle4 ) == "vehicle" and getElementModel ( botvehicle4 ) == 585 then print("vehicle touched 4") setElementPosition(botvehicle4,-414.1000061035, 157.19999694824, 41.400001525879) end end) when i add setElementParent vehicles not move? why and i put if player touche the marker makes vehicles start moving Edited February 7, 2021 by xFabel Link to comment
Tekken Posted February 7, 2021 Share Posted February 7, 2021 I don't quite understand your code but try this: addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(hitelm) if getElementParent(hitelm) == group then if getElementType ( hitelm ) == "vehicle" and getElementModel ( hitelm ) == 405 then --print("vehicle touched 1") setElementPosition(hitelm,-414.1000061035, 157.19999694824, 41.400001525879) elseif getElementType ( hitelm ) == "vehicle" and getElementModel ( hitelm ) == 547 then --print("vehicle touched 2") setElementPosition(hitelm,-414.1000061035, 157.19999694824, 41.400001525879) elseif getElementType ( hitelm ) == "vehicle" and getElementModel ( hitelm ) == 507 then --print("vehicle touched 3") setElementPosition(hitelm,-414.1000061035, 157.19999694824, 41.400001525879) elseif getElementType ( hitelm ) == "vehicle" and getElementModel ( hitelm ) == 585 then --print("vehicle touched 4") setElementPosition(hitelm, -414.1000061035, 157.19999694824, 41.400001525879) end end end) Link to comment
iiv03 Posted February 7, 2021 Author Share Posted February 7, 2021 (edited) 22 minutes ago, Tekken said: I don't quite understand your code but try this: addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(hitelm) if getElementParent(hitelm) == group then if getElementType ( hitelm ) == "vehicle" and getElementModel ( hitelm ) == 405 then --print("vehicle touched 1") setElementPosition(hitelm,-414.1000061035, 157.19999694824, 41.400001525879) elseif getElementType ( hitelm ) == "vehicle" and getElementModel ( hitelm ) == 547 then --print("vehicle touched 2") setElementPosition(hitelm,-414.1000061035, 157.19999694824, 41.400001525879) elseif getElementType ( hitelm ) == "vehicle" and getElementModel ( hitelm ) == 507 then --print("vehicle touched 3") setElementPosition(hitelm,-414.1000061035, 157.19999694824, 41.400001525879) elseif getElementType ( hitelm ) == "vehicle" and getElementModel ( hitelm ) == 585 then --print("vehicle touched 4") setElementPosition(hitelm, -414.1000061035, 157.19999694824, 41.400001525879) end end end) I didn't understand exactly where wrong please check my new code local group = createElement("pedsbots") setElementParent(pedveh1, group) --setElementParent(pedveh2, group) --setElementParent(pedveh3, group) --setElementParent(pedveh4, group) addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function() -- get element 1 parent from group thats i created above if getElementParent(pedveh1) == group then --part check if ped in vehicle try to hit marker if (isElement(pedveh1)) and (getElementType(pedveh1)=="ped") and (getElementModel(pedveh1)==0) then -- here problem text spam me 2 if second car behind firstly and also touching the marker outputChatBox("vehicle touched 1") end end end) Edited February 7, 2021 by xFabel Link to comment
Tekken Posted February 7, 2021 Share Posted February 7, 2021 You should check addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(hitElement ) if hitElement == pedveh1 and getElementParent(hitElement) == group then -- do it end end); NOTE that "onMarkerHit" event have an argument in function called thehitelement == the element that hit the marker. Link to comment
iiv03 Posted February 7, 2021 Author Share Posted February 7, 2021 (edited) 10 minutes ago, Tekken said: You should check addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(hitElement ) if hitElement == pedveh1 and getElementParent(hitElement) == group then -- do it end end); NOTE that "onMarkerHit" event have an argument in function called thehitelement == the element that hit the marker. trust me nothing happen addEventHandler("onMarkerHit", marker_auto_teleport_botscars, function(hitElement) -- get element 1 parent from group thats i created above if hitElement == pedveh1 and getElementParent(hitElement) == group then --part check if ped in vehicle try to hit marker if (isElement(pedveh1)) and (getElementType(pedveh1)=="ped") and (getElementModel(pedveh1)==0) then -- here problem text spam me 2 if second car behind firstly and also touching the marker outputChatBox("vehicle touched 1") end end end) should I know hitElement for an item? like a car vehicle? Edited February 7, 2021 by xFabel Link to comment
Tekken Posted February 7, 2021 Share Posted February 7, 2021 You may send me all code in pm to look up if not want to share it here. 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