Spidy Posted February 21, 2013 Share Posted February 21, 2013 (edited) Hello there! I lately started learning scripting, yet I'm still new, I have made my first script, and ofc, something is missed on it because it doesn't work, the script is /goto (mapname) function Changemap (thePlayer, goto) bool changeGamemodeMap ( resource newMap, [ resource gamemodeToChangeTo ] ) outputChatBox(getPlayerName(source).." changed the map!") end addCommandHandler("ChangeGamemod", Changemap) As I said, I'm still new at scripting, I hope I won't get aggressive comments.. Thanks! Edited February 24, 2013 by Guest Link to comment
mjau Posted February 21, 2013 Share Posted February 21, 2013 function Changemap (thePlayer, cmd, goTo) exports.mapmanager:changeGamemodeMap (goTo) outputChatBox(getPlayerName(thePlayer).." changed the map!") end addCommandHandler("goto", Changemap) Im not sure myself as i never worked with the mapmanager, but i belive this is right. Ingame do /goto mapname Link to comment
Guest Guest4401 Posted February 21, 2013 Share Posted February 21, 2013 addCommandHandler('goto', function(p,c,...) local m = table.concat(arg,' ') local e = exports.mapmanager if #m > 0 then for i,v in ipairs(e:getMaps()) do local n = getResourceInfo(v,'name') if n and n:lower():find(m:lower(),1,true) then e:changeGamemodeMap(v) return outputChatBox(getPlayerName(p)..' starts '..n,root,255,255,0) end end return outputChatBox('Map not found',p,255,255,0) else outputChatBox('/goto [mapname]',p,255,0,0) end end ) Link to comment
Spidy Posted February 21, 2013 Author Share Posted February 21, 2013 Karthik's one works, but I have to type whole mapname to goto, it's like the /changemap cmd, I don't want it in this way, I want it like: E.gs: /goto Pure Skills P, it'll goto Pure Skills Paradise /goto DC ,if there are two maps with the name DC it'll has to say "Found (2) matches": 'DC 15', 'DC 16'.." Got me? Link to comment
gokalpfirat Posted February 22, 2013 Share Posted February 22, 2013 Use string.find to get possible maps and find string that you write in cmd Link to comment
Guest Guest4401 Posted February 23, 2013 Share Posted February 23, 2013 local showmapsLimit = 5 addCommandHandler('goto', function(p,c,...) local m = table.concat(arg,' ') local e = exports.mapmanager local t = {} if #m > 0 then for i,v in ipairs(e:getMaps()) do local n = getResourceInfo(v,'name') if n and n:lower():find(m:lower(),1,true) then table.insert(t,{v,n}) end end if #t == 0 then outputChatBox('No maps found',p,255,0,0) elseif #t == 1 then e:changeGamemodeMap(t[1][1]) outputChatBox(getPlayerName(p)..' starts '..t[1][2],root,255,255,0) else outputChatBox('Found '.. #t ..' matches:',p) for i,v in ipairs(t) do outputChatBox(v[2]) if i == showmapsLimit then outputChatBox('...',p) break end end end else outputChatBox('/goto [mapname]',p,255,0,0) end end ) Link to comment
Spidy Posted February 23, 2013 Author Share Posted February 23, 2013 Still does not work..Whenever I type /goto a mapname it says "goto (mapname), once I write the whole name still nothing happen.. Debugscript 3: goto:8: "bad agrument #1 "ipairs' (table expected, got boolean)".. Link to comment
Guest Guest4401 Posted February 24, 2013 Share Posted February 24, 2013 Still does not work..Whenever I type /goto a mapname it says "goto (mapname), once I write the whole name still nothing happen.. Are you sure you've put the code serverside? Debugscript 3: goto:8: "bad agrument #1 "ipairs' (table expected, got boolean)".. Are you sure that mapmanager resource is running? Link to comment
Spidy Posted February 24, 2013 Author Share Posted February 24, 2013 No I wasn't.. Sorry.. Set it serverside and it works now, thank you for wasting your time helping me) You can close this as well. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now