Mann56 Posted August 14, 2015 Share Posted August 14, 2015 Hey guys, I have a bit of trouble when i want the marker to open where a car hit's it, it would trigger the gui. Server markercords = { {1944.58691, -1778.72266, 12.39060}, {1944.33765, -1773.98657, 12.39060}, {1944.48840, -1771.07495, 12.39060}, {1944.29260, -1767.30762, 12.38281}, } addEventHandler("onResourceStart",resourceRoot, function() for i, pos in ipairs(markercords) do local x,y,z = unpack(pos) fuelmarkers = createMarker(x,y,z,"cylinder",2,255,255,0,50) end end)h addEventHandler("onMarkerHit",fuelmarkers , function (thePlayer) if isElementWithinMarker(thePlayer,fuelmarker) then if isPedInVehicle(thePlayer) then triggerClientEvent(thePlayer,"showthedxGui",root) end end end ) Client: sx_ , sy_ = guiGetScreenSize () sx, sy = sx_/1366 , sy_/768 fuel = 100000 fuelprice = 3 vehfuel = 100 totvehfuel = 150 local veh = isPedInVehicle( localPlayer ) function drawRect ( thePlayer ) exports.topbarchat:sendClientMessage( "DOes COme",root,255,255,255,false,9) if veh == "true" then local getEngineState = getVehicleEngineState(tostring(veh)) end dxDrawRectangle(sx+420,sy+230,sx+470,sy+280,tocolor(0,0,0,150)) dxDrawText ( "Fuel Station" , sx+560, sy+235, sx+490, sy+235, tocolor ( 255, 255, 0, 255 ), 1, "bankgothic" ) dxDrawText("Total Fuel : " .. fuel .. "", sx+510,sy+290,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") dxDrawText("Price : $" .. fuelprice .. "", sx+510,sy+330,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") dxDrawText("Your Fuel : " .. vehfuel .."/"..totvehfuel.. "", sx+510,sy+370,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") if getEngineState == "true" then dxDrawText("Please switch off the engine", sx+510,sy+420,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") elseif getEngineState == "false" then dxDrawText("Press SPACE to refuel!", sx+510,sy+420,sx+500,sy+240,tocolor(255,255,255,255),1 ,"bankgothic") end end addEvent("showthedxGui",true) addEventHandler("showthedxGui",resourceRoot,function () exports.topbarchat:sendClientMessage( "Comes here?",root,255,255,255,true,9) addEventHandler("onClientRender",root,drawRect ) end ) Also i have another Question, do nested events work? Like the one i did in my client file , i have no idea if they work or not Note: The resource is still in development and it lacks some scripting but i want to proceed further only if this problem is fixed so i have no problem afterwards : > Thanks Link to comment
undefined Posted August 14, 2015 Share Posted August 14, 2015 markercords = { {1944.58691, -1778.72266, 12.39060}, {1944.33765, -1773.98657, 12.39060}, {1944.48840, -1771.07495, 12.39060}, {1944.29260, -1767.30762, 12.38281}, } addEventHandler("onResourceStart",resourceRoot, function() for i, pos in ipairs(markercords) do local x,y,z = unpack(pos) local marker = createMarker(x,y,z,"cylinder",2,255,255,0,50) addEventHandler("onMarkerHit", marker, markerHit) end end) function markerHit(thePlayer) if getElementType(thePlayer) ~= "player" then return end if isElementWithinMarker(thePlayer,source) then if isPedInVehicle(thePlayer) then triggerClientEvent(thePlayer,"showthedxGui",root) end end end Link to comment
Mann56 Posted August 14, 2015 Author Share Posted August 14, 2015 Thank you buddy it works : > I thought i should use the event in the loop but i thought maybe nested events won't work .. Nvm Thank you very much 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