Code Obfuscation?

Trying to make an ID System that randomizes a number when a player joins… Any help?

p.s. Didn’t let me change the Name when I edited it… My apologies.



local number = math.random()


???

Yeah, I know that, but would I just set a variable and assign the output to LocalPlayer()?

Just localize everything so your code begins to look like this:


kdmfneicnejsii(skskamdmfjenen, ejdnejdnejdkjenenjeodjn, function()

end )

Then make it all one line.

I believe you’re looking for something like this?

[lua]
function AssignPlayerSerialNumber(pl)
local New_Number = math.random()
local Previously_Assigned = false

for k, v in pairs(player.GetAll()) do
    if v:GetNetworkedInt("Serial_Number") != nil then
        if v:GetNetworkedInt("Serial_Number") == New_Number then
            Previously_Assigned = true
        end
    end
end

if Previously_Assigned then
    return false
end

pl:SetNetworkedInt("Serial_Number", New_Number)
return true

end

hook.Add(“PlayerInitialSpawn”, “Create serial number.”, function(pl)
if AssignPlayerSerialNumber(pl) then
print(“Player serial number successfully set.”)
else
print(“Player serial number already active, trying again.”)
AssignPlayerSerialNumber(pl)
end
end)
[/lua]

[editline]1st March 2016[/editline]

You would want to make this a serverside script.
This will generate a new serial number for players if they disconnect/rejoin.
Using networked variables allows you to access it from the server or a client.

[editline]1st March 2016[/editline]

Also I had made a slight mistake. If the serial number generated is already in use, and the second generated serial number is also in use, a third one will not be created. If you can’t figure out how to make it loop until successful, just let me know and I’ll hep you out. At least give it a shot yourself before hand however if this is the kind of script you had wanted.

[editline]1st March 2016[/editline]

Also the IF statement I created to check if the Serial Number is != nil, that should be removed and modified slightly. It was a quick write up to help give you some understanding, so don’t expect this to work right out of the gate.

Yeah bro. Thanks. I’ll edit it and see what I can come up with it!

[editline]1st March 2016[/editline]


 if (SERVER) then

local plySSN = math.random()


hook.Add( "PlayerSpawn", "FindSSN", function() 
	if ( file.Exists ( ply:Nick() .. ".txt", "DATA/Life/SSNNumbers" ) )
	then print( "Social Security Number Loaded for: " .. ply:Nick() )
	elseif ( file.Write( ply:Nick() .. ".txt", "plySSN" )  )
end
end )
end


Would that work? Saving the SSN into a .txt file?

You should consider using SQL.