ID:163444
 
Is there a way to check filesizes in byond?

I want a custom icon verb for a game however the players are immature sometimes and it also leaves the game vulnerable to spamming massive custom icons and bogging down the server.


So is there any way to limit the size of the icons a player can use?
proc/File_Size(size,value_format)
if(!size || !isnum(size)) return
var/ending = "Byte"
if(size >= 1024)
size /= 1024
ending = "KB"
if(size >= 1024).
size /= 1024
ending = "MB"
if(size >= 1024)
size /= 1024
ending = "GB"
if(value_format == "num")
return size
if(value_format == "text")
return "[num2text(size,100)] [ending]\s"



What it does is it checks to see if the size is greater than 1024 (1024= KiloByte). If the size is bigger than 1024, it divides it by 1024, now the Size is in KB. And it does the same thing for MB and GB which you probably won't need, but who knows you might need it. If there isn't a value for size or if the size isn't a number then it will stop.
In response to LifeSavers
Or, you know, you could use the length() function.