Jump to content

string.find doesn't work properly here


xTravax

Recommended Posts

hi i got a problem guyz

i am using this sort of function to load DM maps but it dont work, it load all other maps even DD and Race

function LoadDMMaps() 
  
   for _,resource in pairs(getResources()) do 
       
      if getResourceInfo(resource,"type") == "map" then 
         if getResourceInfo(resource,"gamemodes") == "race" then 
            if string.find(getResourceInfo(resource,"name"),"[DM]",1) then 
               local MapName = getMapName(resource); 
               local MapAuthor = getMapAuthor(resource); 
               table.insert(Maps.DM,{resource,MapName,MapAuthor}); 
               outputDebugString("loading dm maps... count: "..(#Maps.DM),0,0,187,255); 
            end; 
         end; 
      end; 
   end; 
end; 
setTimer(LoadDMMaps,50,1) 

why does this happen? it's suppose to put in table only maps which have [DM] in their names...

Link to comment

try this

function LoadDMMaps() 
  
   for _,resource in pairs(getResources()) do 
      
      if getResourceInfo(resource,"type") == "map" then 
         if getResourceInfo(resource,"gamemodes") == "race" then 
            if string.find(getResourceInfo(resource,"name"),"[DM]",1, true) then 
               local MapName = getMapName(resource); 
               local MapAuthor = getMapAuthor(resource); 
               table.insert(Maps.DM,{resource,MapName,MapAuthor}); 
               outputDebugString("loading dm maps... count: "..(#Maps.DM),0,0,187,255); 
            end; 
         end; 
      end; 
   end; 
end; 
setTimer(LoadDMMaps,50,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...