Jump to content

Regarding registration limit resource


Recommended Posts

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. :P:P:P:P

Link to comment

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

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
https://wiki.multitheftauto.com/wiki/GetAccountsBySerial

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 
  

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...