Jump to content

Vote for nextmap


novo

Recommended Posts

Posted

Hi all.

I tryed to change /nextmap command. I have the idea to make it like a vote.

-----------------------------------------

Maybe if you make /nextmap n30x on the vote you see:

Vote for nextmap

Set n30x v1 to nextmap ?:

1. Yeah ! I want it !

2. No, stoppid admin !

And then when vote ended:

* Vote for nextmap: Nextmap is n30x v1 setted by n30x as result of the poll.

* Vote for nextmap: Didn't enought votes for set nextmap as n30x v1.

-------------------------------------------

I tryed to take code from /votemap but all what i did is get more confused.

Please help me !!!

Thank you <3

EDIT:

Here's some code but it's not working idk how to fix it, plz help:

  
  
function nextmap(source,cmd,...) 
local playerToKill = getResourceName(nextmap) 
local notEnoughVotesMessage = "Not enough votes to set nextmap as "..nextmapname.."." 
    nextmapname = table.concat({...}," ") 
    nextmap = nil 
    for k,v in ipairs(getResources()) do 
        local name = getResourceInfo(v,'name') 
        if name == nextmapname then 
            nextmap = v 
        end 
    end 
    if nextmap then 
startPoll { 
   --start settings (dictionary part) 
   title="Set nextmap as "..nextmapname.."?", 
   percentage=75, 
   timeout=30, 
   allowchange=false, 
   maxnominations=3, 
   visibleTo=getRootElement(), 
   --start options (array part) 
   [1]={"Yes", "..getResourceName(nextmap)", nm}, 
   [2]={"No", "doOutputChatBox", notEnoughVotesMessage, getRootElement(), vR, vG, vB; default=true}, 
} 
    end 
end 
addCommandHandler("nm",nextmap) 
  
addEvent("onGamemodeMapStop") 
addEventHandler("onGamemodeMapStop",root,function() 
        if (nextmap) then 
        local map = nextmap 
        startResource(map) 
        nextmap = nil 
        end 
    end 
) 

Posted (edited)
  
  
addEvent("nMap",true) -- After Vote Event 
addEventHandler("nMap",root,function(MapName) 
    startResource(getResourceFromName(MapName)) -- start the map 
end ) 
  
addEvent("doOutputChatBox",true) -- outputChatBox Event  
addEventHandler("doOutputChatBox",root,function(Message,r,g,b) 
    outputChatBox(Message,root,r,g,b) -- outputChatBox message  
end ) 
  
addCommandHandler("nextmap",function(plr,cmd,...) 
if plr then 
outputChatBox("**#FFFF00 Vote Started By : [ "..getPlayerName(plr).." #FFFF00]",plr,255,0,0,true)  
nextmapname = table.concat({...}," ") 
nextMap = nil 
    for i,d in ipairs ( getResources() ) do -- get the resource name 
        local resName = getResourceName(d) 
            if string.find(resName,nextmapname) then 
            nextMap = resName 
            end 
    end 
-- Vote 
local notEnoughVotesMessage = "Not enough votes to set nextmap as "..nextmapname.."."  
exports.votemanager:startPoll { --- export the vote manager function 
   title="Set nextmap as "..nextmapname.."?", 
   percentage=75, 
   timeout=30, 
   allowchange=false, 
   maxnominations=3, 
   visibleTo=root, 
   [1]={"Yes", "nMap",plr,nextmapname}, -- "nMap" is the event we added before , and plr is the baseElement in triggerEvent function , nextmapname is the map name 
   [2]={"No", "doOutputChatBox",plr, notEnoughVotesMessage, 255,0,0; default=true}, -- "doOutputChatBox" is the event we added befor , and plr is the baseElement , message , r , g , b 
} 
-- Vote 
end 
end ) 
  

Edited by Guest
Posted

There is a problem, when i do /nextmap n30x v1, it shows n30x v1 and if i do /nextmap lalasaras it makes a vote for a non exist map :S

Plz fix it plz plz plz

Thanks <3

Edit: I see to the default /nextmap text. (Nextmap set as .. by ..)

Posted
  
addEvent("nMap",true) -- After Vote Event 
addEventHandler("nMap",root,function(MapName) 
    startResource(getResourceFromName(MapName)) -- start the resource  
end ) 
----------- 
addEvent("doOutputChatBox",true) -- outputChatBox Event  
addEventHandler("doOutputChatBox",root,function(Message,r,g,b) 
    outputChatBox(Message,root,r,g,b) -- outputChatBox message  
end ) 
----------- 
addEvent("votenext",true) 
addEventHandler("votenext",root, 
function(mapname,notEnoughVotesMessage) 
-- Vote 
exports.votemanager:startPoll { --- export the vote manager function 
   title="Set nextmap as "..mapname.."?", 
   percentage=75, 
   timeout=30, 
   allowchange=false, 
   maxnominations=3, 
   visibleTo=root, 
      [1]={"Yes", "nMap",plr,mapname}, -- "nMap" is the event we added before , and plr is the baseElement in triggerEvent function , nextmapname is the map name 
      [2]={"No", "doOutputChatBox",plr, notEnoughVotesMessage, 255,0,0; default=true}, -- "doOutputChatBox" is the event we added befor , and plr is the baseElement , message , r , g , b 
} 
-- Vote 
end ) 
----------- 
addCommandHandler("nextmap", 
function(plr,cmd,...) 
    if plr then 
        nextmapname = table.concat({...}," ") 
        nextMap = nil; 
        local notEnoughVotesMessage = "Not enough votes to set nextmap as "..nextmapname.."."  
            for i,d in ipairs ( getResources() ) do -- get the resource name 
                resName = getResourceName(d) 
                if string.find(nextmapname,resName) then 
                    nextMap = resName 
                    VoteNext = triggerEvent("votenext",plr,nextmapname,notEnoughVotesMessage) -- "votenext" is event i added to vote 
                end 
            end 
                    if VoteNext then -- if got the map 
                        outputChatBox("**#FFFF00 Vote Started By : [ "..getPlayerName(plr).." #FFFF00]",root,255,0,0,true)  
                    else 
                        outputChatBox("**#FFFF00 No Map Exist With That Name !",plr,255,0,0,true)  
                    end 
    end 
end ) 
  

Posted

Thanks but..

When i do /nextmap alien, the default text is still showing (nextmap set as alien.. by n30x)

and says no exist map with that name, so it doesn't find full map name.

Help please !

I love you <3

Posted
Thanks but..

When i do /nextmap alien, the default text is still showing (nextmap set as alien.. by n30x)

and says no exist map with that name, so it doesn't find full map name.

Help please !

I love you <3

i cant understand you :S ?

Posted

I mean this:

1. When i do /nextmap alien

Chatbox: Nextmap set as alien by n30x !

2. When i do /nextmap alien

Chatbox: Map with this name doesn't exist (The nextmapvote script)

And finally when i do /nextmap alien those 2 are showing :D

Plz help

Posted

I have an idea.

I thinked to get some code of buy nextmap, and add it to vote.

  
function buyMapfunction buyMap(player, command, ...) 
    if g_ForcedNextMap then 
        outputChatBox( 'Next map is ' .. getMapName( g_ForcedNextMap ), player ) 
        return 
    end 
    local query = #{...}>0 and table.concat({...},' ') or nil 
    if not query then 
        if g_ForcedNextMap then 
        outputChatBox( 'Next map is ' .. getMapName( g_ForcedNextMap ), player ) 
        else 
        outputChatBox( 'Next map is not set', player, 255, 0, 0 ) 
        end 
        return 
    end 
    local map = findMap(query) 
    if not map then 
        outputChatBox(errormsg, player) 
        return 
    end 
    if(getPlayerMoney(player) > 3499) then 
        if lastmap_B == map then 
            outputChatBox( 'That map has been played too much recently.', player, 255, 0, 0 ) 
        else 
            g_ForcedNextMap = map 
            outputChatBox(getPlayerName(player).. " bought map '" ..getMapName(g_ForcedNextMap).. "' for $3500. (/bm)", g_Root, 0, 240, 0) 
            givePlayerMoney(player, -3500) 
            setElementData(player, "Money", getPlayerMoney(player)) 
            lastmap_B = g_ForcedNextMap 
        end 
    else 
        outputChatBox("You don't have enough money. ($3500)", player, 255, 0, 0) 
    end 
end 
addCommandHandler('bm', buyMap) 
addCommandHandler('buymap', buyMap) 
  

Code from: viewtopic.php?f=91&t=37526

Thanks ! Help me ! <3

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