scolen Posted April 8, 2023 Posted April 8, 2023 getJobMarker = createMarker(872.03754, -29.07278, 62.3000, "cylinder", 1.0, 0, 255, 255, 255, getRootElement()) ped = createPed(159, 872.92389, -27.08743, 63.94565, 160) setPedFrozen(ped, true) blip = createBlipAttachedTo(getJobMarker, 56) function hitMarkerWindow() window = guiCreateWindow(0.35, 0.35, 0.35, 0.30, "wood job", true) memo = guiCreateMemo(0.10, 0.20, 0.80, 0.4, "this is wood cutting job", true, window) accept = guiCreateButton(0.10, 0.75, 0.22, 0.14, "Accept Job", true, window) leave = guiCreateButton(0.35, 0.75, 0.22, 0.14, "Leave Job", true, window) close = guiCreateButton(0.60, 0.75, 0.22, 0.14, "Close", true, window) showCursor(true) guiMemoSetReadOnly(memo, true) end addEventHandler("onClientMarkerHit", getJobMarker, hitMarkerWindow) function clientClick() if source == close then guiSetVisible(window, false) showCursor(false) triggerServerEvent("cancelButton", resourceRoot, localPlayer) elseif source == accept then guiSetVisible(window, false) showCursor(false) triggerServerEvent("acceptWoodJob", resourceRoot, localPlayer) elseif source == leave then guiSetVisible(window, false) showCursor(false) triggerServerEvent("leaveJob", resourceRoot, localPlayer) end end addEventHandler("onClientGUIClick", root, clientClick)
Ciastuuś Posted April 9, 2023 Posted April 9, 2023 What's your problem? The script works fine. It loads the marker, the gui is loaded, all buttons in it work and trigger.
scolen Posted April 9, 2023 Author Posted April 9, 2023 9 hours ago, Ciastuuś said: What's your problem? The script works fine. It loads the marker, the gui is loaded, all buttons in it work and trigger. If a player hits this marker, every player on the same server will start working. What I want to do is to make it work only for the player who hits the marker. How to fix this?
Ciastuuś Posted April 10, 2023 Posted April 10, 2023 You must specify the player who entered the marker, not the entire server.
scolen Posted April 10, 2023 Author Posted April 10, 2023 6 hours ago, Ciastuuś said: You must specify the player who entered the marker, not the entire server. How to do it?
Addlibs Posted April 10, 2023 Posted April 10, 2023 addEventHandler("onClientMarkerHit", getJobMarker, hitMarkerWindow) -- should be changed to addEventHandler("onClientMarkerHit", getJobMarker, function(hitPlayer, matchingDimension) if (hitPlayer == localPlayer and matchingDimension) then hitMarkerWindow() end end ) This protects the window from being created when any element hits the marker, instead only triggering if the element that hits the marker is the client that is running this client-side script.
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