Jump to content

Don't set next map NOT SOLVED


Newbie

Recommended Posts

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 by Guest
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...