S3M Posted March 23, 2012 Share Posted March 23, 2012 The idea is that if player onMarkerHit onFire he goes. But now if any player onMarkerHit, then everyone goes onfire. What am I doing wrong? local myMarker = createMarker(2489.1613769531, -1668.5617675781, 11.800, 'cylinder', 2.2, 255, 0, 0, 150) function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) setPedOnFire ( getRootElement(), true ) end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) Link to comment
Alpha Posted March 23, 2012 Share Posted March 23, 2012 local myMarker = createMarker(2489.1613769531, -1668.5617675781, 11.800, 'cylinder', 2.2, 255, 0, 0, 150) function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) if elementType == "player" then setPedOnFire ( hitElement, true ) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) You're using root element in setPedOnFire, which will affect all the players. Link to comment
S3M Posted March 23, 2012 Author Share Posted March 23, 2012 local myMarker = createMarker(2489.1613769531, -1668.5617675781, 11.800, 'cylinder', 2.2, 255, 0, 0, 150) function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) if elementType == "player" then setPedOnFire ( hitElement, true ) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) You're using root element in setPedOnFire, which will affect all the players. Aaah oke, thx for answer so fast and alot thx for fix this, now i learn a litte more about marker and root element. THX Alpha Link to comment
S3M Posted March 23, 2012 Author Share Posted March 23, 2012 local myMarker = createMarker(2489.1613769531, -1668.5617675781, 11.800, 'cylinder', 2.2, 255, 0, 0, 150) function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) if elementType == "player" then setPedOnFire ( hitElement, true ) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) You're using root element in setPedOnFire, which will affect all the players. Oke now that works hehehe can you make it that if player stay in marker that player stay onfire. Becouse if now stay on marker player goes onfire one time. Link to comment
Castillo Posted March 23, 2012 Share Posted March 23, 2012 You'll have to make a timer to set him on fire again. You must use: setTimer isElementWithinMarker setPedOnFire Link to comment
S3M Posted March 23, 2012 Author Share Posted March 23, 2012 You'll have to make a timer to set him on fire again.You must use: setTimer isElementWithinMarker setPedOnFire Testing them try copy paste try testing... and so on. But unfortunately am I unable to add that setTimer. Can you help me more on the way? Link to comment
drk Posted March 23, 2012 Share Posted March 23, 2012 Why are you unable to add that setTimer? LOL Link to comment
S3M Posted March 23, 2012 Author Share Posted March 23, 2012 Why are you unable to add that setTimer? LOL Now if you run into marker then you onfire one time, but the intention is that as a player in marker remains that he remains onfire. Link to comment
drk Posted March 23, 2012 Share Posted March 23, 2012 LOL? local myMarker = createMarker(2489.1613769531, -1668.5617675781, 11.800, 'cylinder', 2.2, 255, 0, 0, 150) addEventHandler ( "onMarkerHit", root, function ( g_Ped, m_Dim ) if ( source == myMarker and getElementType ( g_Ped ) == "player" ) then timer = setTimer ( setPedOnFire, 1000, 0, g_Ped, true ) end end ) addEventHandler ( "onMarkerLeave", root, function ( g_Ped, m_Dim ) if ( source == g_Ped and getElementType ( g_Ped ) == "player" ) then killTimer ( timer ) end end ) Link to comment
S3M Posted March 23, 2012 Author Share Posted March 23, 2012 LOL? local myMarker = createMarker(2489.1613769531, -1668.5617675781, 11.800, 'cylinder', 2.2, 255, 0, 0, 150) addEventHandler ( "onMarkerHit", root, function ( g_Ped, m_Dim ) if ( source == myMarker and getElementType ( g_Ped ) == "player" ) then timer = setTimer ( setPedOnFire, 1000, 0, g_Ped, true ) end end ) addEventHandler ( "onMarkerLeave", root, function ( g_Ped, m_Dim ) if ( source == g_Ped and getElementType ( g_Ped ) == "player" ) then killTimer ( timer ) end end ) Hahaha yes indeed LOL, it work but now wen i respawn after death by onfire, i stay on fire now. it dont stop. LOL burn for ever? Link to comment
Castillo Posted March 24, 2012 Share Posted March 24, 2012 local myMarker = createMarker(2489.1613769531, -1668.5617675781, 11.800, 'cylinder', 2.2, 255, 0, 0, 150) local burnTimers = { } function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) if ( elementType == "player" ) then setPedOnFire ( hitElement, true ) if ( isTimer ( burnTimers[ hitElement ] ) ) then killTimer ( burnTimers[ hitElement ] ) end burnTimers[ hitElement ] = setTimer ( setPedOnFire, 2000, 0, hitElement, true ) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) function MarkerLeave ( leaveElement ) local elementType = getElementType( leaveElement ) if ( elementType == "player" ) then if ( isTimer ( burnTimers[ leaveElement ] ) ) then killTimer ( burnTimers[ leaveElement ] ) end setPedOnFire ( leaveElement, false ) end end addEventHandler( "onMarkerLeave", myMarker, MarkerLeave ) addEventHandler ( "onPlayerSpawn", root, function ( ) if ( isTimer ( burnTimers[ source ] ) ) then killTimer ( burnTimers[ source ] ) end setPedOnFire ( source, false ) end ) addEventHandler ( "onPlayerQuit", root, function ( ) if ( isTimer ( burnTimers[ source ] ) ) then killTimer ( burnTimers[ source ] ) end end ) Link to comment
S3M Posted March 24, 2012 Author Share Posted March 24, 2012 local myMarker = createMarker(2489.1613769531, -1668.5617675781, 11.800, 'cylinder', 2.2, 255, 0, 0, 150) local burnTimers = { } function MarkerHit( hitElement, matchingDimension ) local elementType = getElementType( hitElement ) if ( elementType == "player" ) then setPedOnFire ( hitElement, true ) if ( isTimer ( burnTimers[ hitElement ] ) ) then killTimer ( burnTimers[ hitElement ] ) end burnTimers[ hitElement ] = setTimer ( setPedOnFire, 2000, 0, hitElement, true ) end end addEventHandler( "onMarkerHit", myMarker, MarkerHit ) function MarkerLeave ( leaveElement ) local elementType = getElementType( leaveElement ) if ( elementType == "player" ) then if ( isTimer ( burnTimers[ leaveElement ] ) ) then killTimer ( burnTimers[ leaveElement ] ) end setPedOnFire ( leaveElement, false ) end end addEventHandler( "onMarkerLeave", myMarker, MarkerLeave ) addEventHandler ( "onPlayerSpawn", root, function ( ) if ( isTimer ( burnTimers[ source ] ) ) then killTimer ( burnTimers[ source ] ) end setPedOnFire ( source, false ) end ) addEventHandler ( "onPlayerQuit", root, function ( ) if ( isTimer ( burnTimers[ source ] ) ) then killTimer ( burnTimers[ source ] ) end end ) It works now how it was intended, alot thx Solidsnake14 and Draken to help me. 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