iFoReX Posted June 7, 2012 Share Posted June 7, 2012 I want get the state of the job MedicB = {} MedicB[1] = guiCreateButton(551,189,199,42,"Si deseo hacerlo",false) guiSetVisible(MedicB[1],false) guiSetAlpha(MedicB[1],0) MedicB[2] = guiCreateButton(551,242,199,42,"No gracias",false) guiSetVisible(MedicB[2],false) guiSetAlpha(MedicB[2],0) CancelB = {} CancelB[1] = guiCreateButton(0.4375,0.3967,0.1047,0.0383,"Cancelar Job",true) guiSetVisible(CancelB[1],false) guiSetAlpha(CancelB[1],0) CancelB[2] = guiCreateButton(0.4359,0.48,0.0672,0.04,"Cerrar",true) guiSetVisible(CancelB[2],false) guiSetAlpha(CancelB[2],0) function cancelDX() dxDrawText("Cerrar !",568.0,292.0,692.0,310.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawText("Cancelar job !",568.0,243.0,692.0,261.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawText("Cancelar Job",408.0,170.0,631.0,200.0,tocolor(255,255,255,255),1.0,"bankgothic","left","top",false,false,true) dxDrawRectangle(428.0,185.0,461.0,211.0,tocolor(0,0,0,200),false) end function ambulanceDX() dxDrawText("No , Gracias !",558.0,250.0,743.0,277.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawRectangle(552.0,244.0,196.0,40.0,tocolor(0,0,0,200),false) dxDrawText("Si, deseo hacerlo !",558.0,194.0,742.0,226.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawRectangle(551.0,189.0,199.0,43.0,tocolor(0,0,0,220),false) dxDrawText("ambulancia ?",438.0,109.0,598.0,139.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawText("Hola amigo, quieres trabajar conduciendo la",437.0,91.0,816.0,108.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawRectangle(429.0,86.0,419.0,329.0,tocolor(0,0,0,200),false) end medicPed = createPed( 70, -2655.1479492188, 640.16479492188, 14.454549789429) setElementRotation(medicPed, 0, 0, 180) medicMarker = createMarker( -2655.0856933594, 639.46484375, 13.5, "cylinder", 1, 255,255,255, 100 ) function markerHit (hitPlayer) if ( hitPlayer == localPlayer ) then addEventHandler("onClientRender",root, ambulanceDX) guiSetVisible(MedicB[1],true) guiSetVisible(MedicB[2],true) showCursor (true) end end addEventHandler ("onClientMarkerHit", medicMarker, markerHit) function markerHit2 (hitPlayer) if ( hitPlayer == localPlayer ) then addEventHandler("onClientRender",root, cancelDX) guiSetVisible(CancelB[1],true) guiSetVisible(CancelB[2],true) showCursor (true) end end addEventHandler("onClientGUIClick", root, function() if source == MedicB[2] then removeEventHandler("onClientRender",root, ambulanceDX) guiSetVisible(MedicB[1],false) guiSetVisible(MedicB[2],false) showCursor(false) elseif source == MedicB[1] then local state = 'true' setElementData(localPlayer,"DoingJob",state) elseif getElementData(localPlayer,"DoingJob") == state then removeEventHandler("onClientMarkerHit", medicMarker, markerHit) addEventHandler("onClientMarkerHit", medicMarker, markerHit2) end end ) addCommandHandler("false", function() showCursor(false) end ) addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() local state = 'false' setElementData(localPlayer,"DoingJob",state) if getElementData(localPlayer,"DoingJob") == state then addEventHandler("onClientMarkerHit", medicMarker, markerHit) end end ) Link to comment
naz19 Posted June 9, 2012 Share Posted June 9, 2012 addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function() local state = 'false' setElementData(localPlayer,"DoingJob",state) if getElementData(localPlayer,"DoingJob") == state then addEventHandler("onClientMarkerHit", medicMarker, markerHit) end end ) why do u need it? as far as i know data which u had set via setElementData will be lost after u restart resource or player reconnect... anyway i'll come back to ur problem... so try add timer ( u r setting data and getting it in same moment, so when u r trying to get data there could not be that data ) : addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), function ( ) local state = 'false' setElementData ( localPlayer, "DoingJob", state ) setTimer ( function ( ) if getElementData ( localPlayer, "DoingJob" ) == state then addEventHandler ( "onClientMarkerHit", medicMarker, markerHit ) end end, 500, 1 ) end ) 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