• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Function]Comma seperated values!

T0MBIE

Senior Coder
Joined
Nov 25, 2009
Messages
96
Reaction score
4
Location
Paki
Hi folks!
i just thought i would share this function with the ppl that do your own scripts ;)
you deserve this, anyway.
(this is just like php number_format)

lib/050-function.lua
Code:
function comma_value(amount)
  local formatted = amount
  while true do  
    formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
    if (k==0) then
      break
    end
  end
  return formatted
end

How to use?

Simple!
$value = 1234567
doCreatureSay(cid, comma_value($value) )

this will result in:
1,234,567

simple and effective, perfect for everyones banking system!
hard to read your bank value with 12 digits ;)
 
Back
Top