isa_Khamdan Posted July 14, 2013 Share 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? Link to comment
فاّرس Posted July 14, 2013 Share 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 Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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] Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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 ) Link to comment
Moderators IIYAMA Posted July 14, 2013 Moderators Share 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 Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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? Link to comment
isa_Khamdan Posted July 14, 2013 Author Share Posted July 14, 2013 I tested it but it's not working Link to comment
Moderators IIYAMA Posted July 14, 2013 Moderators Share 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. Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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 Link to comment
Moderators IIYAMA Posted July 14, 2013 Moderators Share 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) Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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? Link to comment
Moderators IIYAMA Posted July 14, 2013 Moderators Share Posted July 14, 2013 Use a timer: https://wiki.multitheftauto.com/wiki/SetTimer drawtext only works for clientside: https://wiki.multitheftauto.com/wiki/TriggerClientEvent Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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? Link to comment
فاّرس Posted July 14, 2013 Share Posted July 14, 2013 You want freeze the vehicle for 5 sec and after 5 sec unfreeze? Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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 Link to comment
Castillo Posted July 14, 2013 Share 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. Link to comment
isa_Khamdan Posted July 14, 2013 Author Share Posted July 14, 2013 Thanks but what about the text when you get freeze and unfreeze? Link to comment
Castillo Posted July 14, 2013 Share Posted July 14, 2013 I'm not going to do that for you aswell. Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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 Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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 ) Link to comment
Castillo Posted July 14, 2013 Share Posted July 14, 2013 No, it doesn't make any sense. Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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 Link to comment
Castillo Posted July 14, 2013 Share Posted July 14, 2013 -- server side: triggerClientEvent -- client side: addEvent addEventHandler dxDrawText onClientRender Link to comment
isa_Khamdan Posted July 14, 2013 Author Share 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? 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