kuba90pl Posted November 4, 2011 Posted November 4, 2011 Hi! I wanted to make my own login system so i created : client: function getLoginData (n,p,i) local imie = getPlayerName(getLocalPlayer()) local nick = guiGetText ( edit ) local pass = guiGetText ( edit2 ) n=nick p=pass i=imie triggerServerEvent("getLoginDataServer", getRootElement(), n,p,i) outputChatBox("wyslalem") end function destroyLoginWindow() destroyElement(win) showCursor(false) end addEvent("loginapproved",true) addEventHandler("loginapproved", getRootElement(), destroyLoginWindow) server: function logincheck(name,pass,imie) p=getPlayerFromName(imie) account=getPlayerAccount(p) pass_s=getAccountData(account,"player.pass") name_s=getAccountData(account,"player.nick") if name==name_s and pass==pass_s then outputChatBox("You logged in, welcome back "..imie.." ",p,0,255,0) triggerClientEvent("loginapproved",getRootElement()) else outputChatBox("Wrong password or account name!",p,255,0,0) end end addEvent("getLoginDataServer", true) addEventHandler("getLoginDataServer", getRootElement(), logincheck) but server still cant get player from nick(so its cant get data from account) , i tested this function by adding outputChatBox(imie) and its triggering good from client. Whats the problem?
Castillo Posted November 4, 2011 Posted November 4, 2011 -- client side: function getLoginData () local nick = guiGetText ( edit ) local pass = guiGetText ( edit2 ) local n=nick local p=pass local i=getPlayerName(localPlayer) triggerServerEvent("getLoginDataServer", localPlayer, n,p,i) outputChatBox("wyslalem") end function destroyLoginWindow() destroyElement(win) showCursor(false) end addEvent("loginapproved",true) addEventHandler("loginapproved", getRootElement(), destroyLoginWindow) -- server side: function logincheck(name,pass,imie) local p=source local account=getPlayerAccount(p) local pass_s=getAccountData(account,"player.pass") local name_s=getAccountData(account,"player.nick") if (name==name_s and pass==pass_s) then outputChatBox("You logged in, welcome back "..imie.." ",p,0,255,0) triggerClientEvent("loginapproved",getRootElement()) else outputChatBox("Wrong password or account name!",p,255,0,0) end end addEvent("getLoginDataServer", true) addEventHandler("getLoginDataServer", getRootElement(), logincheck) Try that. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
kuba90pl Posted November 4, 2011 Author Posted November 4, 2011 -- client side: function getLoginData () local nick = guiGetText ( edit ) local pass = guiGetText ( edit2 ) local n=nick local p=pass local i=getPlayerName(localPlayer) triggerServerEvent("getLoginDataServer", localPlayer, n,p,i) outputChatBox("wyslalem") end function destroyLoginWindow() destroyElement(win) showCursor(false) end addEvent("loginapproved",true) addEventHandler("loginapproved", getRootElement(), destroyLoginWindow) -- server side: function logincheck(name,pass,imie) local p=source local account=getPlayerAccount(p) local pass_s=getAccountData(account,"player.pass") local name_s=getAccountData(account,"player.nick") if (name==name_s and pass==pass_s) then outputChatBox("You logged in, welcome back "..imie.." ",p,0,255,0) triggerClientEvent("loginapproved",getRootElement()) else outputChatBox("Wrong password or account name!",p,255,0,0) end end addEvent("getLoginDataServer", true) addEventHandler("getLoginDataServer", getRootElement(), logincheck) Try that. still same , i put right values and still i see Wrong password or account name. my full client with gui for test: ------------------------- ------login window------- function logwindow() local w,s=guiGetScreenSize() showCursor(true) win = guiCreateWindow(w/2-100,-50,315,300,"Oli Login",false) edit = guiCreateEdit(77,75,144,37,"",false,win) edit2 = guiCreateEdit(77,147,144,36,"",false,win) label1 = guiCreateLabel(89,51,125,22,"Name:",false,win) label2 = guiCreateLabel(84,123,125,22,"Password:",false,win) but1 = guiCreateButton(60,235,81,34,"Register",false,win) but2 = guiCreateButton(147,236,81,34,"LogIN!",false,win) radio1 = guiCreateRadioButton(95,191,17,13,"",false,win) guiRadioButtonSetSelected(radio1,true) label3 = guiCreateLabel(112,189,108,18,"I accept rules (OR)",false,win) guiEditSetMasked ( edit2, true ) addEventHandler ( "onClientGUIClick", but2, getLoginData, false ) end addEventHandler("onClientResourceStart", root, logwindow) function getLoginData () local nick = guiGetText ( edit ) local pass = guiGetText ( edit2 ) local n=nick local p=pass local i=getPlayerName(localPlayer) triggerServerEvent("getLoginDataServer", localPlayer, n,p,i) outputChatBox("wyslalem") end function destroyLoginWindow() destroyElement(win) showCursor(false) end addEvent("loginapproved",true) addEventHandler("loginapproved", getRootElement(), destroyLoginWindow) edit: this script is working only when i got logged first by /login pass (build-in mta login system)
Castillo Posted November 4, 2011 Posted November 4, 2011 That's because you're using the MTA built-on system.. getPlayerAccount getAccountData only works for MTA built-on account system. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Charlie_Jefferson Posted November 5, 2011 Posted November 5, 2011 That means you need a database for it to work, doesn't it?
myonlake Posted November 5, 2011 Posted November 5, 2011 That means you need a database for it to work, doesn't it? Yes. You can use a mySQL one or then you can use a XML one (with a password hash on). If I helped you, please click the like button on the right Thanks!
Jaysds1 Posted November 5, 2011 Posted November 5, 2011 Actually, you don't need a mysql, because it's already built in to mta. The internal.dbs is the database with all the players accounts My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
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