Jump to content

[HELP] Another player is already with the window open


[M]ister

Recommended Posts

Hello, I created a script that when a player enter the marker one gui opens, I wanted if another player is trying to access window , it can not and a message appears saying that it can not because there is already a player with the window open

local marker = createMarker( -2631, 1377, 6, "Cylinder", 0.8, 0, 0, 255, 150) 
  
window = guiCreateWindow(400,400,400,264,"Panel Edit", false) 
guiSetVisible(window, false) 
Close = guiCreateButton(365, 10, 25, 25, "X", false, window) 
guiSetFont(Close, 'sans') 
  
addEventHandler ( "onClientGUIClick", root, function ( ) 
    if ( source == Close ) then 
        guiSetVisible ( window, false ) 
        showCursor ( false ) 
    end 
end) 
  
addEventHandler("onClientMarkerHit", marker, function (hitElement) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
        if not guiGetVisible(window) then 
            guiSetVisible(window, true) 
            showCursor(true) 
        end 
    end 
end) 

Link to comment

Please me more information ?

Client:

window = guiCreateWindow(400,400,400,264,"Panel Edit", false) 
guiSetVisible(window, false) 
Close = guiCreateButton(365, 10, 25, 25, "X", false, window) 
guiSetFont(Close, 'sans') 
  
addEventHandler ( "onClientGUIClick", root, function ( ) 
    if ( source == Close ) then 
        guiSetVisible ( window, false ) 
        showCursor ( false ) 
    end 
end) 
  
addEvent("enterMarker", true) 
addEventHandler("enterMarker", root, function () 
    if not guiGetVisible(window) then 
        guiSetVisible(window, true) 
        showCursor(true) 
    end 
end) 

Server:

local marker = createMarker( -2625, 1380, 7, "cylinder", 0.8, 0, 0, 255, 150) 
  
addEventHandler( "onMarkerHit", marker, function(hitElement) 
    if getElementType(hitElement) == "player" then 
        triggerClientEvent(root, "enterMarker", source) 
    end 
end) 

Link to comment
local marker = createMarker ( -2625, 1380, 7, "cylinder", 0.8, 0, 0, 255, 150 ) 
local playerInside = false 
  
addEventHandler ( "onMarkerHit", marker, 
    function ( hitElement ) 
        if ( getElementType ( hitElement ) == "player" ) then 
            if ( not playerInside ) then 
                triggerClientEvent ( hitElement, "enterMarker", hitElement ) 
                playerInside = true 
            end 
        end 
    end 
) 
  
addEventHandler ( "onMarkerLeave", marker, 
    function ( hitElement ) 
        if ( getElementType ( hitElement ) == "player" ) then 
            playerInside = false 
        end 
    end 
) 

Link to comment
local marker = createMarker ( -2625, 1380, 7, "cylinder", 0.8, 0, 0, 255, 150 ) 
  
addEventHandler ( "onMarkerHit", marker, 
    function ( hitElement ) 
        if ( getElementType ( hitElement ) == "player" ) then 
            if ( #getElementsWithinColShape ( getElementColShape ( source ), "player" ) == 1 ) then 
                triggerClientEvent ( hitElement, "enterMarker", hitElement ) 
            end 
        end 
    end 
) 

Try that one instead.

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...