Jump to content

[HELP] onMarkerHit Open Gui Only 1 Player


Whizz

Recommended Posts

This script that I created is shown to all players GUi. But I want it to be shown for the player who entered the marker.

pls Helpme.

 

Marker = createMarker(  1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0)
function openwindow(thePlayer)
    triggerClientEvent("opengui1window", thePlayer, thePlayer)
end
addEventHandler("onMarkerHit", Marker, openwindow)
Link to comment
16 hours ago, alex17" said:
Marker = createMarker(  1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0)
function openwindow(thePlayer)
    triggerClientEvent(thePlayer,"opengui1window", thePlayer, thePlayer)
end
addEventHandler("onMarkerHit", Marker, openwindow)

 

I did it. But it didn't work out right.

Link to comment
40 minutes ago, Commonist said:

I did it. But it didn't work out right.

Marker = createMarker(  1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0)
function openwindow(thePlayer)
  	local elementType = getElementType(thePlayer)
  	if elementType == "player" then 
    triggerClientEvent(thePlayer,"opengui1window", thePlayer)
    end 
end
addEventHandler("onMarkerHit", Marker, openwindow)

 

Link to comment
On 11/09/2023 at 22:02, FlorinSzasz said:
Marker = createMarker(  1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0)
function openwindow(thePlayer)
  	local elementType = getElementType(thePlayer)
  	if elementType == "player" then 
    triggerClientEvent(thePlayer,"opengui1window", thePlayer)
    end 
end
addEventHandler("onMarkerHit", Marker, openwindow)

 

Hello friends. Could this be the problem؟

addEventHandler("onClientMarkerHit",resourceRoot,
    function(thePlayer)
        dm_window = guiCreateWindow(0.1556,0.1597,0.6375,0.6944,"Team-Panel",true)
        grove_button = guiCreateButton(10,108,162,165,"Team-1",false,dm_window)
        police_button = guiCreateButton(285,108,162,165,"Team-2",false,dm_window)
        teams_label = guiCreateLabel(159,44,145,47,"",false,dm_window)
        showCursor(true)
    end
)
Link to comment

It is not necessary to create the marker on the server and then do a trigger, it can work perfectly if you do everything on the client

Marker = createMarker(  1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0)


addEventHandler("onClientMarkerHit", Marker,
    function(element, dim)
        if element == localPlayer and dim then
           if not dm_window then 
             dm_window = guiCreateWindow(0.1556,0.1597,0.6375,0.6944,"Team-Panel",true)
             grove_button = guiCreateButton(10,108,162,165,"Team-1",false,dm_window)
             police_button = guiCreateButton(285,108,162,165,"Team-2",false,dm_window)
             teams_label = guiCreateLabel(159,44,145,47,"",false,dm_window)
           else 
              guiSetVisible(dm_window, true)
           end 
           showCursor(true)
        end 
    end
)

But if you still want to continue doing it with a server to client trigger, I'll leave you how to do it

server

Marker = createMarker(  1508.814453125 , -1144.19921875 , 140.93536376953, "cylinder", 1, 255, 0, 0)
function openwindow(thePlayer, dim)
   local elementType = getElementType(thePlayer)
   if elementType == "player" and dim then 
      triggerClientEvent(thePlayer,"opengui1window", thePlayer)
   end 
end
addEventHandler("onMarkerHit", Marker, openwindow)

client

addEvent("opengui1window", true)
addEventHandler("opengui1window", root, 
   function()
      if not dm_window then 
         dm_window = guiCreateWindow(0.1556,0.1597,0.6375,0.6944,"Team-Panel",true)
         grove_button = guiCreateButton(10,108,162,165,"Team-1",false,dm_window)
         police_button = guiCreateButton(285,108,162,165,"Team-2",false,dm_window)
         teams_label = guiCreateLabel(159,44,145,47,"",false,dm_window)
      else 
         guiSetVisible(dm_window, true)
      end 
      showCursor(true)
   end
)

 

  • Thanks 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...