Jump to content

Changing account serial


itHyperoX

Recommended Posts

Hi.

I made a script, which is save player serial when they register to the server.

 

I want to create script, for admins can change player serial when they reinstalled the windows and can't login their accounts.

 

What i need?

 

I saving the serial with  

setAccountData(getPlayerAccount(player),"account:protect",serial)

 

Maybe what i need is looks like this:

 

function changeserial(player,command,account, ...)
local newSerial = table.concat({ ... }, " ")
setAccountData(getPlayerAccount(account),"account:protect",newSerial)
 outputChatBox("You succesfully changed "..account.." serial to: "..newSerial,player,255,255,255,true)
end
addCommandHandler("changeserial",changeserial)

 

Anybody can give me any example ?

Fixed!

 

function setAccountSerial(thePlayer,key,key,...)
local account = getPlayerAccount(thePlayer)
local newSerial = table.concat({ ... }, " ")
if account and #newSerial > 0 then
        setAccountData(account,"account:protect",newSerial)
    end
end
addCommandHandler("changeserial",setAccountSerial)

 

Edited by TheMOG
Link to comment

What's the concatenation for? Serial is one long string, First of all, you will need to get all the accounts and check if the account name entered via the command actually points to an account and then change the serial of that given account. Try this:

 

function setAccountSerial(p, cmd, target, serial)
	if target and target ~= "" and serial and serial ~= "" then
		local accounts = getAccounts()
		for i = 1, #accounts do
			if(getAccountName(accounts[i]) == target) then
				local oldSerial = getAccountData(accounts[i], "account:protect") or "none"
				setAccountData(accounts[i], "account:protect", serial)
				outputChatBox("User " .. target .. "'s serial has been updated", p)
				outputChatBox("-> Old: ".. oldSerial .."| New: " .. serial, p)
				return
			end
		end
		outputChatBox("Couldn't find any users with the name: " .. target, p)
	else
		outputChatBox("Syntax: /"..cmd.." [account-name] [serial]", p)
	end
end
addCommandHandler("changeserial",setAccountSerial)

 

  • Like 1
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...