Jumba' Posted March 5, 2008 Share Posted March 5, 2008 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
50p Posted March 6, 2008 Share Posted March 6, 2008 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
Frank-De-Ruiter Posted March 6, 2008 Share Posted March 6, 2008 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 Link to comment
lil Toady Posted March 6, 2008 Share Posted March 6, 2008 Frank-De-Ruiter is wrong, the script in the first post looks right, you just forgot to specify it as a client side one in meta.xml, like Link to comment
Jumba' Posted March 7, 2008 Author Share Posted March 7, 2008 Oh yeah I forgot to specify it as client side Altho, the second one, the getPlayerAccount doesn't work and it's supposed to be server side only, which it is being run as. Anyone know what could be wrong with the second one? Link to comment
lil Toady Posted March 7, 2008 Share Posted March 7, 2008 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
Jumba' Posted March 7, 2008 Author Share Posted March 7, 2008 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! 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