Jump to content

does serial exist


JimmyJ

Recommended Posts

This should be working. Though if you have tons of accounts (e.g. more than a thousand), spamming the function might slow down the server. The code is untested, report if any problems found.

function isRegisteredWithSerial(serial) 
 local accounts = getAccounts() 
 for i=1,#accounts do 
   local acc = accounts[i] 
   local srl = getAccountData(acc,"serial") 
   if srl == serial then -- If we found an account with the serial 
      return true -- Return true 
   end 
 end 
 return false -- Unless the interation finished and found nothing, return false 
end 
  
function onLogin(prev,new) 
   -- Get the logged account serial 
   local srl = getAccountData(new,"serial") 
   if not srl then -- If the account doesn't have serial info yet 
      setAccountData(new,"serial",getPlayerSerial(source)) -- Write it with the player's serial 
   end 
end 
addEventHandler("onPlayerLogin",getRootElement(),onLogin) 
  
function customFunctionToCheck(player) 
   local isreg = isRegisteredWithSerial(getPlayerSerial(player)) 
   if isreg == true then 
      outputChatBox("You have an account with your serial") 
   else 
      outputChatBox("Nope, you're not owning any account") 
   end 
end 
addCommandHandler("check",customFunctionToCheck) 

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