Jump to content

[HELP] Another player is already with the window open


[M]ister

Recommended Posts

Posted

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) 

Posted

You should create the marker server side, because if you do it client side, it won't be easy to do what you want.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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) 

Posted
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 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Should be working, yes.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Copy the last code again.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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