GUI Starting Bug

Recommended Posts

I made a simple GUI to warp player (It's not yet completed) but the thing is, I made it so like, It is only opened whenever it is used and does not stays open in the background.

The problem is, if you just logged in, you will have to step inside the marker twice, Eg > You logged in > You hit the marker for the first time and it won't open, but when you hit the marker for the second time, it will open imminently,  and then again if you reconnect or logout it happens again, why is that so? I don't understand what wrong code I have made.


function MakeJPanel()
	if (JoinPanel) then
		return true
	local screenW, screenH = guiGetScreenSize()
	JoinPanel = guiCreateWindow((screenW - 665) / 2, (screenH - 350) / 2, 665, 350, "Welcome To The MTA Server!", false)
	guiWindowSetSizable(JoinPanel, false)
	guiSetProperty(JoinPanel, "CaptionColour", "FFD1039E")

	WelcomeLable = guiCreateLabel(8, 19, 647, 60, "Blah BLah", false, JoinPanel)
	guiLabelSetColor(WelcomeLable, 150, 251, 89)
	LSClothButton = guiCreateButton(155, 164, 112, 22, "Cloth Shop", false, JoinPanel)
	guiSetProperty(LSClothButton, "NormalTextColour", "FFAAAAAA")
	LSVehicleButton = guiCreateButton(399, 164, 112, 22, "Vehicle Shop", false, JoinPanel)
	guiSetProperty(LSVehicleButton, "NormalTextColour", "FFAAAAAA")
	LVbutton = guiCreateButton(277, 132, 112, 22, "LV", false, JoinPanel)
	guiSetProperty(LVbutton, "NormalTextColour", "FF9B0DA7")
	LSButton = guiCreateButton((665 - 112) / 2, (350 - 22) / 2, 112, 22, "LS", false, JoinPanel)
	guiSetProperty(LSButton, "NormalTextColour", "FF1122A2")
	SFButton = guiCreateButton(277, 196, 112, 22, "SF", false, JoinPanel)
	guiSetProperty(SFButton, "NormalTextColour", "FFE9F038")
	CloseButton = guiCreateButton(296, 320, 73, 20, "Close", false, JoinPanel)
	guiSetProperty(CloseButton, "NormalTextColour", "FFAAAAAA")
	InfoLable = guiCreateLabel(9, 228, 646, 85, "Blah Blah", false, JoinPanel)
	guiLabelSetColor(InfoLable, 255, 0, 0)
	addEventHandler("onClientGUIClick", CloseButton, closeJGUI, false)

function openJPanel()
	if (not JoinPanel) then
	local visible = not guiGetVisible(JoinPanel)
	guiSetVisible(JoinPanel, visible)
addEvent("startJPanel", true)
addEventHandler("startJPanel", localPlayer, openJPanel)

function closeJGUI(button)
	if (button ~= "left") then
		return false


local theMarker = createMarker(497.16632080078, -75.45479309082, 997.7378125, "cylinder", 1.6, 0, 120, 200, 255)

function Markers()
	setElementDimension(theMarker, 99)
	setElementInterior(theMarker, 11)
addEventHandler("onResourceStart", resourceRoot, Markers)

function openJGUI(client)
	if (isGuestAccount(getPlayerAccount(client))) then
		return false
	if (getElementDimension(client) ~= 99 or getElementInterior(client) ~= 11) then
		return false
	triggerClientEvent(client, "startJPanel", client)
addEventHandler("onMarkerHit", theMarker, openJGUI)


Share this post

Link to post

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.