FlyingSpoon Posted February 25, 2015 Posted February 25, 2015 I am getting a lot of errors as this is my first script, I don't know where the actual error is, and my login doesn't appear on player join neither. There seems to be an error somewhere. CLIENT SIDE --- Main Menu function showMenu() loginMenu = guiCreateWindow(338, 288, 338, 189, "RaysMTA Login v0.1", false) guiWindowSetSizable(loginMenu, false) infoLbl = guiCreateLabel(37, 21, 275, 27, "Welcome to the server, to get started please login/register below! \nYou can view our news by click the news button!\n", false, loginMenu) guiSetFont(infoLbl, "default-small") guiLabelSetColor(infoLbl, 41, 201, 52) usrLbl = guiCreateLabel(147, 55, 48, 15, "Username", false, loginMenu) guiSetFont(usrLbl, "default-small") usrEdit = guiCreateEdit(90, 66, 162, 21, "", false, loginMenu) passLbl = guiCreateLabel(147, 94, 48, 15, "Password", false, loginMenu) guiSetFont(passLbl, "default-small") passEdit = guiCreateEdit(90, 105, 162, 21, "", false, loginMenu) loginBtn = guiCreateButton(10, 153, 69, 27, "Login", false, loginMenu) guiSetFont(loginBtn, "default-small") regBtn = guiCreateButton(260, 153, 69, 27, "Register", false, loginMenu) guiSetFont(regBtn, "default-small") newsBtn = guiCreateButton(137, 152, 68, 28, "News", false, loginMenu) guiSetFont(newsBtn, "default-small") end addEventHandler("onClientPlayerJoin", getRootElement(), showMenu) --- Register Menu function regPlayer(button,state) if (button == "left" and state == "up") then if (source == regBtn) then username = guiGetText(usrEdit) password = guiGetText(passEdit) triggerServerEvent("acceptRegister", getLocalPlayer(), username, password) end end end addEventHandler("onClientGUIClick", getRootElement(), regPlayer) --- Login Menu function logPlayer(button,state) if (button == "left" and state == "up") then if (source == loginBtn) then username = guiGetText(usrEdit) password = guiGetText(passEdit) triggerServerEvent("acceptLogin", getLocalPlayer(), username, password) end end end addEventHandler("onClientGUIClick", getRootElement(), logPlayer) --- Disable Login Menu function closeMenu() guiSetVisible(loginMenu,false) showCursor(false) outputChatBox("You have successfully logged in!") end end addEvent("hideMenu", true) addEventHandler("hideMenu", getRootElement(), closeMenu) SERVER SIDE --- Registering Event function regPlayer(username,password) if not username == "" then if not password == "" then local account = getAccount(username,password) if account == false then local addAcc = addAccount(username,password) if (addAcC) then triggerClientEvent(source,"hideMenu",getRootElement()) outputChatBox("You have successfully registered!", source) else outputChatBox("There was an error! Please contact an administrator!", source) end end end end end addEvent("acceptRegister",true) addEventHandler("acceptRegister",getRootElement(),regPlayer) --- Logging Event function logPlayer(username,password) if not username == "" then if not password == "" then local account = getAccount(username,password) if ( account ~= false ) then outputChatBox("You have successfully logged in!", source) triggerClientEvent(source,"hideMenu",getRootElement()) else outputChatBox("There was an error! Please contact an administrator!", source) end end end end addEvent("acceptLogin",true) addEventHandler("acceptLogin",getRootElement(),logPlayer) GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
JR10 Posted February 25, 2015 Posted February 25, 2015 onClientPlayerJoin triggers when other players join and not the client. Replace it with onClientResourceStart. As for any errors, you're going to have to post some of them so we can help you. Business System viewtopic.php?f=108&t=35797 Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726 SQLite Tutorial viewtopic.php?f=148&t=38203
3B00DG4MER Posted April 2, 2015 Posted April 2, 2015 addAcC isn't same as addAcc local addAcc = addAccount(username,password) if (addAcc) then SAF/SAO - 30% Skype: Themerzoug2020 in-game name:3B00DG4MER
FlyingSpoon Posted April 2, 2015 Author Posted April 2, 2015 CLIENT SIDE --- Main Menu function showMenu() loginMenu = guiCreateWindow(338, 288, 338, 189, "RaysMTA Login v0.1", false) guiWindowSetSizable(loginMenu, false) infoLbl = guiCreateLabel(37, 21, 275, 27, "Welcome to the server, to get started please login/register below! \nYou can view our news by click the news button!\n", false, loginMenu) guiSetFont(infoLbl, "default-small") guiLabelSetColor(infoLbl, 41, 201, 52) usrLbl = guiCreateLabel(147, 55, 48, 15, "Username", false, loginMenu) guiSetFont(usrLbl, "default-small") usrEdit = guiCreateEdit(90, 66, 162, 21, "", false, loginMenu) passLbl = guiCreateLabel(147, 94, 48, 15, "Password", false, loginMenu) guiSetFont(passLbl, "default-small") passEdit = guiCreateEdit(90, 105, 162, 21, "", false, loginMenu) guiEditSetMasked(passEdit, true) loginBtn = guiCreateButton(10, 153, 69, 27, "Login", false, loginMenu) guiSetFont(loginBtn, "default-small") regBtn = guiCreateButton(260, 153, 69, 27, "Register", false, loginMenu) guiSetFont(regBtn, "default-small") newsBtn = guiCreateButton(137, 152, 68, 28, "News", false, loginMenu) guiSetFont(newsBtn, "default-small") showCursor(true) end addEventHandler("onClientResourceStart", getRootElement(), showMenu) --- Register Menu function regPlayer(button,state) if (button == "left" and state == "up") then if (source == regBtn) then username = guiGetText(usrEdit) password = guiGetText(passEdit) triggerServerEvent("acceptRegister", localPlayer, username, password) end end end addEventHandler("onClientGUIClick", getRootElement(), regPlayer) --- Login Menu function logPlayer(button,state) if (button == "left" and state == "up") then if (source == loginBtn) then username = guiGetText(usrEdit) password = guiGetText(passEdit) triggerServerEvent("acceptLogin", localPlayer, username, password) end end end addEventHandler("onClientGUIClick", getRootElement(), logPlayer) --- Disable Login Menu function closeMenu() guiSetVisible(loginMenu,false) showCursor(false) outputChatBox("You have successfully logged in!") end addEvent("hideMenu", true) addEventHandler("hideMenu", getRootElement(), closeMenu) SERVER SIDE --- Registering Event function regPlayer(username,password) if not username == "" then if not password == "" then local account = getAccount(username,password) if account == false then local addAcc = addAccount(username,password) if (addAcc) then triggerClientEvent(source,"hideMenu",getRootElement()) outputChatBox("You have successfully registered!", source) else outputChatBox("There was an error! Please contact an administrator!", source) end end end end end addEvent("acceptRegister",true) addEventHandler("acceptRegister",getRootElement(),regPlayer) --- Logging Event function logPlayer(username,password) if not username == "" then if not password == "" then local account = getAccount(username,password) if ( account ~= false ) then outputChatBox("You have successfully logged in!", source) triggerClientEvent(source,"hideMenu",getRootElement()) else outputChatBox("There was an error! Please contact an administrator!", source) end end end end addEvent("acceptLogin",true) addEventHandler("acceptLogin",getRootElement(),logPlayer) No errors are outputted, but GUI Appears successfully now, any help on how I can fix? GitHub: https://github.com/flyingspoon YouTube: https://www.youtube.com/channel/UClsnd4SEid3gob33DSk1-GQ
Anubhav Posted April 2, 2015 Posted April 2, 2015 Server side 'not' is only used when it is false or nil '~=' is only used when it is not equal to --- Registering Event function regPlayer(username,password) if username ~= "" then if password ~= "" then local account = getAccount(username,password) if account == false then local addAcc = addAccount(username,password) if (addAcc) then triggerClientEvent(source,"hideMenu",getRootElement()) outputChatBox("You have successfully registered!", source) else outputChatBox("There was an error! Please contact an administrator!", source) end end end end end addEvent("acceptRegister",true) addEventHandler("acceptRegister",getRootElement(),regPlayer) --- Logging Event function logPlayer(username,password) if username ~= "" then if password ~= "" then local account = getAccount(username,password) if ( account ~= false ) then logIn( source, account, password ) outputChatBox("You have successfully logged in!", source) triggerClientEvent(source,"hideMenu",getRootElement()) else outputChatBox("There was an error! Please contact an administrator!", source) end end end end addEvent("acceptLogin",true) addEventHandler("acceptLogin",getRootElement(),logPlayer) edit: just found out you never used logIn function. lol See my some resources: Skin shop: https://community.multitheftauto.com/in ... ls&id=8008 Note script: https://community.multitheftauto.com/in ... ls&id=8009 Rules Panel: https://community.multitheftauto.com/in ... ls&id=8246 Random Money: https://community.multitheftauto.com/in ... ls&id=8718
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