TorNix~|nR Posted March 27, 2017 Share Posted March 27, 2017 Hi guys, I working on script thats make players can't register more two account but don't work and when test to see how many accounts i have i see one account but i registered more then 3 accounts but when i see database (internal.db) i see my accounts don't register ip and serial sorry for my english Link to comment
MTA Team ccw Posted March 27, 2017 MTA Team Share Posted March 27, 2017 ip and serial are set during login 2 Link to comment
Fist Posted March 28, 2017 Share Posted March 28, 2017 when someone register's just set new value for account data setAccountData(account-here,"serial",getPlayerSerial(player-here)); and then just find all accounts with data serial and if they are more than 2 that are equal to player's serial then just cancel register, simple as that. 1 Link to comment
TorNix~|nR Posted March 28, 2017 Author Share Posted March 28, 2017 Sorry ,I don't understand Link to comment
itHyperoX Posted March 28, 2017 Share Posted March 28, 2017 (edited) I dont know how you can make that maybe the pro can help you. @NeXuS™, when the serial is used, but something this: local bRegisteredOnce = false addCommandHandler("register",function(source,commandName,username,password) local theSerial = getPlayerSerial( source ) --> Serial -- Here something for cancelevent if the serial in use if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and bRegisteredOnce == false and (string.len(username)>=4) and (string.len(password)>=4) ) then local accountAdded = addAccount(username,password) if(accountAdded) then outputChatBox("Account added",source) local account = getAccount(username,password) setAccountData(account,"Serial",theSerial) bRegisteredOnce = true else end else if bRegisteredOnce == true then else end end end) Edited March 28, 2017 by TheMOG Link to comment
Abdul KariM Posted March 28, 2017 Share Posted March 28, 2017 Use this check at register Whether login-panel or admin-panel And do not forget the definition of the player if ( #getAccountsBySerial ( getPlayerSerial ( source ) ) >= 1 ) then -- You're Code For example outputChatBox - it's a don't he can register more from one account return end Link to comment
NeXuS™ Posted March 28, 2017 Share Posted March 28, 2017 17 minutes ago, Abdul KariM said: Use this check at register Whether login-panel or admin-panel And do not forget the definition of the player if ( #getAccountsBySerial ( getPlayerSerial ( source ) ) >= 1 ) then -- You're Code For example outputChatBox - it's a don't he can register more from one account return end The main problem with this is if you register your account, but don't LOG IN, your serial wont be saved into the database, and you can register as many accounts as you want. Link to comment
Abdul KariM Posted March 28, 2017 Share Posted March 28, 2017 This Check If he want register , and for solve the problem brings a account the first from database by serial and delete other accounts Link to comment
NeXuS™ Posted March 28, 2017 Share Posted March 28, 2017 I dont think you understood whats the issue with your code. And I dont understand a word from what you just said. Link to comment
itHyperoX Posted March 28, 2017 Share Posted March 28, 2017 @Abdul KariM thats it what the guy need. here you go all in one addCommandHandler("register",function(source,cmd,username,password) if (#getAccountsBySerial(getPlayerSerial(source)) >= 1 ) then outputChatBox("You are already registered!.",source,255,255,255,true) return end if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and (string.len(username)>=4) and (string.len(password)>=4) ) then local accountCreated = addAccount(username,password) if (accountCreated) then outputChatBox("You Succesfully registered.",source,255,0,0,true) else outputChatBox("Contact with the admin.",source,255,0,0,true) end else outputChatBox("The username and password must be 4 character.",source,255,0,0,true) outputChatBox(" /register [Username] [Password]",source,255,255,255,true) end end) Link to comment
xeon17 Posted March 28, 2017 Share Posted March 28, 2017 Create your own account system, best solution. Link to comment
NeXuS™ Posted March 29, 2017 Share Posted March 29, 2017 6 hours ago, TheMOG said: @Abdul KariM thats it what the guy need. here you go all in one addCommandHandler("register",function(source,cmd,username,password) if (#getAccountsBySerial(getPlayerSerial(source)) >= 1 ) then outputChatBox("You are already registered!.",source,255,255,255,true) return end if(password ~= "" and password ~= nil and username ~= "" and username ~= nil and (string.len(username)>=4) and (string.len(password)>=4) ) then local accountCreated = addAccount(username,password) if (accountCreated) then outputChatBox("You Succesfully registered.",source,255,0,0,true) else outputChatBox("Contact with the admin.",source,255,0,0,true) end else outputChatBox("The username and password must be 4 character.",source,255,0,0,true) outputChatBox(" /register [Username] [Password]",source,255,255,255,true) end end) This one won't work either, because of IP and serial are set during login. Link to comment
Thrzu Posted March 29, 2017 Share Posted March 29, 2017 local maxAccountAmout = 3 local query = executeSQLQuery ( "SELECT * FROM accounts WHERE serial=?", getPlayerSerial ( source ) ) if ( query and #query >= maxAccountAmout ) then outputChatBox("You can't register more than "..maxAccountAmout.." accounts.", source, 0, 255, 0) return false end I was hesitating about posting this but i hope it works. Link to comment
NeXuS™ Posted March 29, 2017 Share Posted March 29, 2017 1 hour ago, Thrzu said: local maxAccountAmout = 3 local query = executeSQLQuery ( "SELECT * FROM accounts WHERE serial=?", getPlayerSerial ( source ) ) if ( query and #query >= maxAccountAmout ) then outputChatBox("You can't register more than "..maxAccountAmout.." accounts.", source, 0, 255, 0) return false end I was hesitating about posting this but i hope it works. Again, won't work. Check my comment above bud. Your IP and serial gets set into the database when you LOG IN. So if you just have a register, but no login, you can register as many accounts as you want. Link to comment
MTA Team ccw Posted March 29, 2017 MTA Team Share Posted March 29, 2017 What about modifying the register command to also log the player in, so the serial and ip get set. Something like: if ( #getAccountsBySerial(getPlayerSerial(thePlayer)) == 0 ) logOut( thePlayer ) local account = addAccount( username, password ) logIn( thePlayer, account, password ) logOut( thePlayer ) end Link to comment
NeXuS™ Posted March 29, 2017 Share Posted March 29, 2017 @ccw, or you could this. executeSQLQuery("UPDATE accounts SET serial=?, ip=? WHERE name=?", getPlayerSerial(source), getPlayerIP(source), username) But I think your method is easier for begginer scripters. Link to comment
TorNix~|nR Posted March 29, 2017 Author Share Posted March 29, 2017 guys thanks for replying @TheMOG I won't it by command. I want it with the panel this is the Register, @xeon17 helped me on this Code -- Registration here function registerPlayer(username,password,passwordConfirm) if (getAccountCount(source) >= 2) then return end if not (username == "") then if not (password == "") then if not (passwordConfirm == "") then if password == passwordConfirm then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then triggerClientEvent(source,"hideRegisterWindow",getRootElement()) outputChatBox ("#0000FF* #FFFFFFYou have sucessfuly registered! [Username: #ABCDEF" .. username .. " #FF0000| #FFFFFFPassword: #ABCDEF" .. password .. "#FFFFFF]",source,255,255,255,true ) setTimer(outputChatBox,800,1,"#0000FF* #FFFFFFYou can now login with your new account.",source,255,255,255,true ) else outputChatBox ("#0000FF* #FFFFFFAn unknown error has occured! Please choose a different username/password and try again.",source,255,255,255,true ) end else outputChatBox ("#0000FF* #FFFFFFError! An account with this username already exists!",source,255,255,255,true ) end else outputChatBox ("#0000FF* #FFFFFFError! Passwords do not match!",source,255,255,255,true) end else outputChatBox ("#0000FF* #FFFFFFError! Please confirm your password!",source,255,255,255,true) end else outputChatBox ("#0000FF* #FFFFFFError! Please enter a password!",source,255,255,255,true) end else outputChatBox ("#0000FF* #FFFFFFError! Please enter a username you would like to register with!",source,255,255,255,true) end end function getAccountCount(player) local serial = getPlayerSerial(player) local accounts = getAccountsBySerial(serial) if(accounts) and (type(accounts == "table")) then return #accounts end return false end Link to comment
NeXuS™ Posted March 29, 2017 Share Posted March 29, 2017 (edited) -- Registration here function registerPlayer(username,password,passwordConfirm) if (getAccountCount(source) >= 2) then return end if not (username == "") then if not (password == "") then if not (passwordConfirm == "") then if password == passwordConfirm then local account = getAccount (username,password) if (account == false) then local accountAdded = addAccount(tostring(username),tostring(password)) if (accountAdded) then triggerClientEvent(source,"hideRegisterWindow",getRootElement()) outputChatBox ("#0000FF* #FFFFFFYou have sucessfuly registered! [Username: #ABCDEF" .. username .. " #FF0000| #FFFFFFPassword: #ABCDEF" .. password .. "#FFFFFF]",source,255,255,255,true ) logOut(source) logIn(source, accountAdded, password) logOut(source) setTimer(outputChatBox,800,1,"#0000FF* #FFFFFFYou can now login with your new account.",source,255,255,255,true ) else outputChatBox ("#0000FF* #FFFFFFAn unknown error has occured! Please choose a different username/password and try again.",source,255,255,255,true ) end else outputChatBox ("#0000FF* #FFFFFFError! An account with this username already exists!",source,255,255,255,true ) end else outputChatBox ("#0000FF* #FFFFFFError! Passwords do not match!",source,255,255,255,true) end else outputChatBox ("#0000FF* #FFFFFFError! Please confirm your password!",source,255,255,255,true) end else outputChatBox ("#0000FF* #FFFFFFError! Please enter a password!",source,255,255,255,true) end else outputChatBox ("#0000FF* #FFFFFFError! Please enter a username you would like to register with!",source,255,255,255,true) end end function getAccountCount(player) local serial = getPlayerSerial(player) local accounts = getAccountsBySerial(serial) if(accounts) and (type(accounts == "table")) then return #accounts end return false end This one should work without any problems. Your code above has a problem in it, which we were discussing above. Edited March 29, 2017 by NeXuS™ Link to comment
TorNix~|nR Posted March 29, 2017 Author Share Posted March 29, 2017 Finally guys, it's worked fine, now it saves the serial on internal.db, thank you all. 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