nikitafloy Posted May 4, 2014 Share Posted May 4, 2014 Why I can not identify a marker for ID? (For colshape it worked fine.) function createFunc() for i, o in ipairs (markers) do marker = createMarker ( o[1],-1290.8, 1043.2, "cylinder", 0.3, 28, 239, 0, 160 ) setElementID ( marker, 'do_' .. i ) setElementInterior( marker, 2 ) end end addEventHandler( "onResourceStart", resourceRoot, createFunc ) function jobFactory( hitElement, matchingDimension ) for i=1, #markers do if isElementWithinMarker ( hitElement, getElementByID( 'do_' .. i ) ) then outputChatBox('Да') end end end addEventHandler( 'onMarkerHit', resourceRoot, jobFactory ) Link to comment
nikitafloy Posted May 4, 2014 Author Share Posted May 4, 2014 Done differently debag writes nothing but event does not fire. function createFunc() for i, o in ipairs (markers) do markerDo = createMarker ( o[1],-1290.8, 1043.2, "cylinder", 1, 28, 239, 0, 160 ) setElementID ( markerDo, 'do_' .. i ) setElementInterior( markerDo, 2 ) end addEventHandler( 'onMarkerHit', markerDo, jobFactory ) end addEventHandler( "onResourceStart", getRootElement(), createFunc ) function jobFactory( hitElement, matchingDimension ) for i=1, #markers do if isElementWithinMarker ( hitElement, getElementByID( 'do_' .. i ) ) then outputChatBox('Да') end end end Link to comment
nikitafloy Posted May 4, 2014 Author Share Posted May 4, 2014 Here's the error: When I change the interior marker event does not fire. What should I do? Use colshape, or to create a marker? Or you can fix this problem in another way? Link to comment
TAPL Posted May 17, 2014 Share Posted May 17, 2014 function createFunc() for i, o in ipairs (markers) do markerDo = createMarker(o[1], -1290.8, 1043.2, "cylinder", 1, 28, 239, 0, 160) addEventHandler("onMarkerHit", markerDo, jobFactory) setElementID(markerDo, "do_"..i) setElementInterior(markerDo, 2) end end addEventHandler("onResourceStart", resourceRoot, createFunc) function jobFactory(hitElement, matchingDimension) for i=1, #markers do if isElementWithinMarker(hitElement, getElementByID("do_"..i)) then outputChatBox('Да') end end end Link to comment
nikitafloy Posted May 17, 2014 Author Share Posted May 17, 2014 Does not work. I create two markers, the one who, without interior - have triggered the handler. But that's not all. Marker works only through a special procedure: On Editor, move to interior, Editor disable, restart the script. When it works, then stop working on other handlers markers. for i, o in ipairs (markers) do markerDo = createMarker ( o[1],-1290.8, 1043.2, "cylinder", 1, 28, 239, 0, 160 ) local mDo = createMarker ( o[1],-1290.8, 1043.2, "cylinder", 0.3, 28, 239, 0, 160 ) setElementInterior( mDo, 2 ) setElementID ( markerDo, 'do_' .. i ) setElementID ( mDo, 'doMarker_' .. i ) addEventHandler( "onMarkerHit", markerDo, jobFactory ) end Link to comment
TAPL Posted May 17, 2014 Share Posted May 17, 2014 I don't even get why you use the element id, show your full code and what are you trying to do. Link to comment
nikitafloy Posted May 17, 2014 Author Share Posted May 17, 2014 I don't even get why you use the element id, show your full code and what are you trying to do. Use for identification. function facJob( hitElement, matchingDimension ) outputDebugString('1') for i=1, #markers do if isElementWithinMarker ( hitElement, getElementByID( 'do_' .. i ) ) then local x,y,z = getElementPosition(getElementByID( 'do_' .. i )) setElementVisibleTo ( getElementByID( 'doMarker_' .. i ), root, false ) setTimer ( setElementVisibleTo, 26000, 1, getElementByID( 'do_' .. i ), root, true ) spawnPlayer ( hitElement, x,y-0.3,z, 180, getElementModel( hitElement ), 2, 0 ) setCameraTarget ( hitElement ) factoryDo = createObject( 3016, x,y-1,z+1 ) setElementInterior( factoryDo, 2 ) triggerClientEvent( 'getBone', hitElement, client ) end end end Link to comment
TAPL Posted May 17, 2014 Share Posted May 17, 2014 I don't even get why you use the element id, show your full code and what are you trying to do. Link to comment
nikitafloy Posted May 17, 2014 Author Share Posted May 17, 2014 I don't even get why you use the element id, show your full code and what are you trying to do. http://pastebin.com/0nEiLp0y Link to comment
TAPL Posted May 17, 2014 Share Posted May 17, 2014 I don't even get why you use the element id, show your full code and what are you trying to do. Use for identification. function facJob( hitElement, matchingDimension ) outputDebugString('1') for i=1, #markers do if isElementWithinMarker ( hitElement, getElementByID( 'do_' .. i ) ) then local x,y,z = getElementPosition(getElementByID( 'do_' .. i )) setElementVisibleTo ( getElementByID( 'doMarker_' .. i ), root, false ) setTimer ( setElementVisibleTo, 26000, 1, getElementByID( 'do_' .. i ), root, true ) spawnPlayer ( hitElement, x,y-0.3,z, 180, getElementModel( hitElement ), 2, 0 ) setCameraTarget ( hitElement ) factoryDo = createObject( 3016, x,y-1,z+1 ) setElementInterior( factoryDo, 2 ) triggerClientEvent( 'getBone', hitElement, client ) end end end Why you don't use source? Why you create two marker? Link to comment
nikitafloy Posted May 17, 2014 Author Share Posted May 17, 2014 Oh, yes. I can use source. Because event for marker with the interior > 0 does not work. And I must to restart permanently Editor, I do not know how it is related, but, thanks to this, the marker is determined 0th interior. ------ Dont work. for i, o in ipairs (markers) do mDo = createMarker ( o[1],-1290.8, 1043.2, "cylinder", 0.3, 28, 239, 0, 160 ) addEventHandler( "onMarkerHit", mDo, facJob ) setElementInterior( mDo, 2 ) end function facJob( hitElement, matchingDimension ) -- изготовление деталей outputDebugString('1') -- dont write to debug. for i=1, #markers do ... end end --------------- You can see what's wrong. 1) I rise on a marker and nothing happens. 2) Start editor. 3) Stop editor and restart script. 4) I teleported to a place in front of me there was a box. Thereafter, neither the marker is no longer working. All have to repeat with the second point. Sorry for translate. http://video.yandex.ru/iframe/nikita505 ... gskv.1631/ Link to comment
TAPL Posted May 17, 2014 Share Posted May 17, 2014 The problem from the marker size it too small, try increase it. Link to comment
nikitafloy Posted May 17, 2014 Author Share Posted May 17, 2014 The problem from the marker size it too small, try increase it. Increased and lifted. Stop......I'm shocked. Why did it work now? After all, I considered such a stupid mistake. So much time lost. Thank you for your patience. Link to comment
nikitafloy Posted May 18, 2014 Author Share Posted May 18, 2014 Dont work again: Current part of code: function createMaks() for i, o in ipairs (markReady) do mReady = createMarker ( o[1],o[2], 1043.3, "cylinder", 2, 255,0,0, 100 ) addEventHandler( "onMarkerHit", mReady, stayRead ) setElementInterior( mReady, 2 ) end addEventHandler( "onResourceStart", resourceRoot, createMaks ) function stayRead( hitElement ) outputDebugString('0') local attachE = getAttachedElements ( hitElement ) if attachE then for _, k in ipairs (attachE) do if getElementType (k) == 'Object' then if getElementModel (k) == 3016 then destroyElement ( factoryDo ) for i=1, #markReady do if isElementWithinMarker ( hitElement, source ) then local x,y,z = getElementPosition( source ) createObject( 3016, x,y-1,z+1 ) end end end end end for i=1, #GTAupr do toggleControl ( hitElement, GTAupr[i], true ) end end end Link to comment
TAPL Posted May 18, 2014 Share Posted May 18, 2014 Why the hell you use this shit? for i=1, #markReady do if isElementWithinMarker ( hitElement, source ) then Link to comment
nikitafloy Posted May 18, 2014 Author Share Posted May 18, 2014 Why the hell you use this :~? for i=1, #markReady do if isElementWithinMarker ( hitElement, source ) then Do not use after the change to source (marker). The script did not work right when I start the server and teleported with editor. Now until everything works, I'm working on the script. Try to restart the server and include the resource again later. 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