Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- do -- player.util
- util = {}
- local universes64 = {
- [ "45036" ] = "0",
- [ "76561" ] = "1",
- [ "14861" ] = "2",
- [ "22067" ] = "3",
- [ "29273" ] = "4",
- [ "36479" ] = "5"
- }
- local bases64 = {
- [ "0" ] = "450360",
- [ "1" ] = "76561",
- [ "2" ] = "14861",
- [ "3" ] = "22067",
- [ "4" ] = "29273",
- [ "5" ] = "36479"
- }
- local offsets64 = {
- [ "0" ] = 3922337792,
- [ "1" ] = 197960265728,
- [ "2" ] = 8791998193664,
- [ "3" ] = 6386036121600,
- [ "4" ] = 3980074049536,
- [ "5" ] = 1574111977472
- }
- function util.IsSteamID64( sParam )
- if type( sParam ) ~= "string" then return end
- return universes64[ string.sub( sParam, 1, 5 ) ]
- end
- function util.IsSteamID32( sParam )
- if type( sParam ) ~= "string" then return end
- return string.match( sParam, "STEAM_([012345]):([01]):(%d+)" )
- end
- function util.ChangeSteamID( sSteamID, sNewUniverse, bTo64 )
- sNewUniverse = tostring( sNewUniverse or 1 )
- if not offsets64[ sNewUniverse ] then return end
- local sUniverse64 = util.IsSteamID64( sSteamID )
- if sUniverse64 then
- if sUniverse64 == sNewUniverse and bTo64 ~= false then return sSteamID end
- local iAccount = tonumber( string.sub( sSteamID, 6 ) ) - offsets64[ sUniverse64 ]
- if bTo64 ~= false then
- return string.format( "%s%s", bases64[ sNewUniverse ], tostring( iAccount + offsets64[ sNewUniverse ] ) )
- else
- local sLow, sHigh = tostring( iAccount % 2 ), tostring( math.floor( iAccount / 2 ) )
- return string.format( "STEAM_%s:%s:%s", sNewUniverse, sLow, sHigh )
- end
- else
- local sUniverse32, sLow, sHigh = util.IsSteamID32( sSteamID )
- if sUniverse32 == sNewUniverse and not bTo64 then return sSteamID end
- if not bTo64 then
- return string.format( "STEAM_%s:%s:%s", sNewUniverse, sLow, sHigh )
- else
- local iAccount = tonumber( sLow ) + tonumber( sHigh ) * 2
- return string.format( "%s%s", bases64[ sNewUniverse ], tostring( iAccount + offsets64[ sNewUniverse ] ) )
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment