Booms Posted April 30, 2020 Share Posted April 30, 2020 (edited) The problem with it : It writes the outputChatBox as many times as I enter to the marker. local sX, sY = guiGetScreenSize(); local pX, pY = 1920, 1080; local fuelMarker = createMarker(-2524.38452, -618.74219, 130.65250, "cylinder", 2, 0, 0, 100, 175); CPosX = 778; function rajz() benzin = math.floor(((312*((CPosX-804)/312))+26)/3.02) dxDrawRectangle(762/pX*sX, 400/pY*sY, 396/pX*sX, 300/pY*sY, tocolor(0, 0, 0, 200), false); dxDrawRectangle(802/pX*sX, 500/pY*sY, 316/pX*sX, 30/pY*sY, tocolor(142, 147, 140, 200), false); dxDrawRectangle(804/pX*sX, 502/pY*sY, (312*((CPosX-804)/312))+26/pX*sX, 26/pY*sY, tocolor(73, 82, 140, 200), false); dxDrawRectangle(842/pX*sX, 630/pY*sY, 236/pX*sX, 50/pY*sY, tocolor(183, 86, 67, 200), false); dxDrawRectangle(842/pX*sX, 560/pY*sY, 236/pX*sX, 50/pY*sY, tocolor(51, 153, 48, 200), false); dxDrawText("Mégse",842/pX*sX, 630/pY*sY, 1078/pX*sX, 680/pY*sY, tocolor(250, 250, 250, 250), 1.1,"default", "center","center", false,false,false,true); dxDrawText("Fizetés", 842/pX*sX, 560/pY*sY, 1078/pX*sX, 610/pY*sY, tocolor(250, 250, 250, 250), 1.1,"default", "center","center", false,false,false,true); dxDrawText(benzin.." liter".." = "..((math.floor(((312*((CPosX-804)/312))+26)/3.02))*3).." $",802/pX*sX, 440/pY*sY, 1118/pX*sX, 470/pY*sY, tocolor(39, 194, 182, 250), 1.5,"default", "center","center", false,false,false,true); dxDrawText("Fizetendő:",802/pX*sX, 400/pY*sY, 1118/pX*sX, 450/pY*sY, tocolor(84, 89, 118, 250), 1.5,"default-bold", "center","center", false,false,false,true); dxDrawText(benzin.." liter", 802/pX*sX, 500/pY*sY, 1118/pX*sX, 530/pY*sY, tocolor(250, 250, 250, 250), 1.1,"default", "center","center", false,false,false,true); showCursor(true); end function asd (hitPlayer, mDim) if (mDim) then if (source == fuelMarker) then if (hitPlayer == localPlayer) then local vehicle = getPedOccupiedVehicle(hitPlayer); if (vehicle) then local seat = getPedOccupiedVehicleSeat(hitPlayer); if (seat == 0) then setElementFrozen(hitPlayer, true); setElementFrozen(vehicle, true); addEventHandler("onClientRender", root, rajz); addEventHandler("onClientClick", root, function(button, state) if button == "left" then if state == "up" then if isInSlot(804/pX*sX, 502/pY*sY, 312/pX*sX, 26/pY*sY) then CPosX, CPosY = getCursorPosition() CPosX, CPosY = CPosX*sX, CPosY*sY if (CPosX <= 778) then CPosX = 778; elseif (CPosX >= 1116) then cPosX = 1; end end end end end ); addEventHandler("onClientKey",root, function(key,state) if state then if isCursorShowing() then if key == "mouse1" then if isInSlot(842/pX*sX, 630/pY*sY, 236/pX*sX, 50/pY*sY) then removeEventHandler("onClientRender", root, rajz); showCursor(false); local vehicle = getPedOccupiedVehicle(hitPlayer); setElementFrozen(hitPlayer, false); setElementFrozen(vehicle, false); CPosX = 778; elseif isInSlot(842/pX*sX, 560/pY*sY, 236/pX*sX, 50/pY*sY) then local vehicle = getPedOccupiedVehicle(hitPlayer); local fuel = getElementData(vehicle, "fuel"); local fizetendo = ((math.floor(((312*((CPosX-804)/312))+26)/3.02))*3); local lesz = fuel + (fizetendo/3) ir = 1; if ((fizetendo/3) > 0) then ir = 0; ir2 = 1; if (lesz <= 100) then ir2 = 0; ir3 = 1; local pMoney = getPlayerMoney(localPlayer); if (pMoney >= fizetendo) then ir3 = 0; showCursor(false); removeEventHandler("onClientRender", root, rajz); setTimer( function() local vehicle = getPedOccupiedVehicle(hitPlayer); setElementFrozen(hitPlayer, false); setElementFrozen(vehicle, false); triggerServerEvent("fizetes", resourceRoot, benzin); outputChatBox("#FFFFFF[Szerver]: A jármű megtankolva!#AAAAAA Levonunk tőled "..fizetendo.."$-t a tankolásra!", 0, 0, 0, true); end, (1000)*(fizetendo/3),1); CPosX = 778; elseif (ir3 == 1) then setTimer( function() outputChatBox("#FFFFFF[Szerver]:#FF0000 Nincs ennyi pénzed!", 0, 0, 0, true); ir3 = 0; return; end ,300,1); end elseif (ir2 == 1) then setTimer( function() outputChatBox("#FFFFFF[Szerver]:#FF0000 Nem fér bele ennyi benzin a kocsidba!", 0, 0, 0, true); ir2 = 0; return; end ,300,1); end elseif (ir == 1) then setTimer( function() outputChatBox("#FFFFFF[Szerver]:#FF0000 Nem adtad meg a tankolni kívánt mennyiséget!", 0, 0, 0, true); ir = 0; return; end ,300,1); end end end end end end ); end end end end end end addEventHandler("onClientMarkerHit", root, asd); function isInSlot(x, y, w, h) if isCursorShowing() then cPosX, cPosY = getCursorPosition() cPosX, cPosY = cPosX*sX, cPosY*sY if ( (cPosX > x) and (cPosY > y) and (cPosX < x+w) and (cPosY < y+h) ) then return true else return false end end end Edited April 30, 2020 by Booms Link to comment
Hydra Posted May 1, 2020 Share Posted May 1, 2020 do a separate function with the onClientClick event and set it to activate when you enter the marker and disappear when you exit the marker Example: function testButton() if isMouseInPosition(button coordinates) then outputChatBox("Clicked", 0, 255, 0, true) end end function markerTestEnter(hitPlayer, matchingDimension) addEventHandler("onClientClick", getRootElement(), testButton) end addEventHandler("onClientMarkerHit", yourMarker, markerTestEnter) function markerTestLeave(leavingPlayer, matchingDimension) removeEventHandler("onClientClick", getRootElement(), testButton) end addEventHandler("onClientMarkerHit", yourMarker, markerTestLeave) 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