Jump to content

Need help with GUI


Franky

Recommended Posts

  
function analyseGui ( ) 
    analysegui = guiCreateWindow ( 0.3, 0.25, 0.4, 0.5, "Analysing results", true ) 
    space1 = guiCreateGridList ( 0.015, 0.06, 0.483, 0.1, true, analysegui ) 
    space2 = guiCreateGridList ( 0.512, 0.06, 0.483, 0.1, true, analysegui ) 
    space3 = guiCreateGridList ( 0.015, 0.18, 0.483, 0.1, true, analysegui ) 
    space4 = guiCreateGridList ( 0.512, 0.18, 0.483, 0.1, true, analysegui ) 
    space5 = guiCreateGridList ( 0.015, 0.3, 0.985, 0.6, true, analysegui ) 
    closeBTN = guiCreateButton ( 0.8, 0.92, 0.2, 0.098, "Close", true, analysegui ) 
    guiSetVisible ( analysegui, false ) 
end 
addEventHandler( "onClientResourceStart", getResourceRootElement ( getThisResource ( ) ), analyseGui ) 
  
function analyseCMD ( thePlayer, commandName ) 
    guiSetVisible ( analysegui, true ) 
    showCursor ( true ) 
    guiSetInputEnabled ( true ) 
end 
addCommandHandler ( "analyse", analyseCMD ) 
  
function onGuiClose ( ) 
    showCursor ( false ) 
    guiSetVisible ( analysegui, false ) 
    guiSetInputEnabled ( false ) 
end 
addEventHandler ( "onClientGUIClick", closeBTN, onGuiClose, false ) 
  

Link to comment
... What's wrong with it... I'm not going to copy it to find out, if you think I am. Give us some info.

Sorry i forgot:D

it gives me an error like "Bad argument @ line 26 "addEventHandler" " or something like that.. it doesn't give it in the console, it in the debug script.

Link to comment
... What's wrong with it... I'm not going to copy it to find out, if you think I am. Give us some info.

Sorry i forgot:D

it gives me an error like "Bad argument @ line 26 "addEventHandler" " or something like that.. it doesn't give it in the console, it in the debug script.

Ah ok! :P

Anyway, improved version:

function analyseGui ( ) 
    analysegui = guiCreateWindow ( 0.3, 0.25, 0.4, 0.5, "Analysing results", true ) 
    space1 = guiCreateGridList ( 0.015, 0.06, 0.483, 0.1, true, analysegui ) 
    space2 = guiCreateGridList ( 0.512, 0.06, 0.483, 0.1, true, analysegui ) 
    space3 = guiCreateGridList ( 0.015, 0.18, 0.483, 0.1, true, analysegui ) 
    space4 = guiCreateGridList ( 0.512, 0.18, 0.483, 0.1, true, analysegui ) 
    space5 = guiCreateGridList ( 0.015, 0.3, 0.985, 0.6, true, analysegui ) 
    closeBTN = guiCreateButton ( 0.8, 0.92, 0.2, 0.098, "Close", true, analysegui ) 
    addEventHandler ( "onClientGUIClick", closeBTN, onGuiClose, false ) 
    guiSetVisible ( analysegui, false ) 
end 
addEventHandler( "onClientResourceStart", getResourceRootElement ( getThisResource ( ) ), analyseGui ) 
  
function analyseCMD ( thePlayer, commandName ) 
    guiSetVisible ( analysegui, true ) 
    showCursor ( true ) 
    guiSetInputEnabled ( true ) 
end 
addCommandHandler ( "analyse", analyseCMD ) 
  
function onGuiClose ( ) 
    showCursor ( false ) 
    guiSetVisible ( analysegui, false ) 
    guiSetInputEnabled ( false ) 
end 

What I did, and why:

The addEventHandler is now inside analyseGui function. Reason? Everything outside any events is triggered/initiated before the ones inside events/functions. In other words, if you put for example:

addEventHandler("onPlayerWasted",getRootElement(),playerRespawn) 
  
function playerRespawn() 
    [..] 
end 

That won't work. The addEventHandler was executed BEFORE it knew what playerRespawn actually means. Get it? ^^

So even if the even is onClientResourceStart, the things outside of functions are ALWAYS triggered/initiated earlier! (or well, I don't know any exceptions... :P)

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