.:HyPeX:. Posted October 10, 2013 Share Posted October 10, 2013 Hi guys, can someone tell me why: 1°: The nextmap command is not stopped if it was used already 2°: The previous map is not saved and reset after map changing *Note: i removed all redo/etc functions from the race resource. In-Game: http://i.imgur.com/EHaYB5a.png http://i.imgur.com/gCxFT0N.png both of them are serverside. For reseting the map and clearing the nextmap block: function resetMapLimitations() g_ForcedActualMap = getMapName(exports.mapmanager:getRunningGamemodeMap()) if g_ForcedNextMapBlock == true then g_ForcedNextMapBlock = false outputChatBox("#00aaff[Nextmap]: Nextmap command is now aviable again!", getRootElement(), 0, 175, 255, true) end if g_ForcedNextMap then g_ForcedNextMap = nil end if g_ForcedResetNextMap then g_ForcedNextMap = g_ForcedResetNextMap mapIsAlreadySet = true local map = g_ForcedResetNextMap outputChatBox("#00aaff[Nextmap]: Moved map '".. g_ForcedResetNextMap .."' due to nextmap command was set again!",getRootElement(), 0, 50, 175, true) triggerEvent("onBoughtMap", getRootElement(), map) g_ForcedResetNextMap = nil else if mapIsAlreadySet == true then mapIsAlreadySet = false outputChatBox("#00aaff[Nextmap]: Map has loaded!, you can now buy a map!",getRootElement(), 0, 50, 175, true) else outputChatBox("#00aaff[Nextmap]: The nextmap is free, buy one!",getRootElement(), 0,50,175, true) end end end addEventHandler("onGamemodeMapStart",getRootElement(),resetMapLimitations) the nextmap function: function NextMapCommand(player, command, ...) if g_ForcedNextMap then showPutchatbox = "[Nextmap]: Nextmap is #ffffff".. (getMapName(g_ForcedNextMap)) .. "" else showPutchatbox = "[Nextmap]: There is no nextmap set!" end local query = #{...}>0 and table.concat({...},' ') or nil if not ... then outputChatBox("".. showPutchatbox .."", source, 0, 175, 255, true) return end local admin = true if not _TESTING and admin == false then return end local map, errormsg = findMap( query ) if not map then return end if g_ForcedNextMap == map then outputChatBox("#00aaff[Nextmap]: That is already the nextmap!", player, 0, 175, 255, true) return end if g_ForcedNextMapBlock == true then outputChatBox("#00aaff[Nextmap]: Please wait for next map to use nextmap again!", player, 0, 175, 255, true) return end if mapIsAlreadySet == true then g_ForcedResetNextMap = getMapName(g_ForcedNextMap) g_ForcedNextMap = map g_ForcedResetNextMapBlock = true local mapName = getMapName( g_ForcedNextMap ) local PlayerName = getPlayerName(player) outputChatBox("#00aaff[Nextmap]: ".. PlayerName .."#00aaff has set #ffffff".. mapName .."#00aaff as nextmap!", getRootElement(), 0, 175, 255, true) outputChatBox("#00aaff[Nextmap]: the previous map was moved becouse ".. mapName .."#00aaffwas set as nextmap!", getRootElement(), 0, 175, 255, true) triggerEvent("onBoughtMap", getRootElement(), mapName) else g_ForcedNextMap = map mapIsAlreadySet = true local mapName = getMapName( g_ForcedNextMap ) local PlayerName = getPlayerName(player) outputChatBox("#00aaff[Nextmap]: ".. PlayerName .."#00aaff has set #ffffff".. mapName .."#00aaff as nextmap!", getRootElement(), 0, 175, 255, true) triggerEvent("onBoughtMap", getRootElement(), mapName) end end addCommandHandler("nextmap",NextMapCommand) Link to comment
.:HyPeX:. Posted October 15, 2013 Author Share Posted October 15, 2013 Bump, still any help on this? Thanks in advance HyPeX Link to comment
pa3ck Posted October 15, 2013 Share Posted October 15, 2013 Dont you need an 'if' here: local query = #{...}>0 and table.concat({...},' ') or nil Link to comment
myonlake Posted October 15, 2013 Share Posted October 15, 2013 Dont you need an 'if' here: local query = #{...}>0 and table.concat({...},' ') or nil That is an alternative solution for if-statement. It works as well. Link to comment
.:HyPeX:. Posted October 15, 2013 Author Share Posted October 15, 2013 Dont you need an 'if' here: local query = #{...}>0 and table.concat({...},' ') or nil dont you read? if not ... then outputChatBox("".. showPutchatbox .."", source, 0, 175, 255, true) return end Still searching why this doesnt work as it should. Link to comment
myonlake Posted October 16, 2013 Share Posted October 16, 2013 Switch the 'not ...' to 'not query'. Link to comment
.:HyPeX:. Posted October 16, 2013 Author Share Posted October 16, 2013 Thats not the problem, it works perfectly that part, the problem is: 1°: The nextmap command is not stopped if it was used already 2°: The previous map is not saved and reset after map changing *Note: i removed all redo/etc functions from the race resource Link to comment
.:HyPeX:. Posted October 18, 2013 Author Share Posted October 18, 2013 //Upadted and testing.. function ReNextMap( map ) if map then local mapName = map outputChatBox("#00aaff[Nextmap]: Moved map '".. mapName .."' due to nextmap command was recived and reset!",getRootElement(), 0, 50, 175, true) g_ForcedNextMap = map mapIsAlreadySet = true triggerEvent("onBoughtMap", getRootElement(), mapName) else outputChatBox("#00aaff[Nextmap]: 'map name' was not recived correctly!",getRootElement(), 0, 50, 175, true) end end function resetMapLimitations() g_ForcedActualMap = getMapName(exports.mapmanager:getRunningGamemodeMap()) g_ForcedNextMapBlock = 0 outputChatBox("#00aaff[Nextmap]: Nextmap command is now aviable again!", getRootElement(), 0, 175, 255, true) g_ForcedNextMap = nil if g_ForcedResetNextMap then g_ForcedNextMap = getMapName(g_ForcedResetNextMap) mapIsAlreadySet = true local map = g_ForcedResetNextMap setTimer(ReNextMap, 500, 1, map) outputChatBox("#00aaff[Nextmap]: Moved map '".. g_ForcedResetNextMap .."' due to nextmap command was sent for setting again!",getRootElement(), 0, 50, 175, true) g_ForcedResetNextMap = nil else if mapIsAlreadySet == true then mapIsAlreadySet = false outputChatBox("#00aaff[Nextmap]: Map has loaded!, you can now buy a map!",getRootElement(), 0, 50, 175, true) else outputChatBox("#00aaff[Nextmap]: The nextmap is free, buy one!",getRootElement(), 0,50,175, true) end end end addEventHandler("onGamemodeMapStart",getRootElement(),resetMapLimitations) function NextMapCommand(player, command, ...) if (not isObjectInACLGroup ("user."..accountName, aclGetGroup ( "Admin" ))) or ( not isObjectInACLGroup ("user."..accountName, aclGetGroup ( "SuperModerator" ))) then outputChatBox("[Nextmap]: You are not admin!", source, 0,175,255) return end if g_ForcedNextMap then showPutchatbox = "[Nextmap]: Nextmap is #ffffff".. (getMapName(g_ForcedNextMap)) .. "" else showPutchatbox = "[Nextmap]: There is no nextmap set!" end local query = #{...}>0 and table.concat({...},' ') or nil if not ... then outputChatBox("".. showPutchatbox .."", source, 0, 175, 255, true) return end local admin = true if not _TESTING and admin == false then return end local map, errormsg = findMap( query ) if not map then return end if g_ForcedNextMap == map then outputChatBox("#00aaff[Nextmap]: That is already the nextmap!", player, 0, 175, 255, true) return end if g_ForcedNextMapBlock then outputChatBox("#00aaff[Nextmap]: Please wait for next map to use nextmap again!", player, 0, 175, 255, true) return end if mapIsAlreadySet == true then g_ForcedResetNextMap = getMapName(g_ForcedNextMap) g_ForcedNextMap = query g_ForcedResetNextMapBlock = 1 local mapName = getMapName( g_ForcedNextMap ) local PlayerName = getPlayerName(player) outputChatBox("#00aaff[Nextmap]: ".. PlayerName .."#00aaff has set #ffffff".. mapName .."#00aaff as nextmap!", getRootElement(), 0, 175, 255, true) outputChatBox("#00aaff[Nextmap]: the previous map was moved becouse ".. mapName .."#00aaffwas set as nextmap!", getRootElement(), 0, 175, 255, true) triggerEvent("onBoughtMap", getRootElement(), mapName) return end g_ForcedNextMap = map mapIsAlreadySet = true local mapName = getMapName( g_ForcedNextMap ) local PlayerName = getPlayerName(player) outputChatBox("#00aaff[Nextmap]: ".. PlayerName .."#00aaff has set #ffffff".. mapName .."#00aaff as nextmap!", getRootElement(), 0, 175, 255, true) triggerEvent("onBoughtMap", getRootElement(), mapName) end addCommandHandler("nextmap",NextMapCommand) Link to comment
.:HyPeX:. Posted October 18, 2013 Author Share Posted October 18, 2013 Can somone tell me why even if i restart the script and the race, it is making an infinite loop of reseting the actual map? function ReNextMap( map ) if map then local mapName = map outputChatBox("#00aaff[Nextmap]: Moved map '#ffffff".. mapName .."#00aaff' due to nextmap command was recived and reset!",getRootElement(), 0, 50, 175, true) g_ForcedNextMap = map mapIsAlreadySet = true triggerEvent("onBoughtMap", getRootElement(), mapName) else outputChatBox("#00aaff[Nextmap]: 'map name' was not recived correctly!",getRootElement(), 0, 50, 175, true) end end function () outputChatBox("#00aaff[Nextmap]: Loading..",getRootElement(), 0,175,255,true) end function resetMapLimitations( g_NextMap ) g_ForcedNextMapBlock = 0 outputChatBox("#00aaff[Nextmap]: Nextmap command is now aviable again!", getRootElement(), 0, 175, 255, true) g_ForcedNextMap = nil if g_NextMap then local mapName = getMapName(g_NextMap) g_NextMap = false mapIsAlreadySet = true setTimer(ReNextMap, 5000, 1, mapName) setTimer(, 2000, 1) outputChatBox("#00aaff[Nextmap]: Moved map '#ffffff".. mapName .."#00aaff' due to nextmap command was sent for setting again!",getRootElement(), 0, 50, 175, true) g_NextMap = false else if mapIsAlreadySet == true then mapIsAlreadySet = false outputChatBox("#00aaff[Nextmap]: Map has loaded!, you can now buy a map!",getRootElement(), 0, 50, 175, true) else outputChatBox("#00aaff[Nextmap]: The nextmap is free, buy one!",getRootElement(), 0,50,175, true) end end end addEventHandler("onGamemodeMapStart",getRootElement(),resetMapLimitations) Thanks HyPeX 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