Sign in to follow this  
.:HyPeX:.

Map finding issues..

Recommended Posts

Well, i'm not totally sure whats going on here...

  
addCommandHandler("as", function(player,cmd,mapstring) 
    for i,v in ipairs(exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName( "race" ))) do 
    local name = getResourceInfo(v,"name") 
        if name then 
            if string.find(mapstring:lower(), name:lower()) then 
            outputChatBox(name) 
            end 
        end 
    end 
end) 
  

This is the outputchatbox of "name" loop.

  
[DM] CooN Vol4 - Peaceful Finale 
[DM]FiNN v.4 - Hogwarts 
[DM] HeHu & CooN - Speed Chronicles 
[DM] Nice v.7 - Industrial Skill's™ 
[DM] NitroN ft. FakeDeath - Phenomenal 
[DM] Packy 卐 vol.12 卐 .Conspiration. 卐 
[DM] Quantum ft. FakeDeath ft. Micra ft. ZenoS - Sheer Cold 
[DM] RaGeX v3 - The Blue Dusk 
[DM]Rafinha ft Lemon ft Naval - We Just Wanna Run 
[DM] [b]oost ft. VantaGe - Forest Situation II 

However,/as forest wont return the last map, Forest Situation II.

PD: (I actually have 10 maps)

Share this post


Link to post
addCommandHandler("as", function(player,cmd,mapstring) 
    for i,v in ipairs(exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName( "race" ))) do 
    local name = getResourceInfo(v,"name") 
        if name then 
            if string.find(mapstring:lower(), name:lower(), 1, true) then 
            outputChatBox(name) 
            end 
        end 
    end 
end) 

Share this post


Link to post

No matches, no debug errors. Tried outputing whats going on...

  
addCommandHandler("as", function(player,cmd,mapstring) 
    for i,v in ipairs(exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName( "race" ))) do 
    local name = getResourceInfo(v,"name") 
        if name then 
        outputChatBox(name:lower()) 
        outputChatBox(mapstring:lower()) 
        if string.find(mapstring:lower(), name:lower(),1,true) then 
            outputChatBox(name) 
            end 
        end 
    end 
end) 

  
[dm] coon vol4 - peaceful finale 
forest 
[dm]finn v.4 - hogwarts 
forest 
[dm] hehu & coon - speed chronicles 
forest 
[dm] nice v.7 - industrial skill's™ 
forest 
[dm] nitron ft. fakedeath - phenomenal 
forest 
[dm] packy 卐 vol.12 卐 .conspiration. 卐 
forest 
[dm] quantum ft. fakedeath ft. micra ft. zenos - sheer cold 
forest 
[dm] ragex v3 - the blue dusk 
forest 
[dm]rafinha ft lemon ft naval - we just wanna run 
forest 
[dm] [b]oost ft. vantage - forest situation ii 
forest 

Share this post


Link to post

Well found out.. the values of string.find were mixed up :D

Anyways, i'm not sure, how do i make the way to find more parts of a name than a single word?

Greetz

Share this post


Link to post
  
addCommandHandler("as",  
    function(player, cmd, ...) 
        local parts = table.concat({ ... }, " ") 
        for i, v in ipairs(exports.mapmanager:getMapsCompatibleWithGamemode(getResourceFromName( "race" ))) do 
            local name = getResourceInfo(v,"name") 
            if name then 
                if string.find(name:lower(), parts:lower(), 1, true) then 
                    -- Your code here 
                end 
            end 
        end 
    end 
) 
  

Share this post


Link to post

Great! thanks!

Now i've got an issue, when the text is too long i decided to loop it, but there's a problem, whenever the table is over i'm not sure what to do... (It gives errors)

  
if ClanWar.General.MapRotationInfo[nC + 1] then 
smt = string.split(ClanWar.General.MapRotationInfo[nC + 1][1]) 
local i = interpolateBetween(0,0,0,#smt,0,0,progress, "Linear") 
local i = math.floor(i) 
dxDrawText("1."..smt[1+i]..smt[2+i]..smt[3+i]..smt[4+i]..smt[5+i]..smt[6+i]..smt[7+i]..smt[8+i]..smt[9+i]..smt[10+i], x*0.025, y*0.5, x*0.2, y*0.525, tocolor(255,255,255,255), 0.5, "bankgothic", "left", "center") 
else 
dxDrawText("1. No Map Selected", x*0.025, y*0.5, x*0.2, y*0.525, tocolor(255,255,255,255), 0.5, "bankgothic", "left", "center") 
end 

Share this post


Link to post
if ClanWar.General.MapRotationInfo[nC + 1] then 
    smt = string.split(ClanWar.General.MapRotationInfo[nC + 1][1]) 
    local i = interpolateBetween(0,0,0,#smt,0,0,progress, "Linear") 
    local i = math.floor(i) 
    dxDrawText("1."..(smt[1+i] or "")..(smt[2+i] or "")..(smt[3+i] or "")..(smt[4+i] or "")..(smt[5+i] or "")..(smt[6+i] or "")..(smt[7+i] or "")..(smt[8+i] or "")..(smt[9+i] or "")..(smt[10+i] or ""), x*0.025, y*0.5, x*0.2, y*0.525, tocolor(255,255,255,255), 0.5, "bankgothic", "left", "center") 
else 
    dxDrawText("1. No Map Selected", x*0.025, y*0.5, x*0.2, y*0.525, tocolor(255,255,255,255), 0.5, "bankgothic", "left", "center") 
end 

That should work, btw if you have errors show us the full script

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.