'rdmmap
'1.0
'RandomMap:The-Black-Ninja
'&newmap = Picks a new random Map
'&3413
'&Be sure your map file is not empty or the script will error.


Const rdmmap_cmd = "randmap"
rdmmap_FilePath = BotPath & "plugins\maps.txt"


Set rdmmapFSO = CreateObject("Scripting.FileSystemObject")


Sub rdmmap_Event_Load()

   Randomize
End Sub


Sub rdmmap_Event_Usertalk(Username, Flags, Message, Ping)

   GetDBEntry Username, myAccess, myFlags
   If LCase(Message) = BotVars.Trigger & rdmmap_cmd Then
      Set File = rdmmapFSO.OpenTextFile(rdmmap_FilePath, 1, True)
          mapList = Split(File.ReadAll, vbNewLine)
      File.Close
      
      x = 0
      For Each map In mapList
         If map <> vbNullString Then x = x + 1
      Next
      
      randMap = Int(Rnd * x) + 1
      
      y = 0
      For Each map In mapList
         If map <> vbNullString Then
            y = y + 1
            If y = randMap Then actualMap = map
         End If
      Next
   
      Dsp 1, "Random Map: " & actualMap, Username, vbGreen
   End If
End Sub