isa_Khamdan Posted July 14, 2013 Posted July 14, 2013 Can someone help me to create marker that when a vehicles enters it , the vehicle will be frozen for 5 seconds and some text will show on the screen?
فاّرس Posted July 14, 2013 Posted July 14, 2013 Function's : createMarker isPedInVehicle getPedOccupiedVehicle setElementFrozen setTimer guiSetVisible --[[ Show the label--]] or dxDrawText with 'onClientRender' Event's : onClientMarkerHit or Server Side : onMarkerHit or onPlayerMarkerHit Sha67 سابقاً
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 Function's : createMarker isPedInVehicle getPedOccupiedVehicle setElementFrozen setTimer guiSetVisible --[[ Show the label--]] or dxDrawText with 'onClientRender' Event's : onClientMarkerHit or Server Side : onMarkerHit or onPlayerMarkerHit Like this? [lua]local myMarker = createMarker(-2596.625, 579.358, 15.626, 'cylinder', 2.0, 255, 0, 0, 150) function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler local elementType = getElementType( hitElement ) -- get the hit element's type if isPedInVehicle then if getPedOccupiedVehicle ( thePlayer ) then local playerVehicle = getPlayerOccupiedVehicle ( thePlayer ) local currentFreezeStatus = isElementFrozen ( playerVehicle ) local newFreezeStatus = not currentFreezeStatus setElementFrozen ( playerVehicle, newFreezeStatus ) end end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) -- attach onMarkerHit event to MarkerHit function function MarkerHit() setTimer ( function() end, 5000, 1 ) end MarkerHit() function changeVisibility ( ) guiSetVisible (myWindow, not guiGetVisible ( myWindow ) ) end myWindow = guiCreateWindow ( 0.3, 0.3, 0.5, 0.60, "Test", true ) setTimer ( changeVisibility, 5000, 1 ) [/lua]
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 I tested it but it's not working only the markers shows up but it doesn't do anythings what did I do wrong? local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150) function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler local elementType = getElementType( hitElement ) -- get the hit element's type if isPedInVehicle then if getPedOccupiedVehicle ( thePlayer ) then local playerVehicle = getPlayerOccupiedVehicle ( thePlayer ) local currentFreezeStatus = isElementFrozen ( playerVehicle ) local newFreezeStatus = not currentFreezeStatus setElementFrozen ( playerVehicle, newFreezeStatus ) end end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) -- attach onMarkerHit event to MarkerHit function function MarkerHit() setTimer ( function() end, 5000, 1 ) end MarkerHit() function changeVisibility ( ) guiSetVisible (myWindow, not guiGetVisible ( myWindow ) ) end myWindow = guiCreateWindow ( 0.3, 0.3, 0.5, 0.60, "Test", true ) setTimer ( changeVisibility, 5000, 1 )
Moderators IIYAMA Posted July 14, 2013 Moderators Posted July 14, 2013 local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150) function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler local elementType = getElementType( hitElement ) -- get the hit element's type if elementType == "player" and isPedInVehicle( hitElement ) then local playerVehicle = getPlayerOccupiedVehicle ( hitElement ) local currentFreezeStatus = isElementFrozen ( playerVehicle ) local newFreezeStatus = not currentFreezeStatus setElementFrozen ( playerVehicle, newFreezeStatus ) end end Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150) function MarkerHit( hitElement, matchingDimension ) -- define MarkerHit function for the handler local elementType = getElementType( hitElement ) -- get the hit element's type if elementType == "player" and isPedInVehicle( hitElement ) then local playerVehicle = getPlayerOccupiedVehicle ( hitElement ) local currentFreezeStatus = isElementFrozen ( playerVehicle ) local newFreezeStatus = not currentFreezeStatus setElementFrozen ( playerVehicle, newFreezeStatus ) end end Even if this works there is no timer in it & no draw text on the screen?
Moderators IIYAMA Posted July 14, 2013 Moderators Posted July 14, 2013 indeed. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
Moderators IIYAMA Posted July 14, 2013 Moderators Posted July 14, 2013 local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150) addEventHandler("onPlayerMarkerHit",root, function ( hitElement, matchingDimension ) -- define MarkerHit function for the handler if isPedInVehicle( hitElement ) then local playerVehicle = getPlayerOccupiedVehicle ( hitElement ) local currentFreezeStatus = isElementFrozen ( playerVehicle ) local newFreezeStatus = not currentFreezeStatus setElementFrozen ( playerVehicle, newFreezeStatus ) end end) Lol I didn't seen you also forgot the event. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 local myMarker = createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150) addEventHandler("onPlayerMarkerHit",root, function ( hitElement, matchingDimension ) -- define MarkerHit function for the handler if isPedInVehicle( hitElement ) then local playerVehicle = getPlayerOccupiedVehicle ( hitElement ) local currentFreezeStatus = isElementFrozen ( playerVehicle ) local newFreezeStatus = not currentFreezeStatus setElementFrozen ( playerVehicle, newFreezeStatus ) end end) Lol I didn't seen you also forgot the event. still not working
Moderators IIYAMA Posted July 14, 2013 Moderators Posted July 14, 2013 addEventHandler("onMarkerHit",createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150) , function ( hitElement, matchingDimension ) if getElementType( hitElement ) == "vehicle" then setElementFrozen ( hitElement, not isElementFrozen ( hitElement ) ) end end) Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 addEventHandler("onMarkerHit",createMarker( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150) , function ( hitElement, matchingDimension ) if getElementType( hitElement ) == "vehicle" then setElementFrozen ( hitElement, not isElementFrozen ( hitElement ) ) end end) Now it works but how can I make it freeze you for 5 seconds only & drawtext will show in screen?
Moderators IIYAMA Posted July 14, 2013 Moderators Posted July 14, 2013 Use a timer: https://wiki.multitheftauto.com/wiki/SetTimer drawtext only works for clientside: https://wiki.multitheftauto.com/wiki/TriggerClientEvent Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 I tried but it didn't work can someone help me to add some text when you get frozen for 5 seconds and then some texts when the freeze gone?
فاّرس Posted July 14, 2013 Posted July 14, 2013 You want freeze the vehicle for 5 sec and after 5 sec unfreeze? Sha67 سابقاً
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 You want freeze the vehicle for 5 sec and after 5 sec unfreeze? yes , and text when you get freeze and some one you get unfreeze
Castillo Posted July 14, 2013 Posted July 14, 2013 addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ) , function ( hitElement, matchingDimension ) if ( getElementType ( hitElement ) == "vehicle" ) then setElementFrozen ( hitElement, true ) setTimer ( setElementFrozen, 5000, 1, hitElement, false ) end end ) That's for the 5 seconds to unfreeze, but for the dxDrawText, you'll have to do that. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 Thanks but what about the text when you get freeze and unfreeze?
Castillo Posted July 14, 2013 Posted July 14, 2013 I'm not going to do that for you aswell. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 I'm not going to do that for you aswell. ok i'll try my self but tell me if I am wrong
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 Will this works and show the text on screen? addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ) , function ( hitElement, matchingDimension ) if ( getElementType ( hitElement ) == "vehicle" ) then triggerClientEvent ( thePlayer, "hitElement", getRootElement(), "Frozen" ) else if ( setElementFrozen, false, hitElement, false ) triggerClientEvent ( thePlayer, "hitElement", getRootElement(), "GO" ) setElementFrozen ( hitElement, true ) setTimer ( setElementFrozen, 5000, 1, hitElement, false ) end end )
Castillo Posted July 14, 2013 Posted July 14, 2013 No, it doesn't make any sense. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 No, it doesn't make any sense. then how can I draw text on screen when you get freeze and unfreeze
Castillo Posted July 14, 2013 Posted July 14, 2013 -- server side: triggerClientEvent -- client side: addEvent addEventHandler dxDrawText onClientRender San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 -- server side: triggerClientEvent -- client side: addEvent addEventHandler dxDrawText onClientRender so I should have a code in server side & client side? not server alone to do that?
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