Lloyd Logan Posted January 19, 2013 Share Posted January 19, 2013 Hey, so How would I make it so that when the car if fixed and the player leaves the marker it won't say "Wait you forgot your repair". I made it so that it says that when you leave the marker, it displays that. But even if the car is repaired and the player leaves, it still says it? Server dutymarker = createMarker(1911.35938, -1777.46899, 11.98387, "cylinder", 4.0, 255, 255, 155) function paynspray(hitElement,matchingDimension) if (hitElement and getElementType(hitElement) == "player" and matchingDimension) then local money = getPlayerMoney(hitElement) if ( money>=500 ) then outputChatBox("Please wait whilst we work on your vehicle!", hitElement) setTimer (fixVehicle, 5000, 1, getPedOccupiedVehicle(hitElement)) setTimer ( outputChatBox, 5000, 1, "Thank you for for coming to us for your repair!" ) else outputChatBox("Please come back when you have atleast $500, thank you", hitElement) end end end addEventHandler("onMarkerHit", dutymarker, paynspray) function mLeave(hitElement, matchingDimension) if (hitElement and getElementType(hitElement) == "player" and matchingDimension) then cancelEvent("onMarkerHit", paynspray) outputChatBox("Wait, you forgot your repair!", hitElement) else local money = getPlayerMoney(hitElement) if ( money<=500 ) then outputChatBox("", hitElement) end end end addEventHandler("onMarkerLeave", getRootElement(), mLeave) Link to comment
3NAD Posted January 19, 2013 Share Posted January 19, 2013 dutymarker = createMarker(1911.35938, -1777.46899, 11.98387, "cylinder", 4.0, 255, 255, 155) function paynspray ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" then if isPedInVehicle ( hitElement ) then local money = getPlayerMoney ( hitElement ) if money >= 500 then outputChatBox ( "Please wait whilst we work on your vehicle!", hitElement) setTimer ( function ( ) fixVehicle ( getPedOccupiedVehicle ( hitElement ) ) outputChatBox ( "Thank you for coming to us for your repair!" ) end , 5000, 1 ) else outputChatBox("Please come back when you have atleast $500, thank you", hitElement) end else outputChatBox ( "You don't have vehicle!", hitElement) end end end addEventHandler ( "onMarkerHit", dutymarker, paynspray, false ) function mLeave ( hitElement, matchingDimension ) if getElementType(hitElement) == "player" then removeEventHandler ( "onMarkerHit", dutymarker, paynspray ) outputChatBox ( "Wait, you forgot your repair!", hitElement ) end end addEventHandler ( "onMarkerLeave", dutymarker, mLeave, false ) Link to comment
Lloyd Logan Posted January 19, 2013 Author Share Posted January 19, 2013 dutymarker = createMarker(1911.35938, -1777.46899, 11.98387, "cylinder", 4.0, 255, 255, 155) function paynspray ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" then if isPedInVehicle ( hitElement ) then local money = getPlayerMoney ( hitElement ) if money >= 500 then outputChatBox ( "Please wait whilst we work on your vehicle!", hitElement) setTimer ( function ( ) fixVehicle ( getPedOccupiedVehicle ( hitElement ) ) outputChatBox ( "Thank you for coming to us for your repair!" ) end , 5000, 1 ) else outputChatBox("Please come back when you have atleast $500, thank you", hitElement) end else outputChatBox ( "You don't have vehicle!", hitElement) end end end addEventHandler ( "onMarkerHit", dutymarker, paynspray, false ) function mLeave ( hitElement, matchingDimension ) if getElementType(hitElement) == "player" then removeEventHandler ( "onMarkerHit", dutymarker, paynspray ) outputChatBox ( "Wait, you forgot your repair!", hitElement ) end end addEventHandler ( "onMarkerLeave", dutymarker, mLeave, false ) What i mean is, when i leave the marker, it cancels the event, which was working, but... It always say wait, you forgot your repair, even if they have got their repair or they've got no money, it still says "wait your forgot your repair!" Link to comment
3NAD Posted January 19, 2013 Share Posted January 19, 2013 Use setElementData getElementData Link to comment
Lloyd Logan Posted January 19, 2013 Author Share Posted January 19, 2013 Use setElementData getElementData How would i use these? Like, what data would i get and set? Link to comment
J.S. Posted January 19, 2013 Share Posted January 19, 2013 Element data isn't necessary. Just assign a variable to the timer and use killTimer when they leave the marker. Also, I'd set the marker alpha to 0 to make it invisible, but that's just my preference. Link to comment
Lloyd Logan Posted January 19, 2013 Author Share Posted January 19, 2013 Element data isn't necessary. Just assign a variable to the timer and use killTimer when they leave the marker.Also, I'd set the marker alpha to 0 to make it invisible, but that's just my preference. Thank I'll try that, the alpha was at 0 but i was trying other createMarkers. Thanks Alot! Link to comment
3NAD Posted January 19, 2013 Share Posted January 19, 2013 Why not try Tables, like this dutymarker = createMarker ( 1911.35938, -1777.46899, 11.98387, "cylinder", 4.0, 255, 255, 155, 255 ) fix = { } function paynspray ( hitElement, matchingDimension ) if getElementType ( hitElement ) == "player" then if isPedInVehicle ( hitElement ) then local money = getPlayerMoney ( hitElement ) if money >= 500 then outputChatBox ( "Please wait while we work on your vehicle!", hitElement, 255, 255, 0, true ) fix [ hitElement ] = false theTimer = setTimer ( function ( ) if not isElementWithinMarker ( hitElement, dutymarker ) then if isTimer ( theTimer ) then killTimer ( theTimer ) return end end playSoundFrontEnd ( hitElement, 46 ) takePlayerMoney ( hitElement, 500 ) fixVehicle ( getPedOccupiedVehicle ( hitElement ) ) outputChatBox ( "Thank you for coming to us for your repair!", hitElement, 0, 255, 0, true ) fix [ hitElement ] = true end , 5000, 1 ) else outputChatBox("Please come back when you have atleast $500, thank you", hitElement, 255, 0, 0, true ) end else outputChatBox ( "You don't have vehicle!", hitElement, 255, 0, 0, true ) end end end addEventHandler ( "onMarkerHit", dutymarker, paynspray, false ) function mLeave ( hitElement, matchingDimension ) if getElementType(hitElement) == "player" then if not fix [ hitElement ] then outputChatBox ( "Wait, you forgot your repair!", hitElement, 255, 0, 0, true ) end end end addEventHandler ( "onMarkerLeave", dutymarker, mLeave, false ) Link to comment
Lloyd Logan Posted January 19, 2013 Author Share Posted January 19, 2013 Thats fantastic, 3NAD, it works perfect! Thank You! 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