neal777 Posted May 6, 2015 Share Posted May 6, 2015 I have a server since 1 month ago. The server has been growing rapidly so is registrations. Players are creating as many accounts as they like. The is okay at the moment but it will create confusion and lag later on. I am a beginner at scripting (especially Lua) and I can't get my head around to make a decent script that stops players creating more than 2 account which should be based on MTA serial. Basically 2 accounts per serial. Any help will be appreciated, even better if there is already this kind of script available on community then please share the link there. Link to comment
xXMADEXx Posted May 7, 2015 Share Posted May 7, 2015 When someone registers, loop through the table that getAccounts returns, then use getAccountSerial and compare the players serial to that. If they're the same, cancel the function and send an error. Here's an example: function _registerPlayer ( user, pass, player ) for _, account in pairs ( getAccounts ( ) ) do if ( getAccountSerial ( account ) == getPlayerSerial ( player ) ) then outputChatBox ( "An account with this serial already exists!", player, 255, 0, 0 ); return false; end end --- Complete the registration code here return true; end Link to comment
Anubhav Posted May 7, 2015 Share Posted May 7, 2015 https://wiki.multitheftauto.com/wiki/Ge ... tsBySerial Better way function _registerPlayer ( user, pass, player ) if ( #getAccountsBySerial( getPlayerSerial( player ) ) == 2 ) then outputChatBox ( "Max account limit reached!", player, 255, 0, 0 ); return false; end --- Complete the registration code here return true; end Link to comment
3B00DG4MER Posted May 7, 2015 Share Posted May 7, 2015 https://wiki.multitheftauto.com/wiki/GetAccountsBySerialBetter way function _registerPlayer ( user, pass, player ) if ( #getAccountsBySerial( getPlayerSerial( player ) ) == 2 ) then outputChatBox ( "Max account limit reached!", player, 255, 0, 0 ); return false; end --- Complete the registration code here return true; end Sometimes he have more than 2 cuz the resource is not running -.- function _registerPlayer ( user, pass, player ) if ( #getAccountsBySerial( getPlayerSerial( player ) ) > 1 ) then outputChatBox ( "Max account limit reached!", player, 255, 0, 0 ); return false; end --- Complete the registration code here return true; end Link to comment
Anubhav Posted May 7, 2015 Share Posted May 7, 2015 OMG Guyz, why don't you read? He told 2 account / serial. Get it? Not to be rude here, but yeah, learn to read before posting Link to comment
neal777 Posted May 12, 2015 Author Share Posted May 12, 2015 (edited) Thank you everyone for helping me. Edited July 2, 2015 by Guest Link to comment
neal777 Posted May 15, 2015 Author Share Posted May 15, 2015 xXMADEXx, your example helped me a lot. In fact only your short line of script is the only one that works compared to Anubhav and 3B00DG4MER. Thank you. :) Link to comment
TAPL Posted May 15, 2015 Share Posted May 15, 2015 Be aware getAccountSerial only return the last serial that logged into the account and empty if no one has logged into the account before, so you better off use account data to store the serial. 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