TheMaysTRo Posted September 8, 2014 Share Posted September 8, 2014 hey guys . i used attachElements to attach a marker to a vehicle but it appeard that i can't use onMarkerHit on an attached marker . any idea what i must do to make it work ? explination : I want the marker to be attached to the vehicle and when i enter it outputchatbox . Link to comment
joaosilva099 Posted September 8, 2014 Share Posted September 8, 2014 [*]If u want to the message be outputed when enter the vehicle you can use onVehicleEnter event. Otherwise idk Link to comment
Ab-47 Posted September 8, 2014 Share Posted September 8, 2014 Try positioning argument 'Z' to 1 unit ahead of it's original. Otherwise post your code. Link to comment
TheMaysTRo Posted September 8, 2014 Author Share Posted September 8, 2014 local attachedmarker = createMarker (0,0,0,"cylinder",1.2,0,255,255,180) attachElements ( attachedmarker, car, 0, 3, -1 ) function fixandpay(player) setPedAnimation( player, "BD_FIRE", "wash_up ",-1,false,false,nil,false) outputChatBox (".............",player,255,0,0,false) end function commandon (player) if hitElement and isElement (hitElement) and getElementType (hitElement) == "player" and not isPedInVehicle (hitElement) then if source == attachedmarker then outputChatBox (".................",player,255,0,0,false) addCommandHandler ( "fix", fixandpay ) end end end addEventHandler ("onMarkerHit",getRootElement(),commandon) function commandoff(player) if source == attachedmarker then removeCommandHandler ( "fix" ) end end addEventHandler ("onMarkerHit",getRootElement(),commandoff) Link to comment
Ab-47 Posted September 8, 2014 Share Posted September 8, 2014 No Idea. ? Delete your second code and replace it with: function fixandpay(player) setPedAnimation( player, "BD_FIRE", "wash_up ",-1,false,false,nil,false) outputChatBox (".............",player,255,0,0,false) end function commandon (player) if (player and isElement (player) and getElementType (player) == "player") and (not isPedInVehicle (player)) then if (source == attachedmarker) then if (isElementWithinMarker(player)) then outputChatBox (".................",player,255,0,0,false) fixandpay() else return end end end end addCommandHandler ( "fix", commandon ) Then tell me your response. Basically what I've did is, cleared up the code a bit as yours was kinda messy, replaced 'hitElement' with player, as player was defined in your function, removed those useless command/event handlers and added a function to check whether the player is within the marker or not. What you did, you created a marker attached to a vehicle and added an event handler that when you enter the marker a command handler is initiated and then removed, which makes no sense. You've used an un-defined definition, 'hitElement' and most of your code was useless :3 I've left scripting and MTA for a while due to exams, so I'm sorry if my code didn't help.. Link to comment
TheMaysTRo Posted September 8, 2014 Author Share Posted September 8, 2014 No Idea. ? Delete your second code and replace it with: function fixandpay(player) setPedAnimation( player, "BD_FIRE", "wash_up ",-1,false,false,nil,false) outputChatBox (".............",player,255,0,0,false) end function commandon (player) if (player and isElement (player) and getElementType (player) == "player") and (not isPedInVehicle (player)) then if (source == attachedmarker) then if (isElementWithinMarker(player)) then outputChatBox (".................",player,255,0,0,false) fixandpay() else return end end end end addCommandHandler ( "fix", commandon ) Then tell me your response. Basically what I've did is, cleared up the code a bit as yours was kinda messy, replaced 'hitElement' with player, as player was defined in your function, removed those useless command/event handlers and added a function to check whether the player is within the marker or not. What you did, you created a marker attached to a vehicle and added an event handler that when you enter the marker a command handler is initiated and then removed, which makes no sense. You've used an un-defined definition, 'hitElement' and most of your code was useless :3 I've left scripting and MTA for a while due to exams, so I'm sorry if my code didn't help.. thanks for trying to help me you have fault if (isElementWithinMarker(player,attachedmarker)) then but i got an error says "Expected marker at argument 2 got nill." Link to comment
Ab-47 Posted September 10, 2014 Share Posted September 10, 2014 No Idea. ? Delete your second code and replace it with: function fixandpay(player) setPedAnimation( player, "BD_FIRE", "wash_up ",-1,false,false,nil,false) outputChatBox (".............",player,255,0,0,false) end function commandon (player) if (player and isElement (player) and getElementType (player) == "player") and (not isPedInVehicle (player)) then if (source == attachedmarker) then if (isElementWithinMarker(player)) then outputChatBox (".................",player,255,0,0,false) fixandpay() else return end end end end addCommandHandler ( "fix", commandon ) Then tell me your response. Basically what I've did is, cleared up the code a bit as yours was kinda messy, replaced 'hitElement' with player, as player was defined in your function, removed those useless command/event handlers and added a function to check whether the player is within the marker or not. What you did, you created a marker attached to a vehicle and added an event handler that when you enter the marker a command handler is initiated and then removed, which makes no sense. You've used an un-defined definition, 'hitElement' and most of your code was useless :3 I've left scripting and MTA for a while due to exams, so I'm sorry if my code didn't help.. thanks for trying to help me you have fault if (isElementWithinMarker(player,attachedmarker)) then but i got an error says "Expected marker at argument 2 got nill." You did include your marker part did you? local attachedmarker = createMarker (0,0,0,"cylinder",1.2,0,255,255,180) attachElements ( attachedmarker, car, 0, 3, -1 ) ? Link to comment
TheMaysTRo Posted September 10, 2014 Author Share Posted September 10, 2014 yes i did . Link to comment
Ab-47 Posted September 11, 2014 Share Posted September 11, 2014 yes i did . In the same file or a different one? 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