sheenidgs Posted April 23, 2013 Share Posted April 23, 2013 Hi... I have a problem with GUI. The GUI doesn't appear with bindKey I already searching every topic discuss about GUI and i tried to follow the method, but it's nothing GUIEditor = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, checkbox = {} } function initializeBankPanel () GUIEditor.window[1] = guiCreateWindow(541, 262, 314, 226, "National Bank of San Andreas", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 21, 295, 196, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Deposit", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(20, 56, 247, 15, "Your balance: $", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Withdraw", GUIEditor.tabpanel[1]) GUIEditor.label[3] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[2]) GUIEditor.edit[2] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(20, 56, 248, 15, "Your balance: $", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[2]) GUIEditor.tab[3] = guiCreateTab("Transfer", GUIEditor.tabpanel[1]) GUIEditor.label[5] = guiCreateLabel(20, 19, 61, 15, "Username:", false, GUIEditor.tab[3]) GUIEditor.label[6] = guiCreateLabel(20, 52, 61, 15, "Amount: $", false, GUIEditor.tab[3]) GUIEditor.label[7] = guiCreateLabel(20, 88, 247, 15, "Your balance: $", false, GUIEditor.tab[3]) GUIEditor.edit[3] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.edit[4] = guiCreateEdit(85, 50, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.checkbox[1] = guiCreateCheckBox(270, 20, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.checkbox[2] = guiCreateCheckBox(270, 55, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.button[3] = guiCreateButton(88, 120, 124, 38, "Proceed", false, GUIEditor.tab[3]) end function startToBindKey ( ) bindKey ( "]", "down", function () guiSetVisible ( GUIEditor.window[1], not guiGetVisible ( GUIEditor.window[1] ) ) showCursor ( guiGetVisible ( GUIEditor.window[1] ) ) guiSetInputEnabled ( guiGetVisible ( GUIEditor.window[1] ) ) end } initializeBankPanel() end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startToBindKey ) player = getLocalPlayer ( ) gettab = getSelectedTab ( GUIEditor.tabpanel[1] ) function controlBankPanel ( ) if not isElement ( GUIEditor.window[1] ) then initializeBankPanel () end if not guiGetVisible ( GUIEditor.window[1] ) then showBankPanel ( ) else closeBankPanel ( ) end end function updateBalance () guiSetText ( GUIEditor.label[2], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[4], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[7], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) end function showBankPanel () guiSetVisible ( GUIEditor.window[1], true ) showCursor ( true ) guiSetInputEnabled ( true ) updateBalance ( ) end function closeBankPanel() guiSetVisible ( GUIEditor.window[1], false ) showCursor ( false ) guiSetInputEnabled ( false ) end addEventHandler("onClientGUIClick", GUIEditor.button[1], deposit, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], withdraw, false) addEventHandler("onClientGUIClick", GUIEditor.button[3], transfer, false) addEventHandler("onClientGUITabSwitched", getRootElement ( ), updateBalance, false) addEvent("showBankPanel", true) addEvent("closeBankPanel", true) addEventHandler("showBankPanel", getRootElement(), showBankPanel) addEventHandler("closeBankPanel", getRootElement(), closeBankPanel) Thx for ur attention and your help Link to comment
MIKI785 Posted April 23, 2013 Share Posted April 23, 2013 Do you get any warnings/errors? That would help. Link to comment
sheenidgs Posted April 23, 2013 Author Share Posted April 23, 2013 Do you get any warnings/errors? That would help. I don't get any errors or warnings. Link to comment
MIKI785 Posted April 23, 2013 Share Posted April 23, 2013 Try this: GUIEditor = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, checkbox = {} } function initializeBankPanel () GUIEditor.window[1] = guiCreateWindow(541, 262, 314, 226, "National Bank of San Andreas", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 21, 295, 196, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Deposit", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(20, 56, 247, 15, "Your balance: $", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Withdraw", GUIEditor.tabpanel[1]) GUIEditor.label[3] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[2]) GUIEditor.edit[2] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(20, 56, 248, 15, "Your balance: $", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[2]) GUIEditor.tab[3] = guiCreateTab("Transfer", GUIEditor.tabpanel[1]) GUIEditor.label[5] = guiCreateLabel(20, 19, 61, 15, "Username:", false, GUIEditor.tab[3]) GUIEditor.label[6] = guiCreateLabel(20, 52, 61, 15, "Amount: $", false, GUIEditor.tab[3]) GUIEditor.label[7] = guiCreateLabel(20, 88, 247, 15, "Your balance: $", false, GUIEditor.tab[3]) GUIEditor.edit[3] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.edit[4] = guiCreateEdit(85, 50, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.checkbox[1] = guiCreateCheckBox(270, 20, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.checkbox[2] = guiCreateCheckBox(270, 55, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.button[3] = guiCreateButton(88, 120, 124, 38, "Proceed", false, GUIEditor.tab[3]) end bindKey ( "]", "down", function () if isElement(GUIEditor.window[1]) then destroyElement(GUIEditor.window[1]) showCursor(false) guiSetInputEnabled(false) else initializeBankPanel() showCursor(true) guiSetInputEnabled(true) end end ) player = getLocalPlayer ( ) gettab = getSelectedTab ( GUIEditor.tabpanel[1] ) function controlBankPanel ( ) if not isElement ( GUIEditor.window[1] ) then initializeBankPanel () end if not guiGetVisible ( GUIEditor.window[1] ) then showBankPanel ( ) else closeBankPanel ( ) end end function updateBalance () guiSetText ( GUIEditor.label[2], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[4], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[7], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) end function showBankPanel () guiSetVisible ( GUIEditor.window[1], true ) showCursor ( true ) guiSetInputEnabled ( true ) updateBalance ( ) end function closeBankPanel() guiSetVisible ( GUIEditor.window[1], false ) showCursor ( false ) guiSetInputEnabled ( false ) end addEventHandler("onClientGUIClick", GUIEditor.button[1], deposit, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], withdraw, false) addEventHandler("onClientGUIClick", GUIEditor.button[3], transfer, false) addEventHandler("onClientGUITabSwitched", getRootElement ( ), updateBalance, false) addEvent("showBankPanel", true) addEvent("closeBankPanel", true) addEventHandler("showBankPanel", getRootElement(), showBankPanel) addEventHandler("closeBankPanel", getRootElement(), closeBankPanel) Link to comment
sheenidgs Posted April 24, 2013 Author Share Posted April 24, 2013 Try this: GUIEditor = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, checkbox = {} } function initializeBankPanel () GUIEditor.window[1] = guiCreateWindow(541, 262, 314, 226, "National Bank of San Andreas", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 21, 295, 196, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Deposit", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(20, 56, 247, 15, "Your balance: $", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Withdraw", GUIEditor.tabpanel[1]) GUIEditor.label[3] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[2]) GUIEditor.edit[2] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(20, 56, 248, 15, "Your balance: $", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[2]) GUIEditor.tab[3] = guiCreateTab("Transfer", GUIEditor.tabpanel[1]) GUIEditor.label[5] = guiCreateLabel(20, 19, 61, 15, "Username:", false, GUIEditor.tab[3]) GUIEditor.label[6] = guiCreateLabel(20, 52, 61, 15, "Amount: $", false, GUIEditor.tab[3]) GUIEditor.label[7] = guiCreateLabel(20, 88, 247, 15, "Your balance: $", false, GUIEditor.tab[3]) GUIEditor.edit[3] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.edit[4] = guiCreateEdit(85, 50, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.checkbox[1] = guiCreateCheckBox(270, 20, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.checkbox[2] = guiCreateCheckBox(270, 55, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.button[3] = guiCreateButton(88, 120, 124, 38, "Proceed", false, GUIEditor.tab[3]) end bindKey ( "]", "down", function () if isElement(GUIEditor.window[1]) then destroyElement(GUIEditor.window[1]) showCursor(false) guiSetInputEnabled(false) else initializeBankPanel() showCursor(true) guiSetInputEnabled(true) end end ) player = getLocalPlayer ( ) gettab = getSelectedTab ( GUIEditor.tabpanel[1] ) function controlBankPanel ( ) if not isElement ( GUIEditor.window[1] ) then initializeBankPanel () end if not guiGetVisible ( GUIEditor.window[1] ) then showBankPanel ( ) else closeBankPanel ( ) end end function updateBalance () guiSetText ( GUIEditor.label[2], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[4], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[7], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) end function showBankPanel () guiSetVisible ( GUIEditor.window[1], true ) showCursor ( true ) guiSetInputEnabled ( true ) updateBalance ( ) end function closeBankPanel() guiSetVisible ( GUIEditor.window[1], false ) showCursor ( false ) guiSetInputEnabled ( false ) end addEventHandler("onClientGUIClick", GUIEditor.button[1], deposit, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], withdraw, false) addEventHandler("onClientGUIClick", GUIEditor.button[3], transfer, false) addEventHandler("onClientGUITabSwitched", getRootElement ( ), updateBalance, false) addEvent("showBankPanel", true) addEvent("closeBankPanel", true) addEventHandler("showBankPanel", getRootElement(), showBankPanel) addEventHandler("closeBankPanel", getRootElement(), closeBankPanel) Thanks. It's worked Link to comment
sheenidgs Posted April 24, 2013 Author Share Posted April 24, 2013 Try this: GUIEditor = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, checkbox = {} } function initializeBankPanel () GUIEditor.window[1] = guiCreateWindow(541, 262, 314, 226, "National Bank of San Andreas", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 21, 295, 196, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Deposit", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(20, 56, 247, 15, "Your balance: $", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Withdraw", GUIEditor.tabpanel[1]) GUIEditor.label[3] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[2]) GUIEditor.edit[2] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(20, 56, 248, 15, "Your balance: $", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[2]) GUIEditor.tab[3] = guiCreateTab("Transfer", GUIEditor.tabpanel[1]) GUIEditor.label[5] = guiCreateLabel(20, 19, 61, 15, "Username:", false, GUIEditor.tab[3]) GUIEditor.label[6] = guiCreateLabel(20, 52, 61, 15, "Amount: $", false, GUIEditor.tab[3]) GUIEditor.label[7] = guiCreateLabel(20, 88, 247, 15, "Your balance: $", false, GUIEditor.tab[3]) GUIEditor.edit[3] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.edit[4] = guiCreateEdit(85, 50, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.checkbox[1] = guiCreateCheckBox(270, 20, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.checkbox[2] = guiCreateCheckBox(270, 55, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.button[3] = guiCreateButton(88, 120, 124, 38, "Proceed", false, GUIEditor.tab[3]) end bindKey ( "]", "down", function () if isElement(GUIEditor.window[1]) then destroyElement(GUIEditor.window[1]) showCursor(false) guiSetInputEnabled(false) else initializeBankPanel() showCursor(true) guiSetInputEnabled(true) end end ) player = getLocalPlayer ( ) gettab = getSelectedTab ( GUIEditor.tabpanel[1] ) function controlBankPanel ( ) if not isElement ( GUIEditor.window[1] ) then initializeBankPanel () end if not guiGetVisible ( GUIEditor.window[1] ) then showBankPanel ( ) else closeBankPanel ( ) end end function updateBalance () guiSetText ( GUIEditor.label[2], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[4], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) guiSetText ( GUIEditor.label[7], "Your balance: $"..getElementData ( getLocalPlayer () ).."" ) end function showBankPanel () guiSetVisible ( GUIEditor.window[1], true ) showCursor ( true ) guiSetInputEnabled ( true ) updateBalance ( ) end function closeBankPanel() guiSetVisible ( GUIEditor.window[1], false ) showCursor ( false ) guiSetInputEnabled ( false ) end addEventHandler("onClientGUIClick", GUIEditor.button[1], deposit, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], withdraw, false) addEventHandler("onClientGUIClick", GUIEditor.button[3], transfer, false) addEventHandler("onClientGUITabSwitched", getRootElement ( ), updateBalance, false) addEvent("showBankPanel", true) addEvent("closeBankPanel", true) addEventHandler("showBankPanel", getRootElement(), showBankPanel) addEventHandler("closeBankPanel", getRootElement(), closeBankPanel) Thanks. But,I can't close the GUI now (no error and warning) Link to comment
OGF Posted April 24, 2013 Share Posted April 24, 2013 That's because line 54 is stopping you from pressing your bind. guiSetInputEnabled(true) This should be a better help. guiSetInputMode("no_binds_when_editing") Link to comment
DNL291 Posted April 24, 2013 Share Posted April 24, 2013 The code has many errors. getElementData has two required arguments. Use guiSetVisible instead of destroyElement to close the window. The 'getSelectedTab' function doesn't exist, use guiGetSelectedTab instead. Link to comment
sheenidgs Posted April 24, 2013 Author Share Posted April 24, 2013 That's because line 54 is stopping you from pressing your bind. guiSetInputEnabled(true) This should be a better help. guiSetInputMode("no_binds_when_editing") Thanks. Now the GUI worked properly The code has many errors.getElementData has two required arguments. Use guiSetVisible instead of destroyElement to close the window. The 'getSelectedTab' function doesn't exist, use guiGetSelectedTab instead. Then, which script editor i must use ? MTA script editor ? (I use notepad++) Link to comment
DNL291 Posted April 24, 2013 Share Posted April 24, 2013 Then, which script editor i must use ? MTA script editor ? (I use notepad++) I also use Notepad++, I recommend using with Lua highlight. More information see this thread: https://forum.multitheftauto.com/viewto ... d3c651f384 Link to comment
sheenidgs Posted April 24, 2013 Author Share Posted April 24, 2013 Then, which script editor i must use ? MTA script editor ? (I use notepad++) I also use Notepad++, I recommend using with Lua highlight. More information see this thread: https://forum.multitheftauto.com/viewto ... d3c651f384 Thanks for the information Btw, i have another problem. When I click the GUI button, it's nothing. Here's my new code. GUIEditor = { tab = {}, tabpanel = {}, edit = {}, button = {}, window = {}, label = {}, checkbox = {} } function initializeBankPanel () GUIEditor.window[1] = guiCreateWindow(541, 262, 314, 226, "National Bank of San Andreas", false) guiWindowSetMovable(GUIEditor.window[1], false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.tabpanel[1] = guiCreateTabPanel(9, 21, 295, 196, false, GUIEditor.window[1]) GUIEditor.tab[1] = guiCreateTab("Deposit", GUIEditor.tabpanel[1]) GUIEditor.label[1] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[1]) GUIEditor.edit[1] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[1]) GUIEditor.button[1] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[1]) GUIEditor.label[2] = guiCreateLabel(20, 56, 247, 15, "Your balance: $", false, GUIEditor.tab[1]) GUIEditor.tab[2] = guiCreateTab("Withdraw", GUIEditor.tabpanel[1]) GUIEditor.label[3] = guiCreateLabel(20, 19, 61, 15, "Amount: $", false, GUIEditor.tab[2]) GUIEditor.edit[2] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[2]) GUIEditor.label[4] = guiCreateLabel(20, 56, 248, 15, "Your balance: $", false, GUIEditor.tab[2]) GUIEditor.button[2] = guiCreateButton(88, 100, 124, 38, "Proceed", false, GUIEditor.tab[2]) GUIEditor.tab[3] = guiCreateTab("Transfer", GUIEditor.tabpanel[1]) GUIEditor.label[5] = guiCreateLabel(20, 19, 61, 15, "Username:", false, GUIEditor.tab[3]) GUIEditor.label[6] = guiCreateLabel(20, 52, 61, 15, "Amount: $", false, GUIEditor.tab[3]) GUIEditor.label[7] = guiCreateLabel(20, 88, 247, 15, "Your balance: $", false, GUIEditor.tab[3]) GUIEditor.edit[3] = guiCreateEdit(85, 14, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.edit[4] = guiCreateEdit(85, 50, 182, 26, "", false, GUIEditor.tab[3]) GUIEditor.checkbox[1] = guiCreateCheckBox(270, 20, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.checkbox[2] = guiCreateCheckBox(270, 55, 15, 15, "", false, false, GUIEditor.tab[3]) GUIEditor.button[3] = guiCreateButton(88, 120, 124, 38, "Proceed", false, GUIEditor.tab[3]) end bindKey ( "]", "down", function () if isElement(GUIEditor.window[1]) then destroyElement(GUIEditor.window[1]) showCursor(false) guiSetInputEnabled(false) updateBalance ( ) else initializeBankPanel() showCursor(true) guiSetInputMode("no_binds_when_editing") updateBalance ( ) end end ) player = getLocalPlayer ( ) function updateBalance () guiSetText ( GUIEditor.label[2], "Your balance: $".. getElementData ( player, "data.bank" ) .."" ) guiSetText ( GUIEditor.label[4], "Your balance: $".. getElementData ( player, "data.bank" ) .."" ) guiSetText ( GUIEditor.label[7], "Your balance: $".. getElementData ( player, "data.bank" ) .."" ) end function deposit ( ) local text = guiGetText ( GUIEditor.edit[1] ) local amount = tonumber ( text ) if amount <= 0 or amount > getPlayerMoney ( ) then return guiShowMessageBox ( "Invalid value.", "error" ) end local operation = triggerServerEvent ( "depositMoney", getRootElement(), localPlayer, amount ) if operation then return guiShowMessageBox ( "Operation completed.", "info" ) else return guiShowMessageBox ( "Unknown error.", "error" ) end end function withdraw ( ) local text = guiGetText ( GUIEditor.edit[2] ) local amount = tonumber ( text ) if amount <= 0 or amount > tonumber ( getElementData ( player, "data.bank" ) ) then return guiShowMessageBox ( "Invalid value.", "error" ) end if getPlayerMoney ( ) + amount > 999999999 then return guiShowMessageBox ( "You can't carry that cash too much.", "error" ) end local operation = triggerServerEvent ( "withdrawMoney", getRootElement(), localPlayer, amount ) if operation then return guiShowMessageBox ( "Operation completed.", "info" ) else return guiShowMessageBox ( "Unknown error.", "error" ) end end function transfer ( ) local user = guiGetText ( GUIEditor.edit[3] ) local text = guiGetText ( GUIEditor.edit[4] ) local amount = tonumber ( text ) local oldbal = getElementData ( player, "data.bank" ) local newbal = tonumber ( oldbal ) if amount <= 0 then return guiShowMessageBox ( "Invalid value.", "error" ) end if amount > newbal then return guiShowMessageBox ( "You don't have that cash in your balance.", "error" ) end if user == nil then return guiShowMessageBox ( "Insert the username.", "error" ) end if user == getPlayerName ( player ) then return guiShowMessageBox ( "You can't transfer to yourself.", "error" ) end if guiCheckBoxGetSelected ( GUIEditor.checkbox[1] ) and guiCheckBoxGetSelected ( GUIEditor.checkbox[2] ) then for k,name in inpairs ( getElementsByType ( "player" ) ) do if name == user and getElementData ( getPlayerFromName ( user ), "loggedin" ) == 1 then local operation = triggerServerEvent ( "transferMoney", getRootElement(), localPlayer, user, amount ) if operation then return guiShowMessageBox ( "Operation completed.", "info" ) else return guiShowMessageBox ( "Unknown error.", "error" ) end end end else return guiShowMessageBox ( "You must check the boxes to confirm your input.", "error" ) end guiShowMessageBox ( "The player is not active right now.", "error" ) end addEventHandler("onClientGUIClick", GUIEditor.button[1], deposit, false) addEventHandler("onClientGUIClick", GUIEditor.button[2], withdraw, false) addEventHandler("onClientGUIClick", GUIEditor.button[3], transfer, false) addEventHandler("onClientGUITabSwitched", getRootElement ( ), updateBalance, false) addEvent("showBankPanel", true) addEvent("closeBankPanel", true) addEvent("initializeBankPanel", true) addEventHandler("showBankPanel", getRootElement(), showBankPanel) addEventHandler("closeBankPanel", getRootElement(), closeBankPanel) addEventHandler("initializeBankPanel", getRootElement(), initializeBankPanel) Link to comment
iPrestege Posted April 24, 2013 Share Posted April 24, 2013 Which Line? And there's no error's on the debug? Link to comment
sheenidgs Posted April 24, 2013 Author Share Posted April 24, 2013 Which Line? And there's no error's on the debug? No error and warning. No one buttons work. Link to comment
OGF Posted April 24, 2013 Share Posted April 24, 2013 Why do you have 3 events for "onClientGUIClick" you can just add one and use elseif statements addEventHandler("onClientGUIClick", guiRoot, functionhere, false) Link to comment
sheenidgs Posted April 24, 2013 Author Share Posted April 24, 2013 Why do you have 3 events for "onClientGUIClick" you can just add one and use elseif statements addEventHandler("onClientGUIClick", guiRoot, functionhere, false) I use a login system and the code it's same. login_register_window = guiCreateWindow(448,192,419,227,"MySQL Login System",false) guiWindowSetMovable(login_register_window,false) guiWindowSetSizable(login_register_window,false) tab_panel = guiCreateTabPanel(0.0859,0.1982,0.8282,0.7225,true,login_register_window) login_tab = guiCreateTab("Login",tab_panel) register_tab = guiCreateTab("Register",tab_panel) activation_tab = guiCreateTab("Activation",tab_panel) user_active_l = guiCreateEdit(0.2507,0.15,0.6311,0.2,"",true,activation_tab) code_edit_l = guiCreateEdit(0.2507,0.4143,0.634,0.1929,"",true,activation_tab) user_edit_l = guiCreateEdit(0.2507,0.15,0.6311,0.2,"",true,login_tab) pw_edit_l = guiCreateEdit(0.2507,0.4143,0.634,0.1929,"",true,login_tab) reg_edit_l = guiCreateEdit(0.2507,0.15,0.6311,0.2,"http://mta.cingka.com",true,register_tab) guiEditSetReadOnly ( reg_edit_l, true ) login_btn_l = guiCreateButton(0.2536,0.6643,0.634,0.2071,"Login",true,login_tab) guiSetFont(login_btn_l,"default-bold-small") login_active_l = guiCreateButton(0.2536,0.6643,0.634,0.2071,"Activate",true,activation_tab) guiSetFont(login_btn_l,"default-bold-small") username_label_l = guiCreateLabel(0.0317,0.1571,0.219,0.1929,"Username: ",true,login_tab) username_active_l = guiCreateLabel(0.0317,0.1571,0.219,0.1929,"Username: ",true,activation_tab) register_label_l = guiCreateLabel(0.0317,0.1571,0.219,0.1929,"Register: ",true,register_tab) guiLabelSetVerticalAlign(username_label_l,"center") guiLabelSetHorizontalAlign(username_label_l,"right",false) guiSetFont(username_label_l,"default-bold-small") guiLabelSetVerticalAlign(register_label_l,"center") guiLabelSetHorizontalAlign(register_label_l,"right",false) guiSetFont(register_label_l,"default-bold-small") guiLabelSetVerticalAlign(username_active_l,"center") guiLabelSetHorizontalAlign(username_active_l,"right",false) guiSetFont(username_active_l,"default-bold-small") pw_label_l = guiCreateLabel(0.0692,0.4286,0.17,0.1714," Password: ",true,login_tab) code_active_l = guiCreateLabel(0.0692,0.4286,0.17,0.1714," Code: ",true,activation_tab) guiLabelSetVerticalAlign(pw_label_l,"center") guiLabelSetHorizontalAlign(pw_label_l,"center",false) guiSetFont(pw_label_l,"default-bold-small") guiLabelSetVerticalAlign(code_active_l,"center") guiLabelSetHorizontalAlign(code_active_l,"center",false) guiSetFont(code_active_l,"default-bold-small") guiEditSetMasked( pw_edit_l, true ) guiSetVisible( login_register_window, false ) function playerJoin() guiSetText( user_active_l, getPlayerName(getLocalPlayer()) ) guiSetText( user_edit_l, getPlayerName(getLocalPlayer()) ) guiSetVisible( login_register_window, true ) showCursor( true ) guiSetInputEnabled( true ) setCameraMatrix( -1799.6999511719, 1856.5999755859, 30.39999961853, -1763.9000244141, 1852.5999755859, 19.799999237061 ) fadeCamera (true) end addEvent("onJoin", true) addEventHandler("onJoin", getRootElement(), playerJoin) function closeWindow() guiSetVisible( login_register_window, false ) showCursor( false ) guiSetInputEnabled( false ) end addEvent("closeWindow", true) addEventHandler("closeWindow", getRootElement(), closeWindow) function login_player ( source ) triggerServerEvent ( "onLogin", getRootElement(), localPlayer, guiGetText(user_edit_l), guiGetText(pw_edit_l) ) end addEventHandler("onClientGUIClick", login_btn_l, login_player,false) function activation_player ( source ) triggerServerEvent ( "onActivation", getRootElement(), localPlayer, guiGetText(user_active_l), guiGetText(code_edit_l) ) end addEventHandler("onClientGUIClick", login_active_l, activation_player,false) That script worked and I don't understand what's wrong Link to comment
sheenidgs Posted April 25, 2013 Author Share Posted April 25, 2013 I need help for my problem, please. 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