Newbie Posted March 23, 2015 Posted March 23, 2015 (edited) Read Lower Edited March 24, 2015 by Guest
WhoAmI Posted March 23, 2015 Posted March 23, 2015 Where is defined 'thePlayer' argument? Also I'm not sure if you can execute register/login commands serverside or you can execute this command at all.
Newbie Posted March 23, 2015 Author Posted March 23, 2015 You can only execute commands created by Lua. You cannot execute MTA harcoded commands due to security reasons. Oh..
Newbie Posted March 23, 2015 Author Posted March 23, 2015 outputChatBox("Error creating account, contact the server admin.",source) Client addEventHandler("onClientGUIClick", root, function (button, state) if button == "left" and state == "up" then if (source == buttonHover) then username = exports.dxEditBox:getText( "1" ) password = exports.dxEditBox:getText( "2" ) triggerServerEvent("register1", localPlayer, username, password) outputChatBox("Username: ".. username .." Password: " .. password .."",255,255,255,true) end end end) Server function registerr( username, password ) if(password ~= "" and password ~= nil and username ~= "" and username ~= nil) then local accountAdded = addAccount(username,password) if(accountAdded) then outputChatBox("Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login",source) else outputChatBox("Error creating account, contact the server admin.",source) end else outputChatBox("Error creating account, correct syntax: /register ",source) end end addEvent( "register1", true ) addEventHandler( "register1", root, registerr )
Enargy, Posted March 23, 2015 Posted March 23, 2015 function registerr( username, password ) if not ( username == "") and ( not password == "" ) then local accountAdded = addAccount(username,password) if(accountAdded) then outputChatBox("Thank you " .. getPlayerName(source) .. ", you're now registed, you can login with /login",source) else outputChatBox("Error creating account, contact the server admin.",source) end else outputChatBox("Error creating account, correct syntax: /register ",source) end end addEvent( "register1", true ) addEventHandler( "register1", root, registerr ) EDIT: check if this code gives you the text needed; username = exports.dxEditBox:getText( "1" ) password = exports.dxEditBox:getText( "2" ) outputChatBox("name: "..username.. " | pass: "..password)
Addlibs Posted March 23, 2015 Posted March 23, 2015 (edited) You can only execute commands created by Lua. You cannot execute MTA harcoded commands due to security reasons. Actually, /register is a Lua command, handled by the admin panel Lines 447-468 of admin/server/admin_server.lua Edited March 23, 2015 by Guest
Newbie Posted March 23, 2015 Author Posted March 23, 2015 I'll already did it by other way. It adds account! function registerr ( username, password ) if ( username and password and type ( username ) == 'string' and type ( password ) == 'string' ) then account = addAccount ( username, password ) exports.bar_messages:outputMessageBar("Successfully signed up! Now you can play", source, 0, 0, 0, 5000) end end addEvent( "register1", true ) addEventHandler( "register1", root, registerr ) How can i make that when player click's register button "as shown upper" to check if account already exists ?
Newbie Posted March 24, 2015 Author Posted March 24, 2015 Thanks for help. I've taken server sided code from MTASA Resources. Changed variables, it working fine now.
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