How to convert 7.6561198001288e+016 to a regular string steamid OR vice versa, convert a regular string steamid into ulong format (7.6561198001288e+016)
Solved Ulong to string? (Lua)
Discussion in 'Rust Development' started by Rusty, Feb 24, 2016.
-
Wulf Community Admin
You'd need to use one of the library helpers in Oxide if you are using Lua, as it can't handle them natively.
-
Im using LUA yes, which one of library helpers should i use? or where do i get info on those?
-
Wulf Community Admin
-
See i dont have a player when im doing this routine, all i have is the steamid in string format, and i need to convert it to long.
-
Wulf Community Admin
-
Would string.format work? is it worth testing with it?
-
-
Cupboard auth list comes in ulong format, my steamid is in regular string format, i would like to convert so i can compare them.
-
Wulf Community Admin
-
I know but..not a lot of time to learn a new language, anyway that, from the kindness of your heart you could maybe show me a quick snippet on how to call the value from a csharp snipet? (external call)
-
Using format (I think it was "%.0f") you can format the ID like you want, but that doesn't solve the issue.
The core issue is that Rust gives you an int64, and Lua converts the int64 to a number.
A number is just a float64, and is not precise enough to hold int64s. It will truncate the ID.
There is no way to do this except for using an API that converts IDs to strings while still using a language that has int64s (such as Python or C#).
Such a plugin in your case would be EntityOwner. -
Yea i came to that conclusion, im willing to call it from a csharp plugin ..whats an easy way to feed in the ulong and get a string value?
string ulongtostring(ulong)
{
return ulongasstring
}
--- Any easy way to achieve this in C?
[DOUBLEPOST=1456465496,1456438783][/DOUBLEPOST]I guess lets work on the lua extension, i know int64s is available in the newer versions. -
{
return ulong.ToString();
}
This should work perfectly fine, no? I didn't test it/check the syntax, but I think this should work. -
It still rounds it up but i found a work around, i pass the PlayerNameID var to the CS plugin and then returns the proper PlayerNameID.userid
Thanks for help everyone!