Way to only read whole numbers? - 28/07/15 03:42 PM
I have a code for my twitch bot that gives the top 1-10 users with the most points in chat. As always people try to break the bot and have started doing commands like !top 4.5345454 The code will still show the top 4 but it will repeat "the top 4.5345454 users are..."
Is there a way to only allow it to read whole numbers because when people make very long numbers after the decimal it makes the chat quite spammy.
The code is
Is there a way to only allow it to read whole numbers because when people make very long numbers after the decimal it makes the chat quite spammy.
The code is
Code:
on *:text:!top*:#: { if ($2 < 1 || $0 < 2) { msg $chan /me $nick to use the !top command you must specify a positive number. } elseif ($2 > 10) { msg $chan /me $nick you cannot specify a number greater than 10. } else { var %ID = $ini(%rosterFile, 0) if ($2 > %ID) { msg $chan /me $nick there are only %ID people in the level system. } else { write -c %topFile var %topList = The $2 highest level users: var %i = 1 while (%i <= $2) { $getTopID() var %name = $readini(%topFile, %i, name) var %points = $readini(%topFile, %i, levels) if (%i != $2) { %topList = $+(%topList, $chr(32), %name, $chr(32), %points, $chr(44)) } else { %topList = $+(%topList, $chr(32), %name, $chr(32), %points) } inc %i } msg $chan /me %topList } } } // ------------------------------------------------------------------------------------------------------------------------ // Format: $getTopID() // Gets the ID with the highest number of points that is not already in the temp file alias -l getTopID { var %rosterID = $ini(%rosterFile, 0) var %topID = $ini(%topFile, 0) var %highestPoints = 0 var %highestID = -1 var %i = 1 while (%i <= %rosterID) { var %points = $readini(%rosterFile, %i, levels) if (%points >= %highestPoints) { var %topNameFound = $false var %j = 1 while (%j <= %topID) { var %name = $readini(%rosterFile, %i, name) var %topName = $readini(%topFile, %j, name) if (%name == %topName) { %topNameFound = $true break } inc %j } if (%topNameFound == $false) { %highestPoints = %points %highestID = %i } } inc %i } var %highestName = $readini(%rosterFile, %highestID, name) writeini -n %topFile $calc(%topID + 1) name %highestName writeini -n %topFile $calc(%topID + 1) levels %highestPoints }