Jump to content

Can't get gui windows to work..


Jumba'

Recommended Posts

Hi, I've been trying to make a gui window but it won't go. I'm using the dev wiki example

  
function guiWindow ( ) 
    local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true )  -- create a window which has "Information" in the title bar. 
  
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow )       -- create a tab panel which fills the whole window 
local tabMap = guiCreateTab( "Map Information", tabPanel )                -- create a tab named "Map Information" on 'tabPanel' 
local tabHelp = guiCreateTab( "Help", tabPanel )                          -- create another tab named "Help" on 'tabPanel' 
  
-- adds a label (text) to each tab 
guiCreateLabel(0.02, 0.04, 0.94, 0.2, "This is information about the current map", true, tabMap) 
guiCreateLabel(0.02, 0.04, 0.94, 0.92, "This is help text.", true, tabHelp) 
end 
addCommandHandler ("cwindow", guiWindow )    
  

But then I do it I get this error

ERROR: .../Server/mods/deathmatch/resources/license/client.lua:1: attempt to call global 'guiCreateWindow' (a nil value) 

It's the same with getPlayerAccount, I do it while logged in or out and I still get

ERROR: ...server/mods/deathmatch/resources/license/license.lua:24: attempt to call global 'getPlayerAccount' (a nil value) 

when using

function viewAccount(thePlayer, command) 
  
        -- get the name of the account from thePlayer 
        local accountName = getPlayerAccount(thePlayer) 
        
        -- output the message to the player 
        outputChatBox("Your account name is " .. accountName, thePlayer)        
end 
  
-- add the console command 
addCommandHandler("account", viewAccount) 

Link to comment

Make sure that gui script is client-side and that account script is server-side.

When you get message:

attempt to call global...

It usually is caused by using function that doesn't exist. So "server-side only" function will not work in client-side script and vice versa.

Check whether function is client-side or server-side on wiki before you use it.

Link to comment

try this:

meta.xml:

  
<meta> 
  <info author="yourname" version="0.1" type="misc" />  
  
  <script src="myWindow.lua" type="client" />  
  
 </meta> 
  

myWindow.lua:

  
 function guiToggleVisible ( ) 
  
        if ( guiGetVisible ( myWindow ) == true ) then            
                guiSetVisible ( myWindow, false ) 
                showCursor ( false ) 
        else       
                guiSetVisible ( myWindow, true ) 
                showCursor ( true ) 
        end 
end 
  
myWindow = guiCreateWindow ( 0, 0, .5, .5, "MyWindow", true ) 
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow ) 
local tabFrontPage = guiCreateTab( "Front Page", tabPanel ) 
local tabCommands = guiCreateTab( "Commands", tabPanel ) 
local tabCredits = guiCreateTab( "Info", tabPanel) 
  
guiCreateLabel(0.01,0.92,0.94,0.2,"If you see this your panel is working!",true,tabFrontPage) 
  
bindKey ( "F4", "down", guiToggleVisible ) 
  
  
  

Now you can open your windows by pushing: F4 Sould work, working for me so :P

Link to comment

it's getClientAccount, i dunno why somebody added the getPlayerAccount to the wiki, ill have a look into that. And to output the account name you also have to use getAccountName, something like outputChatBox ( getAccountName ( getClientAccount ( player ) ) )

Link to comment
it's getClientAccount, i dunno why somebody added the getPlayerAccount to the wiki, ill have a look into that. And to output the account name you also have to use getAccountName, something like outputChatBox ( getAccountName ( getClientAccount ( player ) ) )

Oooh, ok. Thanks for the help! :D

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