Jump to content

onClientGUIClick problem, help!


Recommended Posts

Hi, i am sure this problem will be easy to solve, but i cannot do it by my self:

Im trying to make a simple panel, the simplest panel you will see ever... xD this panel got open when a player hit a marker, the panel have three buttons, and the problem it's no one works when got clicked, i dont know if it's a handler error (onClientGUIclick) or what the hell it's happenin here, the panel its triggered by another source (by serverside source, for markerHit) and works, the problem it's just the buttons... i tried and tried but nothing. Here's the client(Gui) code:

function pilotPanelOne () 
  
  
rWin = guiCreateWindow(472, 289, 158, 152, "Pilot Work", false) 
guiWindowSetSizable(rWin, false) 
leaveJob = guiCreateButton(12, 70, 136, 31, "Leave the job.", false, rWin) 
getJob = guiCreateButton(12, 29, 136, 31, "Get the job.", false, rWin) 
theClose = guiCreateButton(12, 111, 136, 31, "Close.", false, rWin) 
outputChatBox ("Works") 
showCursor (true) 
  
  
  
  
end 
addEvent ("pilotPanelOne", true) 
addEventHandler ("pilotPanelOne", getLocalPlayer(), pilotPanelOne) 
  
  
  
function whenPlayerClickToClose () 
    outputChatBox ("Works") 
    guiSetVisible (rWin, false) 
    showCursor (false) 
end 
addEventHandler ("onClientGUIClick", theClose, whenPlayerClickToClose) 
  
  

Yes, the code just handle one of the buttons, the button for close the panel, i'll not handle the other buttons until this one (theClose) works. Thank you all.

Link to comment

i think this should work

function pilotPanelOne () 
  
  
rWin = guiCreateWindow(472, 289, 158, 152, "Pilot Work", false) 
guiWindowSetSizable(rWin, false) 
leaveJob = guiCreateButton(12, 70, 136, 31, "Leave the job.", false, rWin) 
getJob = guiCreateButton(12, 29, 136, 31, "Get the job.", false, rWin) 
theClose = guiCreateButton(12, 111, 136, 31, "Close.", false, rWin) 
outputChatBox ("Works") 
showCursor (true) 
  
  
  
  
end 
addEvent ("pilotPanelOne", true) 
addEventHandler ("pilotPanelOne", getLocalPlayer(), pilotPanelOne) 
  
  
  
function whenPlayerClickToClose (button, state, absoluteX, absoluteY) 
    if ( source == theClose ) then 
    outputChatBox ("Works") 
    guiSetVisible (rWin, false) 
    showCursor (false) 
end 
addEventHandler ("onClientGUIClick", theClose, whenPlayerClickToClose) 
  
  

Link to comment
i think this should work
function pilotPanelOne () 
  
  
rWin = guiCreateWindow(472, 289, 158, 152, "Pilot Work", false) 
guiWindowSetSizable(rWin, false) 
leaveJob = guiCreateButton(12, 70, 136, 31, "Leave the job.", false, rWin) 
getJob = guiCreateButton(12, 29, 136, 31, "Get the job.", false, rWin) 
theClose = guiCreateButton(12, 111, 136, 31, "Close.", false, rWin) 
outputChatBox ("Works") 
showCursor (true) 
  
  
  
  
end 
addEvent ("pilotPanelOne", true) 
addEventHandler ("pilotPanelOne", getLocalPlayer(), pilotPanelOne) 
  
  
  
function whenPlayerClickToClose (button, state, absoluteX, absoluteY) 
    if ( source == theClose ) then 
    outputChatBox ("Works") 
    guiSetVisible (rWin, false) 
    showCursor (false) 
end 
addEventHandler ("onClientGUIClick", theClose, whenPlayerClickToClose) 
  
  

Continue without work... idk what is happenin here bro, this should be working... thank you for the try haha ;) It's the stupid - est bug i got ever scripting, console didn't explain me where's the problem too.. xD well ,lets wait for more solutions, thank you!

pd: You forgot the "end" for close "if" hehe

Link to comment

The event handler has to go inside "pilotPanelOne" function.

function pilotPanelOne ( )  
    rWin = guiCreateWindow(472, 289, 158, 152, "Pilot Work", false) 
    guiWindowSetSizable(rWin, false) 
    leaveJob = guiCreateButton(12, 70, 136, 31, "Leave the job.", false, rWin) 
    getJob = guiCreateButton(12, 29, 136, 31, "Get the job.", false, rWin) 
    theClose = guiCreateButton(12, 111, 136, 31, "Close.", false, rWin) 
    outputChatBox ("Works") 
    showCursor (true) 
    addEventHandler ("onClientGUIClick", theClose, whenPlayerClickToClose, false) -- Here 
end 
addEvent ("pilotPanelOne", true) 
addEventHandler ("pilotPanelOne", getLocalPlayer(), pilotPanelOne) 
  
function whenPlayerClickToClose (button, state, absoluteX, absoluteY) 
    outputChatBox ("Works") 
    guiSetVisible (rWin, false) 
    showCursor (false) 
end 

Link to comment
The event handler has to go inside "pilotPanelOne" function.
function pilotPanelOne ( )  
    rWin = guiCreateWindow(472, 289, 158, 152, "Pilot Work", false) 
    guiWindowSetSizable(rWin, false) 
    leaveJob = guiCreateButton(12, 70, 136, 31, "Leave the job.", false, rWin) 
    getJob = guiCreateButton(12, 29, 136, 31, "Get the job.", false, rWin) 
    theClose = guiCreateButton(12, 111, 136, 31, "Close.", false, rWin) 
    outputChatBox ("Works") 
    showCursor (true) 
    addEventHandler ("onClientGUIClick", theClose, whenPlayerClickToClose, false) -- Here 
end 
addEvent ("pilotPanelOne", true) 
addEventHandler ("pilotPanelOne", getLocalPlayer(), pilotPanelOne) 
  
function whenPlayerClickToClose (button, state, absoluteX, absoluteY) 
    outputChatBox ("Works") 
    guiSetVisible (rWin, false) 
    showCursor (false) 
end 

Now works, but... why the hell don't work it before, i tried this way too xD well, thank you Solid, this is working fine now, and i learn something more :)

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