Sorata_Kanda Posted August 29, 2018 Share Posted August 29, 2018 Hey everyone, whenever I start my resource, I'm not able to click on any GUI buttons, nor on the Admin, nor can I bring up the GUI through "onClientClick". What I want to do is to make a GUI appear whenever I click on a certain ped. These peds are listed in the .map file as well. -- This is client-sided -- Ped godmode local bsGirls = { getElementByID("burgershotGirl"), getElementByID("burgershotDowntownGirl"), getElementByID("burgershotJuniperGirl") } function noDamage() cancelEvent() end function addGodmode() for k, v in ipairs(bsGirls) do addEventHandler( "onClientPedDamage", v, noDamage ) end end addGodmode() GUIRestaurants = { button = {}, window = {}, label = {} } function createGUI() GUIRestaurants.window[1] = guiCreateWindow(475, 259, 350, 208, "Burger Shot - Order", false) guiWindowSetSizable(GUIRestaurants.window[1], false) GUIRestaurants.label[1] = guiCreateLabel(28, 22, 294, 47, "Welcome to Burger Shot!\nChoose one of our delicious meals.", false, GUIRestaurants.window[1]) guiLabelSetHorizontalAlign(GUIRestaurants.label[1], "center", false) guiLabelSetVerticalAlign(GUIRestaurants.label[1], "center") GUIRestaurants.button[1] = guiCreateButton(17, 84, 143, 36, "Heart Stopper\n$50", false, GUIRestaurants.window[1]) GUIRestaurants.button[2] = guiCreateButton(17, 130, 143, 36, "Money Shot Deal\n$45", false, GUIRestaurants.window[1]) GUIRestaurants.button[3] = guiCreateButton(189, 84, 143, 36, "Bleeder Meel\n$25", false, GUIRestaurants.window[1]) GUIRestaurants.button[4] = guiCreateButton(189, 130, 143, 36, "Low Key Salad\n$20", false, GUIRestaurants.window[1]) GUIRestaurants.button[5] = guiCreateButton(101, 178, 149, 20, "Close", false, GUIRestaurants.window[1]) -- Close button addEventHandler("onClientGUIClick", GUIRestaurants.button[5], function() showCursor(false) destroyElement(GUIRestaurants) end, false) -- Heart Stopper addEventHandler( "onClientGUIClick", GUIRestaurants.button[1], function() if payPrice( 50 ) then setElementHealth(getLocalPlayer(), getElementHealth(getLocalPlayer()) + 45) else outputChatBox("You don't have enough money.") end end, false) -- Money Shot Deal addEventHandler( "onClientGUIClick", GUIRestaurants.button[2], function() if payPrice( 45 ) then setElementHealth(getLocalPlayer(), getElementHealth(getLocalPlayer()) + 35) else outputChatBox("You don't have enough money.") end end, false) -- Bleeder Meel addEventHandler( "onClientGUIClick", GUIRestaurants.button[3], function() if payPrice( 25 ) then setElementHealth(getLocalPlayer(), getElementHealth(getLocalPlayer()) + 25) else outputChatBox("You don't have enough money.") end end, false) -- Low Key Salad addEventHandler( "onClientGUIClick", GUIRestaurants.button[4], function() if payPrice( 20 ) then setElementHealth(getLocalPlayer(), getElementHealth(getLocalPlayer()) + 15) else outputChatBox("You don't have enough money.") end end, false) end function openGUI( button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement ) outputDebugString("Yes") if clickedElement then outputDebugString("Yes") for k, v in ipairs(bsGirls) do if clickedElement == v then createGUI() end end end end addEventHandler("onClientClick", getRootElement(), openGUI) function payPrice( price ) local money = getPlayerMoney() if money < price then return false else local newMoney = money - price setPlayerMoney(newMoney) return true end end As you can also see in function openGUI() I added outputDebugString("") but nothing is even put out. What did I do wrong? Thanks in advance. Link to comment
Sorata_Kanda Posted August 29, 2018 Author Share Posted August 29, 2018 Okay, I managed to fix the issue. There was an invisible GUI blocking the screen. However, when I click on the ped, the GUI opens twice. And when I click outside of the GUI, I can't focus them anymore. Link to comment
Sorata_Kanda Posted August 29, 2018 Author Share Posted August 29, 2018 That issue's fixed too by simply adding get/setElementData. Still curious why it is created twice and not once. Now there's a focusing problem. When I click outside the GUI, I can't use it anymore. But when I start guieditor and then open that ped GUI, I can move it and re-focus it just fine. Link to comment
Sorata_Kanda Posted August 29, 2018 Author Share Posted August 29, 2018 Topic can be closed now. Issue was in a other script file which has a pre-created label that might have blocked me from using the GUI. Link to comment
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