Jump to content

[AYUDA]MapShop Race


XxRomxX

Recommended Posts

function updateTextForPanel ( gMode, mapName ) 
    local tName = getModeAndMap ( gMode, mapName ); 
    local tSql = executeSQLQuery ( 'SELECT playerName AS pName, timeText AS txTTime FROM ' .. qsafetablename ( tName ) ); 
    if not tSql or #tSql == 0 then return false end 
    if type ( tSql ) == 'table' and #tSql > 0 then 
        if tSql[1] then t1Nick = tSql[1].pName t1Time = tSql[1].txTTime else t1Nick = false t1Time = false end 
        if tSql[2] then t2Nick = tSql[2].pName t2Time = tSql[2].txTTime else t2Nick = false t2Time = false end 
        if tSql[3] then t3Nick = tSql[3].pName t3Time = tSql[3].txTTime else t3Nick = false t3Time = false end 
        return { nick1 = t1Nick, time1 = t1Time, nick2 = t2Nick, time2 = t2Time, nick3 = t3Nick, time3 = t3Time }; 
    end 
end 
  
function getModeAndMap ( gMode, mapName ) 
    return 'race maptimes ' .. gMode .. ' ' .. mapName 
end 

No si mira asi tengo el race_toptimes

Link to comment

No Tampoco Me Funciona el race_toptimes lo tengo asi por las dudas

function="updateTextForPanel"/> 
function updateTextForPanel ( gMode, mapName ) 
    local tName = getModeAndMap ( gMode, mapName ); 
    local tSql = executeSQLQuery ( 'SELECT playerName AS pName, timeText AS txTTime FROM ' .. qsafetablename ( tName ) ); 
    if not tSql or #tSql == 0 then return false end 
    if type ( tSql ) == 'table' and #tSql > 0 then 
        if tSql[1] then t1Nick = tSql[1].pName t1Time = tSql[1].txTTime else t1Nick = false t1Time = false end 
        if tSql[2] then t2Nick = tSql[2].pName t2Time = tSql[2].txTTime else t2Nick = false t2Time = false end 
        if tSql[3] then t3Nick = tSql[3].pName t3Time = tSql[3].txTTime else t3Nick = false t3Time = false end 
        return { nick1 = t1Nick, time1 = t1Time, nick2 = t2Nick, time2 = t2Time, nick3 = t3Nick, time3 = t3Time }; 
    end 
end 
  
function getModeAndMap ( gMode, mapName ) 
    return 'race maptimes ' .. gMode .. ' ' .. mapName 
end 

Link to comment
  • MTA Team

Yo uso el mapshop de twix y nunca tube que modifcar nada en el meta..Fijate que probablemente tu version es antigua..Yo tengo la version actual, si la quieres, manda PM y con gusto te la doy :wink:

Saludos

Link to comment

race_voting.server

-- 
-- racemidvote_server.lua
--
-- Mid-race random map vote and
-- NextMapVote handled in this file
--
 
local lastVoteStarterName = ''
local lastVoteStarterCount = 0
 
----------------------------------------------------------------------------
-- displayHilariarseMessage
--
-- Comedy gold
----------------------------------------------------------------------------
function displayHilariarseMessage( player )
    if not player then
        lastVoteStarterName = ''
    else
        local playerName = getPlayerName(player)
        local msg = ''
        if playerName == lastVoteStarterName then
            lastVoteStarterCount = lastVoteStarterCount + 1
            if lastVoteStarterCount == 5 then
                msg = playerName .. ' started a vote. Hardly a suprise.'
            elseif lastVoteStarterCount == 10 then
                msg = 'Guess what! '..playerName .. ' started ANOTHER vote!'
            elseif lastVoteStarterCount < 5 then
                msg = playerName .. ' started another vote.'
            else
                msg = playerName .. ' continues to abuse the vote system.'
            end
        else
            lastVoteStarterCount = 0
            lastVoteStarterName = playerName
            msg = playerName .. ' started a vote.'
        end
        outputRace( msg )
    end
end
 
 
----------------------------------------------------------------------------
-- displayKillerPunchLine
--
-- Sewing kits available in the foyer
----------------------------------------------------------------------------
function displayKillerPunchLine( player )
    if lastVoteStarterName ~= '' then
        outputRace( 'Offical news: Everybody hates ' .. lastVoteStarterName )
    end
end
 
 
----------------------------------------------------------------------------
-- startMidMapVoteForRandomMap
--
-- Start the vote menu if during a race and more than 30 seconds from the end
-- No messages if this was not started by a player
----------------------------------------------------------------------------
function startMidMapVoteForRandomMap(player)
 
    -- Check state and race time left
    if not stateAllowsRandomMapVote() or g_CurrentRaceMode:getTimeRemaining() < 30000 then
        if player then
            outputRace( "I'm afraid I can't let you do that, " .. getPlayerName(player) .. ".", player )
        end
        return
    end
 
    displayHilariarseMessage( player )
    exports.votemanager:stopPoll()
 
    -- Actual vote started here
    local pollDidStart = exports.votemanager:startPoll {
            title='Do you want to change to a random map?',
            percentage=51,
            timeout=15,
            allowchange=true,
            visibleTo=getRootElement(),
            [1]={'Yes', 'midMapVoteResult', getRootElement(), true},
            [2]={'No', 'midMapVoteResult', getRootElement(), false;default=true},
    }
 
    -- Change state if vote did start
    if pollDidStart then
        gotoState('MidMapVote')
    end
 
end
addCommandHandler('new',startMidMapVoteForRandomMap)
 
 
----------------------------------------------------------------------------
-- event midMapVoteResult
--
-- Called from the votemanager when the poll has completed
----------------------------------------------------------------------------
addEvent('midMapVoteResult')
addEventHandler('midMapVoteResult', getRootElement(),
    function( votedYes )
        -- Change state back
        if stateAllowsRandomMapVoteResult() then
            gotoState('Running')
            if votedYes then
                startRandomMap()
            else
                displayKillerPunchLine()
            end
        end
    end
)
 
 
 
----------------------------------------------------------------------------
-- startRandomMap
--
-- Changes the current map to a random race map
----------------------------------------------------------------------------
function startRandomMap()
 
    -- Handle forced nextmap setting
    if maybeApplyForcedNextMap() then
        return
    end
 
    -- Get a random map chosen from the 10% of least recently player maps, with enough spawn points for all the players (if required)
    local map = getRandomMapCompatibleWithGamemode( getThisResource(), 10, g_GameOptions.ghostmode and 0 or getTotalPlayerCount() )
    if map then
        g_IgnoreSpawnCountProblems = map    -- Uber hack 4000
        if not exports.mapmanager:changeGamemodeMap ( map, nil, true ) then
            problemChangingMap()
        end
    else
        outputWarning( 'startRandomMap failed' )
    end
end
 
 
----------------------------------------------------------------------------
-- outputRace
--
-- Race color is defined in the settings
----------------------------------------------------------------------------
function outputRace(message, toElement)
    toElement = toElement or g_Root
    local r, g, b = getColorFromString(string.upper(get("color")))
    if getElementType(toElement) == 'console' then
        outputServerLog(message)
    else
        if toElement == rootElement then
            outputServerLog(message)
        end
        if getElementType(toElement) == 'player' then
            message = '[PM] ' .. message
        end
        outputChatBox(message, toElement, r, g, b)
    end
end
 
 
----------------------------------------------------------------------------
-- problemChangingMap
--
-- Sort it
----------------------------------------------------------------------------
function problemChangingMap()
    outputRace( 'Changing to random map in 5 seconds' )
    local currentMap = exports.mapmanager:getRunningGamemodeMap()
    TimerManager.createTimerFor("resource","mapproblem"):setTimer(
        function()
            -- Check that something else hasn't already changed the map
            if currentMap == exports.mapmanager:getRunningGamemodeMap() then
                startRandomMap()
            end
        end,
        math.random(4500,5500), 1 )
end
 
 
 
--
--
-- NextMapVote
--
--
--
 
local g_Poll
 
----------------------------------------------------------------------------
-- startNextMapVote
--
-- Start a votemap for the next map. Should only be called during the
-- race state 'NextMapSelect'
----------------------------------------------------------------------------
function startNextMapVote()
 
    exports.votemanager:stopPoll()
 
    -- Handle forced nextmap setting
    if maybeApplyForcedNextMap() then
        return
    end
 
    -- Get all maps
    local compatibleMaps = exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource())
   
    -- limit it to eight random maps
    if #compatibleMaps > 8 then
        math.randomseed(getTickCount())
        repeat
            table.remove(compatibleMaps, math.random(1, #compatibleMaps))
        until #compatibleMaps == 8
    elseif #compatibleMaps < 2 then
        return false, errorCode.onlyOneCompatibleMap
    end
 
    -- mix up the list order
    for i,map in ipairs(compatibleMaps) do
        local swapWith = math.random(1, #compatibleMaps)
        local temp = compatibleMaps[i]
        compatibleMaps[i] = compatibleMaps[swapWith]
        compatibleMaps[swapWith] = temp
    end
   
    local poll = {
        title="Choose the next map:",
        visibleTo=getRootElement(),
        percentage=51,
        timeout=15,
        allowchange=true;
        }
   
    for index, map in ipairs(compatibleMaps) do
        local mapName = getResourceInfo(map, "name") or getResourceName(map)
        table.insert(poll, {mapName, 'nextMapVoteResult', getRootElement(), map})
    end
   
    local currentMap = exports.mapmanager:getRunningGamemodeMap()
    if currentMap then
        table.insert(poll, {"Play again", 'nextMapVoteResult', getRootElement(), currentMap})
    end
 
    -- Allow addons to modify the poll
    g_Poll = poll
    triggerEvent('onPollStarting', g_Root, poll )
    poll = g_Poll
    g_Poll = nil
 
   
Link to comment

Ok remplaza esto por lo tuyo

racevoting_server

-- 
-- racemidvote_server.lua
--
-- Mid-race random map vote and
-- NextMapVote handled in this file
--
 
local lastVoteStarterName = ''
local lastVoteStarterCount = 0
 
----------------------------------------------------------------------------
-- displayHilariarseMessage
--
-- Comedy gold
----------------------------------------------------------------------------
function displayHilariarseMessage( player )
    if not player then
        lastVoteStarterName = ''
    else
        local playerName = getPlayerName(player)
        local msg = ''
        if playerName == lastVoteStarterName then
            lastVoteStarterCount = lastVoteStarterCount + 1
            if lastVoteStarterCount == 5 then
                msg = playerName .. ' started a vote. Hardly a suprise.'
            elseif lastVoteStarterCount == 10 then
                msg = 'Guess what! '..playerName .. ' started ANOTHER vote!'
            elseif lastVoteStarterCount < 5 then
                msg = playerName .. ' started another vote.'
            else
                msg = playerName .. ' continues to abuse the vote system.'
            end
        else
            lastVoteStarterCount = 0
            lastVoteStarterName = playerName
            msg = playerName .. ' started a vote.'
        end
        outputRace( msg )
    end
end
 
 
----------------------------------------------------------------------------
-- displayKillerPunchLine
--
-- Sewing kits available in the foyer
----------------------------------------------------------------------------
function displayKillerPunchLine( player )
    if lastVoteStarterName ~= '' then
        outputRace( 'Offical news: Everybody hates ' .. lastVoteStarterName )
    end
end
 
 
----------------------------------------------------------------------------
-- startMidMapVoteForRandomMap
--
-- Start the vote menu if during a race and more than 30 seconds from the end
-- No messages if this was not started by a player
----------------------------------------------------------------------------
function startMidMapVoteForRandomMap(player)
 
    -- Check state and race time left
    if not stateAllowsRandomMapVote() or g_CurrentRaceMode:getTimeRemaining() < 30000 then
        if player then
            outputRace( "I'm afraid I can't let you do that, " .. getPlayerName(player) .. ".", player )
        end
        return
    end
 
    displayHilariarseMessage( player )
    exports.votemanager:stopPoll()
 
    -- Actual vote started here
    local pollDidStart = exports.votemanager:startPoll {
            title='Do you want to change to a random map?',
            percentage=51,
            timeout=15,
            allowchange=true,
            visibleTo=getRootElement(),
            [1]={'Yes', 'midMapVoteResult', getRootElement(), true},
            [2]={'No', 'midMapVoteResult', getRootElement(), false;default=true},
    }
 
    -- Change state if vote did start
    if pollDidStart then
        gotoState('MidMapVote')
    end
 
end
addCommandHandler('new',startMidMapVoteForRandomMap)
 
 
----------------------------------------------------------------------------
-- event midMapVoteResult
--
-- Called from the votemanager when the poll has completed
----------------------------------------------------------------------------
addEvent('midMapVoteResult')
addEventHandler('midMapVoteResult', getRootElement(),
    function( votedYes )
        -- Change state back
        if stateAllowsRandomMapVoteResult() then
            gotoState('Running')
            if votedYes then
                startRandomMap()
            else
                displayKillerPunchLine()
            end
        end
    end
)
 
 
 
----------------------------------------------------------------------------
-- startRandomMap
--
-- Changes the current map to a random race map
----------------------------------------------------------------------------
function startRandomMap()
 
    -- Handle forced nextmap setting
    if maybeApplyForcedNextMap() then
        return
    end
 
    -- Get a random map chosen from the 10% of least recently player maps, with enough spawn points for all the players (if required)
    local map = getRandomMapCompatibleWithGamemode( getThisResource(), 10, g_GameOptions.ghostmode and 0 or getTotalPlayerCount() )
    if map then
        g_IgnoreSpawnCountProblems = map    -- Uber hack 4000
        if not exports.mapmanager:changeGamemodeMap ( map, nil, true ) then
            problemChangingMap()
        end
    else
        outputWarning( 'startRandomMap failed' )
    end
end
 
 
----------------------------------------------------------------------------
-- outputRace
--
-- Race color is defined in the settings
----------------------------------------------------------------------------
function outputRace(message, toElement)
    toElement = toElement or g_Root
    local r, g, b = getColorFromString(string.upper(get("color")))
    if getElementType(toElement) == 'console' then
        outputServerLog(message)
    else
        if toElement == rootElement then
            outputServerLog(message)
        end
        if getElementType(toElement) == 'player' then
            message = '[PM] ' .. message
        end
        outputChatBox(message, toElement, r, g, b)
    end
end
 
 
----------------------------------------------------------------------------
-- problemChangingMap
--
-- Sort it
----------------------------------------------------------------------------
function problemChangingMap()
    outputRace( 'Changing to random map in 5 seconds' )
    local currentMap = exports.mapmanager:getRunningGamemodeMap()
    TimerManager.createTimerFor("resource","mapproblem"):setTimer(
        function()
            -- Check that something else hasn't already changed the map
            if currentMap == exports.mapmanager:getRunningGamemodeMap() then
                startRandomMap()
            end
        end,
        math.random(4500,5500), 1 )
end
 
 
 
--
--
-- NextMapVote
--
--
--
 
local g_Poll
 
----------------------------------------------------------------------------
-- startNextMapVote
--
-- Start a votemap for the next map. Should only be called during the
-- race state 'NextMapSelect'
----------------------------------------------------------------------------
function startNextMapVote()
 
    exports.votemanager:stopPoll()
 
    -- Handle forced nextmap setting
    if maybeApplyForcedNextMap() then
        return
    end
 
    -- Get all maps
    local compatibleMaps = exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource())
   
    -- limit it to eight random maps
    if #compatibleMaps > 8 then
        math.randomseed(getTickCount())
        repeat
            table.remove(compatibleMaps, math.random(1, #compatibleMaps))
        until #compatibleMaps == 8
    elseif #compatibleMaps < 2 then
        return false, errorCode.onlyOneCompatibleMap
    end
 
    -- mix up the list order
    for i,map in ipairs(compatibleMaps) do
        local swapWith = math.random(1, #compatibleMaps)
        local temp = compatibleMaps[i]
        compatibleMaps[i] = compatibleMaps[swapWith]
        compatibleMaps[swapWith] = temp
    end
   
    local poll = {
        title="Choose the next map:",
        visibleTo=getRootElement(),
        percentage=51,
        timeout=15,
        allowchange=true;
        }
   
    for index, map in ipairs(compatibleMaps) do
        local mapName = getResourceInfo(map, "name") or getResourceName(map)
        table.insert(poll, {mapName, 'nextMapVoteResult', getRootElement(), map})
    end
   
    local currentMap = exports.mapmanager:getRunningGamemodeMap()
    if currentMap then
        table.insert(poll, {"Play again", 'nextMapVoteResult', getRootElement(), currentMap})
    end
 
    -- Allow addons to modify the poll
    g_Poll = poll
    triggerEvent('onPollStarting', g_Root, poll )
    poll = g_Poll
    g_Poll =
Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...