Tokio Posted November 11, 2017 Share 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 Link to comment
WorthlessCynomys Posted November 11, 2017 Share 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. Link to comment
Tokio Posted November 11, 2017 Author Share 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 Link to comment
WorthlessCynomys Posted November 11, 2017 Share Posted November 11, 2017 Hm. Is it inside the setTimer with the creations? Link to comment
Tokio Posted November 11, 2017 Author Share Posted November 11, 2017 1 minute ago, Randomly said: Hm. Is it inside the setTimer with the creations? No, after the settimer Link to comment
WorthlessCynomys Posted November 11, 2017 Share Posted November 11, 2017 1 minute ago, 50cent said: No, after the settimer Try it in the timer. Link to comment
Tokio Posted November 11, 2017 Author Share Posted November 11, 2017 2 minutes ago, Randomly said: Try it in the timer. does not working Link to comment
WorthlessCynomys Posted November 11, 2017 Share Posted November 11, 2017 Do you use debugscript 3 in the console? Does it output sg? Link to comment
Tokio Posted November 11, 2017 Author Share 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] Link to comment
WorthlessCynomys Posted November 11, 2017 Share Posted November 11, 2017 @IIYAMA any ideas? I know you're good 1 Link to comment
Moderators IIYAMA Posted November 11, 2017 Moderators Share 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) Link to comment
MaurO^ Posted November 13, 2017 Share 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. 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