Tokio Posted November 11, 2017 Posted November 11, 2017 function ccv (thePlayer) local accountname = getAccountName (getPlayerAccount(thePlayer)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then setTimer(function() ve1 = createVehicle ( 535, -2220.98706, -129.69173, 35.32031 ) ma1 = createMarker ( -2221.09668, -129.61031, 33.88103, "cylinder", 7.5, 255, 255, 0, 5 ) end, 1000, 1) end end addCommandHandler("ccvp", ccv) function marker1() destroyElement(ve1) destroyElement(ma1) end addEventHandler( "onMarkerHit", ma1, marker1) when i walk into the marker, nothing happens
WorthlessCynomys Posted November 11, 2017 Posted November 11, 2017 It may be because addEventHandler runs when the script starts but the marker is not existing at that time. I'd put the addEventHandler in the function after the creation of the vehicle and the marker and give it a try.
Tokio Posted November 11, 2017 Author Posted November 11, 2017 5 minutes ago, Randomly said: It may be because addEventHandler runs when the script starts but the marker is not existing at that time. I'd put the addEventHandler in the function after the creation of the vehicle and the marker and give it a try. does not working
WorthlessCynomys Posted November 11, 2017 Posted November 11, 2017 Hm. Is it inside the setTimer with the creations?
Tokio Posted November 11, 2017 Author Posted November 11, 2017 1 minute ago, Randomly said: Hm. Is it inside the setTimer with the creations? No, after the settimer
WorthlessCynomys Posted November 11, 2017 Posted November 11, 2017 1 minute ago, 50cent said: No, after the settimer Try it in the timer.
Tokio Posted November 11, 2017 Author Posted November 11, 2017 2 minutes ago, Randomly said: Try it in the timer. does not working
WorthlessCynomys Posted November 11, 2017 Posted November 11, 2017 Do you use debugscript 3 in the console? Does it output sg?
Tokio Posted November 11, 2017 Author Posted November 11, 2017 6 minutes ago, Randomly said: Do you use debugscript 3 in the console? Does it output sg? Bad argument @ addEventHandler [Expected element at argument 2, got nil]
WorthlessCynomys Posted November 11, 2017 Posted November 11, 2017 @IIYAMA any ideas? I know you're good 1
Moderators IIYAMA Posted November 11, 2017 Moderators Posted November 11, 2017 You can't attach an addEventHandler to an element that doesn't exist yet.(it exist after the addCommandHandler has been executed. Feel free to apply this tutorial: (because a parent element can be created and attached before the children are created)
MaurO^ Posted November 13, 2017 Posted November 13, 2017 On 11/11/2017 at 07:35, 50cent said: function ccv (thePlayer) local accountname = getAccountName (getPlayerAccount(thePlayer)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then setTimer(function() ve1 = createVehicle ( 535, -2220.98706, -129.69173, 35.32031 ) ma1 = createMarker ( -2221.09668, -129.61031, 33.88103, "cylinder", 7.5, 255, 255, 0, 5 ) end, 1000, 1) end end addCommandHandler("ccvp", ccv) function marker1() destroyElement(ve1) destroyElement(ma1) end addEventHandler( "onMarkerHit", ma1, marker1) when i walk into the marker, nothing happens function ccv (thePlayer) local accountname = getAccountName (getPlayerAccount(thePlayer)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then setTimer(function() ve1 = createVehicle ( 535, -2220.98706, -129.69173, 35.32031 ) ma1 = createMarker ( -2221.09668, -129.61031, 33.88103, "cylinder", 7.5, 255, 255, 0, 5 ) addEventHandler( "onMarkerHit", ma1, marker1) end, 1000, 1) end end addCommandHandler("ccvp", ccv) function marker1( hitElement ) if(getElementType(hitElement) == "player") then if isElement(ve1) then destroyElement(ve1) end if isElement(ma1) then destroyElement(ma1) end end end try this.
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