Newbie Posted March 6, 2014 Share Posted March 6, 2014 (edited) It seems to be well, but it doesn't set next map.. When i buy map in panel. -- Buy a next map function buyMap(thePlayer,mapName,command) local account = getPlayerAccount(thePlayer) if not (isGuestAccount(account)) then local playerCash = tonumber(getAccountData(account,"cash")) if not (mapName == "") then if playerCash >= mapCost then if command then mapName = getMapName(mapName) else mapName = tostring(mapName) end if not mapTimer[mapName] then if not tableFind(mapQueue,mapName) then table.insert(mapQueue,mapName) outputChatBox("#00BFFF[NEXT] #ffffff"..getPlayerName(thePlayer).."#FFFFFF has bought #00BFFF"..tostring(mapName).."#ffffff!",getRootElement(),255,255,255,true) outputChatBox("#00BFFF[NEXT] #ffffff"..tostring(mapName).."#ffffff successfully added to map queue!",getRootElement(),255,255,255,true) addStat(account,"buyedMaps",1) setAccountData(account,"cash",playerCash - mapCost) scoreboardRefresh(thePlayer) mapTimer[mapName] = setTimer(resetMapTimer,60000*35,1,mapName) if #mapQueue <= 1 then triggerEvent("onBoughtMap",getRootElement(),mapName) end callClientFunction(getRootElement(),"setMapQueue",mapQueue) else outputChatBox("#00BFFF[NEXT] #FFFFFFMap "..mapName.." is already in map queue.",thePlayer,255,255,255,true) end else local remaining, executesRemaining, totalExecutes = getTimerDetails(mapTimer[mapName]) if remaining < 60000 then remaining = math.floor(remaining/1000).."#ffffff second" else minutes = math.floor(remaining/60000) remaining = string.format('%02d',minutes).."#ffffff minutes" end outputChatBox("#00BFFF[NEXT] #FFFFFFYou have to wait #00BFFF"..remaining.." to set this map!",thePlayer,255,255,255,true) end else outputChatBox("#00BFFF[NEXT] #FFFFFFYou don't have enough money to set a map!",thePlayer,255,255,255,true) end else outputChatBox("#00BFFF[NEXT] #FFFFFFPlease select a map from the list first!",thePlayer,255,255,255,true) end else outputChatBox("#00BFFF[NEXT] #FFFFFFA map is already set at the moment! Please try again later.",thePlayer,255,255,255,true) end end function resetMapSetStatus(g_MapInfo) if #mapQueue >= 1 then if g_MapInfo.name ~= mapQueue[1] then triggerEvent("onBoughtMap",getRootElement(),mapQueue[1]) removeFromTable(mapQueue,mapQueue[1]) else removeFromTable(mapQueue,mapQueue[1]) if mapQueue[1] then triggerEvent("onBoughtMap",getRootElement(),mapQueue[1]) end end end for i,player in pairs(getElementsByType("player")) do respawnFix[player] = false end respawnFix = {} callClientFunction(getRootElement(),"setMapQueue",mapQueue) end addEvent("onMapStarting",true) addEventHandler("onMapStarting",getRootElement(),resetMapSetStatus) function removeFromTable(tabela,value) if tabela ~= nil then for i,data in pairs(tabela) do if data == value then table.remove(tabela,i) end end end end function tableFind(tabela,value) local ifIs = false for i,data in pairs(tabela) do if data == value then ifIs = true break end end return ifIs end addCommandHandler("resetMapBlock", function () mapIsAlreadySet = false mapName = "" mapBlock = "" end) function resetMapTimer(mapName) mapTimer[mapName] = nil outputChatBox( "#00BFFF[NEXT] #ffffffMap #00BFFF"..mapName.." #ffffffcan be bought again!", getRootElement(), 255,255,255,true) end function buyMapCommand(player,command, ... ) local query = #{...}>0 and table.concat({...},' ') or nil if query then local map, errormsg = findMap( query ) if not map then outputChatBox( "#00BFFF[NEXT] #ffffff"..errormsg, player, 255,255,255,true) return end buyMap(player,map,true) end end addCommandHandler("bm",buyMapCommand) racevoting_server -------------------- addCommandHandler('bm', function( player, command, ... ) if not getElementData (getRootElement(),"mapIsAlreadySet") == true then --this check need for /bm, if guy bought map (/bm),not from user panel(so you can modify code for bm(take player money too)finish it local query = #{...}>0 and table.concat({...},' ') or nil if not query then if g_ForcedNextMap then outputChatBox( '#abcdefNext map is #ffffff ' .. getMapName( g_ForcedNextMap ), player, 255, 255, 255, true ) else outputChatBox( '#abcdefNext map is not set', player, 255, 255 ,255, true ) end return end local map, errormsg = findMap( query ) if not map then outputRace( errormsg, player ) return end if (isGuestAccount(getPlayerAccount(player)) == false) then g_ForcedNextMap = map outputChatBox('#FF6600* Next map set from #ABCDEF'..getPlayerName( player )..' #FFFFFF[' .. getMapName( g_ForcedNextMap ).." ]", g_Root, 0, 240, 0,true) else outputChatBox("#00ff00*[bM] #FF0000ERROR: #ffffffPlease Register or Login!",player,255,255,255,true) end else outputChatBox("#FF0000* #FFFFFFA map is already #ff0000set #ffffffat the moment! Please try again later.",player,255,255,255,true) end end ) Edited March 11, 2014 by Guest Link to comment
Bonsai Posted March 6, 2014 Share Posted March 6, 2014 Buy next map is basically the same as /nextmap command of race resource. Just check how its done there. As far as I know it just checks if some variable is set, else vote starts. Link to comment
Saml1er Posted March 6, 2014 Share Posted March 6, 2014 findMap( query ) function is missing. Link to comment
Newbie Posted March 6, 2014 Author Share Posted March 6, 2014 When i buy next map the script outputs that i have buyed map. But when i die it comes a random map, my buyed map does't start. Can you exactly tell what should i do ? Link to comment
Castillo Posted March 6, 2014 Share Posted March 6, 2014 Any errors in the debugscript? Link to comment
Newbie Posted March 6, 2014 Author Share Posted March 6, 2014 Any errors in the debugscript? No errors Link to comment
Newbie Posted March 7, 2014 Author Share Posted March 7, 2014 Look: It should set next map but it does not. I think i need to do smt in racevot.. But what Link to comment
Moderators Citizen Posted March 12, 2014 Moderators Share Posted March 12, 2014 Stop using two topics for the exact same problem and reply to my question on the other one: viewtopic.php?f=91&t=72512&p=671772 Solid, could you lock this one please ? Link to comment
Newbie Posted March 12, 2014 Author Share Posted March 12, 2014 Lock another one. I didnt understand what to do. Do you see those codes ? The first one is in my panel, when i click to buy selected map it does not set next map.. Just this. Link to comment
Moderators Citizen Posted March 12, 2014 Moderators Share Posted March 12, 2014 The answer: viewtopic.php?f=91&t=72512&p=671772#p671566 And no, this one should be locked, not the newest one. 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