I do have a question... when using "tostring( item.UserID )" in the print statement it returns a ulong in the output...
[Oxide] Rejecting client (7.6561197977418e+016 in banlist)
I spent a little time trying to see if I could get the actual ID (76561197977418126) using math.floor function but I could never
get it to print correctly. It always displayed as a ulong. Any ideas on how to correct that?
Thanks
Solved Converting ulong to string
Discussion in 'Rust Development' started by kbenton00, Mar 30, 2014.
-
Code:
string.format("%17.0f",item.UserID )
-
Thanks ZOR... worked great!
-
Hi everyone
i'm trying to convert ulong to string but i'm having NO luck
Code:local GetUsers, SetUsers = typesystem.GetField( Rust.PasswordLockableObject, "_validUsers", bf.private_instance ) --local PasswordLockableObject = cs.gettype( "PasswordLockableObject, Assembly-CSharp") --local HasAccess = util.GetStaticMethod( Rust.PasswordLockableObject, "HasAccess", bf.public_static, { System.UInt64 } ) function PLUGIN:CanOpenDoor( netuser, door ) local deployable = door:GetComponent( "DeployableObject" ) if (not deployable) then return end if(self.AdminLive[netuser]) then local lockable = door:GetComponent( "PasswordLockableObject" ) local hashset = GetUsers(lockable) local it = hashset:GetEnumerator() while (it:MoveNext()) do print(cs.readulongfieldasstring( it.Current, it.Current )) end end end
and using: cs.readulongfieldasstring , well i'm not really getting a field so ...
anybody got an idea? -
Have u tried it.Current:ToString() ?
or u could try just getting the value out of the ulong - > m_value;
or u could make and array out of it and have cs.convertandsetonarray handle it.
or just check access with the HasAccess method on the PasswordLockableObject. -
it.Current:ToString() i tried ^^ doesnt work
or u could try just getting the value out of the ulong - > m_value ??? how i don't really get it!
cs.convertandsetonarray => i'll defenitly try it!!!! ty for the tip!
or just check access with the HasAccess method on the PasswordLockableObject => tried ... failed, because i can only get from online players with rust.GetLongUserID,
i want to make a plugin so we can see who have access to a door. -
-
Î know how to do it for online players, but not offline players
[DOUBLEPOST=1409579120,1409536557][/DOUBLEPOST]ok tried but fail again:
Code:local steamid = rust.CommunityIDToSteamID( tonumber(userid) ) local steamid64 = tostring(self:ToSteamID64(steamid)) print(steamid64) local idArr = util.ArrayFromTable( System.Object, { steamid64 }, 1 ) cs.convertandsetonarray( idArr, 0, steamid64, System.UInt64._type ) print(tostring(idArr[0])) print(type(idArr[0]))
[Oxide] 7.6561197977715e+016
[Oxide] number
it shows me this, -
Wulf Community Admin
Did you ever figure out an elegant way of handling this? Running into this issue with Rust Experimental as well. The below options work, but they round up which we wouldn't want.
Code:string.format("%.0f", userid)
Code:string.format("%17.0f", userid)
-
-
Wulf Community Admin
-
rust.UserIDFromConnection and rust.UserIDFromPlayer have been added to Oxide 2, should be able to use those as a work-around for now. They return the user ID as a string.