Jump to content
  • 0

problem with GUI, help please.


Izanagi

Question

Alright, I got a problem with gui. it won't create properly. I am using tab panel with 3 tabs and stuff in there, but it only creates the tab panel + first tab and then it won't do anything after those lines. I am posting my client script. It is all in one file at the moment as I have started scripting about 53 minutes ago. ANyways, here it is:

client:

local root = getRootElement()
local loc = getLocalPlayer()
 
function createAuthWindow()
tpAuth = {}
GUIEditor_Edit = {}
 
tpAuth[1] = guiCreateTabPanel(583,317,187,159,false)
authTab[1] = guiCreateTab("Register",tpAuth[1])
regLabel[1] = guiCreateLabel(0.05,0.1,0.4,0.1,"Username* :",true,authTab[1])
guiLabelSetColor(regLabel[1],255,255,255)
guiLabelSetVerticalAlign(regLabel[1],"center")
guiLabelSetHorizontalAlign(regLabel[1],"right",false)
regLabel[2] = guiCreateLabel(0.05,0.3,0.4,0.1,"Password* :",true,authTab[1])
guiLabelSetColor(regLabel[2],255,255,255)
guiLabelSetVerticalAlign(regLabel[2],"center")
guiLabelSetHorizontalAlign(regLabel[2],"right",false)
regLabel[3] = guiCreateLabel(0.05,0.5,0.4,0.1,"Repeat* :",true,authTab[1])
guiLabelSetColor(regLabel[3],255,255,255)
guiLabelSetVerticalAlign(regLabel[3],"center")
guiLabelSetHorizontalAlign(regLabel[3],"right",false)
regEdit[1] = guiCreateEdit(0.5,0.1,0.4,0.15,"",true,authTab[1])
guiEditSetMaxLength(regEdit[1],24)
regEdit[2] = guiCreateEdit(0.5,0.3,0.4,0.15,"",true,authTab[1])
guiEditSetMasked(regEdit[2],true)
guiEditSetMaxLength(regEdit[2],16)
regEdit[3] = guiCreateEdit(0.5,0.5,0.4,0.15,"",true,authTab[1])
guiEditSetMasked(regEdit[3],true)
guiEditSetMaxLength(regEdit[3],16)
regButton[1] = guiCreateButton(0.3,0.75,0.4,0.2,"Register",true,authTab[1])
authTab[2] = guiCreateTab("Login",tpAuth[1])
logLabel[1] = guiCreateLabel(0.05,0.1,0.4,0.1,"Username :",true,authTab[2])
guiLabelSetColor(logLabel[1],255,255,255)
guiLabelSetVerticalAlign(logLabel[1],"center")
guiLabelSetHorizontalAlign(logLabel[1],"right",false)
logLabel[2] = guiCreateLabel(0.05,0.3,0.4,0.1,"Password :",true,authTab[2])
guiLabelSetColor(logLabel[2],255,255,255)
guiLabelSetVerticalAlign(logLabel[2],"center")
guiLabelSetHorizontalAlign(logLabel[2],"right",false)
logEdit[1] = guiCreateEdit(0.5,0.1,0.4,0.15,"",true,authTab[2])
guiEditSetMaxLength(logEdit[1],24)
logEdit[2] = guiCreateEdit(0.5,0.3,0.4,0.15,"",true,authTab[2])
guiEditSetMasked(logEdit[2],true)
guiEditSetMaxLength(logEdit[2],16)
logCheckbox[1] = guiCreateCheckBox(0.1,0.55,0.8,0.1,"Remember me",false,true,authTab[2])
logCheckbox[2] = guiCreateCheckBox(0.1,0.65,0.8,0.1,"Auto login",false,true,authTab[2])
logButton[1] = guiCreateButton(0.3,0.85,0.4,0.1,"Login",true,authTab[2])
authTab[3] = guiCreateTab("Recovery",tpAuth[1])
--GUIEditor_Edit[1] = guiCreateEdit(0.4545,1.1136,0,0,"",true,authTab[3])
recLabel[1] = guiCreateLabel(0.1,0.1,0.8,0.1,"Unique User ID",true,authTab[3])
guiLabelSetColor(recLabel[1],255,255,255)
guiLabelSetVerticalAlign(recLabel[1],"center")
guiLabelSetHorizontalAlign(recLabel[1],"center",false)
recLabel[2] = guiCreateLabel(0.1,0.4,0.8,0.1,"New Password",true,authTab[3])
guiLabelSetColor(recLabel[2],255,255,255)
guiLabelSetVerticalAlign(recLabel[2],"center")
guiLabelSetHorizontalAlign(recLabel[2],"center",false)
recEdit[1] = guiCreateEdit(0.2,0.25,0.6,0.15,"",true,authTab[3])
recEdit[2] = guiCreateEdit(0.2,0.55,0.6,0.15,"",true,authTab[3])
guiEditSetMaxLength(recEdit[2],16)
recButton[1] = guiCreateButton(0.2,0.8,0.6,0.15,"Set Password",true,authTab[3])
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), 
function ()
	createAuthWindow()
 
guiSetVisible(tpAuth, true)
outputChatBox("test after show")
 
showCursor(true)
guiSetInputEnabled(true)
end
)
 
function clientSubmitLogin(button)
if button == "left" then
 
triggerServerEvent("SubmitLogin", root, guiGetText(logEdit[1]), guiGetText(logEdit[2]))
guiSetInputEnabled(false)
guiSetVisible(tpAuth[1], false)
showCursor(false)
end
end
 
addEventHandler("onClientGUIClick", regButton[1], clientSubmitRegister, false)
addEventHandler("onClientGUIClick", logButton[1], clientSubmitLogin, false)
addEventHandler("onClientGUIClick", recButton[1], clientSubmitRecovery, false)

what is wrong with the code, tell me!

I used the Gui Edit to generate gui code..

Link to comment

7 answers to this question

Recommended Posts

  • 0

Use "/debugscript 3" when you're on your server, You would have seen an error if you would have done that.

Problem is that you're trying to index tables which don't exist. These don't exist:

- authTab

- regLabel

- regEdit

- regButton

- logLabel

- logEdit

- logCheckbox

- logButton

- recLabel

- recEdit

- recButton

And that's with only checking your createAuthWindow function. I'd advice you to either merge this all into 1 table. But otherwise, do something like this:

authTab={}
regLabel={}
...
...

P.S. This should actually be in Scripting section.

Link to comment
  • 0

yeah okay. That solved it but now with /debugscript 3 it displays that there are errors in the cient script where I add event handlers. and about the values, i'll see into it that they use less memory which I will do (if is possible) so make me shut up because I don't know what I am telling, but the thing is now that the addEventHandler is giving errors in the debugscript 3.. what do I do now?

Link to comment
  • 0

okay, first I didn't say that tehy don't mean anything. and those are warnings. let me qoute it..

WARNING: c.base.lua: bad argument @ 'addEventHandler' - Line:112

same for lines 113 and 114. the handlers I add onguiclick... wonder what's wrong.

it's the lines 86,87,88 in the script provided by me in the first post, it has diffrent line numbers as i've changed something in the create function and it works just fine now.

I am new to lua+mta so i need help handling things. please guide me what did I do wrong

EDIT:

oh yeah, and i've added the three handlers for the addEventHandler functions

Link to comment
  • 0

They're not in a function - which means they're being run before any lines in any functions are, and before any events are called. So your GUI hasn't been created yet, and the buttons you're attaching the handlers to don't exist yet. That's your 'bad argument' - a non-existing element.

Move those 3 lines directly under createAuthWindow() in the "onClientResourceStart" event handler. They'll then apply their handers directly after the GUI is created.

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