StefanAlmighty Posted October 3, 2015 Share Posted October 3, 2015 Quick question. How can I convert an integer value to a string? For example: k = math.random(1,100) I want to convert k from an integer into a string. So if the value k is 41, then I want to convert it to "41". Appreciated, thanks. Link to comment
KariiiM Posted October 3, 2015 Share Posted October 3, 2015 Simply there are two lua functions, 1st = converting to number and 2nd = converting to string tonumber tostring Link to comment
Noki Posted October 5, 2015 Share Posted October 5, 2015 To add onto what KariiM said, tostring() converts anything into a string. local plr = getPlayerFromName("Noki") tostring(isPedOnGround(plr)) will return either "true" or "false" tostring(getPlayerFromName("Noki")) will return a string with the player element of a player named 'Noki' tostring() converts anything into a string However, tonumber() will either return a number (float or integer) or nil if invalid arguments were passed tonumber(dxGetStatus()) will return nil as you cannot convert a table to an integer tonumber("12") will return 12 as an integer Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now