Jump to content

[HELP] Phone Number System


_Perfect_

Recommended Posts

Hello

I have a phone number system
Each player has a seven-digit number

To figure out what player's number is, we use the command / number
And the server tells us:

Number is : 1234567

Please teach me to work with strings so I can do the first three digits of the phone number from the last four digits.

like this :

Number is 123-4567

 

@Dimos7 @LilDawage 

@IIYAMA @KINGKHAN @MrTasty @Dimos7 @LilDawage @MrKAREEM

plz help me :(

 

Link to comment

Depending on whether the 7 digit number is a real number or a string containing digits.

function formatNumber(number)
  if (type(number)=="number") then -- if 'number' was a number rather than a string
    number = string.format("%07d", number) -- format the number into 7 digits padded by 0 from the front if the number is less than 1000000
  end
  if (type(number)~="string") then return false end -- return a false and exit function if 'number' isn't a string at this point
  return string.sub(number, 1, 3) .. "-" .. string.sub(number, 4, -1) -- put characters 1 to 3, follow it with a dash, and characters 4+
end
Edited by MrTasty
Link to comment
1 hour ago, MrTasty said:

Depending on whether the 7 digit number is a real number or a string containing digits.


function formatNumber(number)
  if (type(number)=="number") then -- if 'number' was a number rather than a string
    number = string.format("%07d", number) -- format the number into 7 digits padded by 0 from the front if the number is less than 1000000
  end
  if (type(number)~="string") then return false end -- return a false and exit function if 'number' isn't a string at this point
  return string.sub(number, 1, 3) .. "-" .. string.sub(number, 4, -1) -- put characters 1 to 3, follow it with a dash, and characters 4+
end

thanks ❤️ 

  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...