2013martin1212 Posted June 30, 2015 Share Posted June 30, 2015 (edited) i make a login panel what the wiki shows but i cant find any tutorial about the mysql login panel and i try to make one with scracth there what i get now its a basic but i want to learn it firts the lua can someone help with it ? There is my sourceC file function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) -- define new X and Y positions for the first label X = 0.0825 Y = 0.2 -- define new Width and Height values for the first label Width = 0.25 Height = 0.25 -- create the first label, note the final argument passed is 'wdwLogin' meaning the window -- we created above is the parent of this label (so all the position and size values are now relative to the position of that window) guiCreateLabel(X, Y, Width, Height, "Username:", true, wdwLogin) -- alter the Y value, so the second label is slightly below the first Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password:", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "username", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "password", true, wdwLogin) -- set the maximum character length for the username and password fields to 50 guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) -- make the window invisible guiSetVisible(wdwLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () -- create the log in window and its components createLoginWindow() -- output a brief welcome message to the player outputChatBox("Welcome to My MTA:SA Server, please log in.") -- if the GUI was successfully created, then show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasnt been properly created, tell the player outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on the components) showCursor(true) -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin",getRootElement(),username,password) guiSetInputEnabled(false) guiSetVisible(wdwLogin,false) showCursor(false) else outputChatBox("Please enter a username and password.") end end end And there is my sourcS file function loginPlayer (thePlayer, username, password) local account = getAccount (username, password) if (account ~= false) then logIn ( thePlayer, account, password ) else outputChatBox("Wrong username or password!", thePlayer, 255, 255, 0) end end addEvent("LogIn") addEventHandler("LogIn", loginPlayer) Edited June 30, 2015 by Guest Link to comment
2013martin1212 Posted June 30, 2015 Author Share Posted June 30, 2015 i cant log in to the server i try to make a basic login panel but i cant log in , but the mysql connection with the exports is works and doesnt show me any problem in the debugscript Link to comment
Drakath Posted June 30, 2015 Share Posted June 30, 2015 Where is "onLogin" event triggered? You might wanna change it to "submitLogin". Link to comment
2013martin1212 Posted June 30, 2015 Author Share Posted June 30, 2015 Drakath i am new in lua so please can you explain to me what you mean thanks Link to comment
Drakath Posted June 30, 2015 Share Posted June 30, 2015 Drakath i am new in lua so please can you explain to me what you mean thanks You are triggering an event called "submitLogin" here: triggerServerEvent("submitLogin",getRootElement(),username,password) However your other event is called "LogIn" here: addEvent("LogIn") addEventHandler("LogIn", loginPlayer) The event name has to be the same. Also, clientSubmitLogin function is never triggered either. You need to add event handler for that function. Link to comment
2013martin1212 Posted June 30, 2015 Author Share Posted June 30, 2015 I change it the "LogIn" to submitLogin , but still not working Link to comment
Drakath Posted June 30, 2015 Share Posted June 30, 2015 I change it the "LogIn" to submitLogin , but still not working Did you add an event handler for that other function? Also, change addEvent("submitLogin") to addEvent("submitLogin", true) and addEventHandler("submitLogin", loginPlayer) to addEventHandler("submitLogin", root, loginPlayer) Link to comment
2013martin1212 Posted June 30, 2015 Author Share Posted June 30, 2015 I change it to this ,sourceS function loginPlayer (thePlayer, username, password) local account = getAccount (username, password) if (account ~= false) then logIn ( thePlayer, account, password ) else outputChatBox("Wrong username or password!", thePlayer, 255, 255, 0) end end addEvent("submitLogin", true) addEventHandler("submitLogin", root, loginPlayer) but still not working. sourceC: function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) -- define new X and Y positions for the first label X = 0.0825 Y = 0.2 -- define new Width and Height values for the first label Width = 0.25 Height = 0.25 -- create the first label, note the final argument passed is 'wdwLogin' meaning the window -- we created above is the parent of this label (so all the position and size values are now relative to the position of that window) guiCreateLabel(X, Y, Width, Height, "Username:", true, wdwLogin) -- alter the Y value, so the second label is slightly below the first Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password:", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) -- set the maximum character length for the username and password fields to 50 guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) -- make the window invisible guiSetVisible(wdwLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () -- create the log in window and its components createLoginWindow() -- output a brief welcome message to the player outputChatBox("Welcome to My MTA:SA Server, please log in.") -- if the GUI was successfully created, then show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasnt been properly created, tell the player outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on the components) showCursor(true) -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin",getRootElement(),username,password) guiSetInputEnabled(false) guiSetVisible(wdwLogin,false) showCursor(false) else outputChatBox("Please enter a username and password.") end end end Link to comment
Drakath Posted July 1, 2015 Share Posted July 1, 2015 I change it to this ,sourceSfunction loginPlayer (thePlayer, username, password) local account = getAccount (username, password) if (account ~= false) then logIn ( thePlayer, account, password ) else outputChatBox("Wrong username or password!", thePlayer, 255, 255, 0) end end addEvent("submitLogin", true) addEventHandler("submitLogin", root, loginPlayer) but still not working. sourceC: function createLoginWindow() local X = 0.375 local Y = 0.375 local Width = 0.25 local Height = 0.25 wdwLogin = guiCreateWindow(X, Y, Width, Height, "Please Log In", true) -- define new X and Y positions for the first label X = 0.0825 Y = 0.2 -- define new Width and Height values for the first label Width = 0.25 Height = 0.25 -- create the first label, note the final argument passed is 'wdwLogin' meaning the window -- we created above is the parent of this label (so all the position and size values are now relative to the position of that window) guiCreateLabel(X, Y, Width, Height, "Username:", true, wdwLogin) -- alter the Y value, so the second label is slightly below the first Y = 0.5 guiCreateLabel(X, Y, Width, Height, "Password:", true, wdwLogin) X = 0.415 Y = 0.2 Width = 0.5 Height = 0.15 edtUser = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) Y = 0.5 edtPass = guiCreateEdit(X, Y, Width, Height, "", true, wdwLogin) -- set the maximum character length for the username and password fields to 50 guiEditSetMaxLength(edtUser, 50) guiEditSetMaxLength(edtPass, 50) X = 0.415 Y = 0.7 Width = 0.25 Height = 0.2 btnLogin = guiCreateButton(X, Y, Width, Height, "Log In", true, wdwLogin) -- make the window invisible guiSetVisible(wdwLogin, false) end addEventHandler("onClientResourceStart", getResourceRootElement(), function () -- create the log in window and its components createLoginWindow() -- output a brief welcome message to the player outputChatBox("Welcome to My MTA:SA Server, please log in.") -- if the GUI was successfully created, then show the GUI to the player if (wdwLogin ~= nil) then guiSetVisible(wdwLogin, true) else -- if the GUI hasnt been properly created, tell the player outputChatBox("An unexpected error has occurred and the log in GUI has not been created.") end -- enable the players cursor (so they can select and click on the components) showCursor(true) -- set the input focus onto the GUI, allowing players (for example) to press 'T' without the chatbox opening guiSetInputEnabled(true) end ) function clientSubmitLogin(button,state) if button == "left" and state == "up" then local username = guiGetText(edtUser) local password = guiGetText(edtPass) if username and password then triggerServerEvent("submitLogin",getRootElement(),username,password) guiSetInputEnabled(false) guiSetVisible(wdwLogin,false) showCursor(false) else outputChatBox("Please enter a username and password.") end end end There is still no event handler for clientSubmitLogin() function. Where did you get this script anyway? Link to comment
2013martin1212 Posted July 1, 2015 Author Share Posted July 1, 2015 i get this script from here ..https://wiki.multitheftauto.com/wiki/Introduction_to_Scripting_the_GUI#A_tutorial_to_make_a_login_window Link to comment
xeon17 Posted July 1, 2015 Share Posted July 1, 2015 This script is outdated and only a example for begginers , just visit the community and you will find a working cool login panel. Link to comment
2013martin1212 Posted July 1, 2015 Author Share Posted July 1, 2015 i now there is lots of login panel but i want to create one on my own not to edit, and if i download one then i doesnt learn it because most script are complied 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