Jump to content

empire999

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by empire999

  1. This is voteredo's lua. Clancolor = '#0095FF' function getPlayersCount() players = {} for k,v in ipairs(getElementsByType('player')) do table.insert(players,v) end return #players end addEvent('onMapStarting',true) addEventHandler('onMapStarting',root, function() for k,v in ipairs(getElementsByType('player')) do if getElementData(v,'voted') == true then setElementData(v,'voted',false) end end voteredo = { players = math.ceil(getPlayersCount()/2), vr = 0, redo = false, mapname = getMapName(exports.mapmanager:getRunningGamemodeMap()) } end ) function Voteredo(plr) if voteredo then if isRestarted() == false then if voteredo.redo ~= true then if getElementData(plr,'voted') ~= true then if voteredo.vr+1 < voteredo.players then voteredo.vr = voteredo.vr+1 setElementData(plr,'voted',true) outputChatBox(Clancolor..'[VOTEREDO] #FFFFFF('..getPlayerName(plr)..'#FFFFFF) Has voted for redo #FFFFFF(#FF0000'..voteredo.vr..'#FFFFFF/'..voteredo.players..')',root,255,255,255,true) else voteredo.vr = voteredo.vr+1 voteredo.redo = true outputChatBox(Clancolor..'[VOTEREDO] #FFFFFF('..getPlayerName(plr)..'#FFFFFF) Has voted for redo #FFFFFF(#00FF00'..voteredo.vr..'#FFFFFF/'..voteredo.players..')',root,255,255,255,true) end else outputChatBox(Clancolor..'[VOTEREDO] #FFFFFFYou cant vote more than one time',plr,255,255,255,true) end else outputChatBox(Clancolor..'[VOTEREDO] #FFFFFFThis map will already be restarted',plr,255,255,255,true) end else outputChatBox(Clancolor..'[VOTEREDO] #FFFFFFThis map already was restarted by voteredo',plr,255,255,255,true) end else outputChatBox(Clancolor..'[VOTEREDO] #FFFFFFAn error has occurred , try to vote nextmap',plr,255,255,255,true) end end addCommandHandler('vr',Voteredo) addCommandHandler('voteredo',Voteredo) addEvent('onPostFinish',true) addEventHandler('onPostFinish',root, function() if voteredo then if voteredo.redo == true then local currentMap = exports.mapmanager:getRunningGamemodeMap() exports.mapmanager:changeGamemodeMap (currentMap, nil, true) lastmaprestarted = getMapName(exports.mapmanager:getRunningGamemodeMap()) outputChatBox(Clancolor..'[VOTEREDO] #FFFFFFMap has been restarted by voteredo',plr,255,255,255,true) end end end ) function isRestarted() if lastmaprestarted and voteredo.mapname then if lastmaprestarted == voteredo.mapname then return true else return false end else return false end end function getMapName( map ) return getResourceInfo( map, "name" ) or getResourceName( map ) or "unknown" end And can we set timer for this? http://i.imgur.com/vXF9ISP.png http://i.imgur.com/99f1pCT.png
  2. Doesnt work.When i redo current map,next map is changing. Edit:When i redo current map,queue is right but when i voteredo current map,queue is false
  3. I need some help on map queue.When i bought a map and redo current map,it says Next map:Random map Example: -----Before redo----- Map:[DM]1 Next Map:[DM]Bought Map ------After redo----- Map:[DM]1 Next Map:Random map local mapQueue = {} local mapTimers = {} local randomMap = 0 local specialMapCost = 75000 mapBuyDelay = 35 -- Here delay in minutes function addMapToQueue(thePlayer,resourceName) if isPlayerLogged(thePlayer) then local playerCash = getPlayerData(thePlayer,'cash') if playerCash>=shopPrice.map then local errorCode = false if #mapQueue ~= 0 then for i,tableQ in pairs(mapQueue) do if tableQ[4] == resourceName then errorCode = 1 break elseif tableQ[3] == thePlayer then errorCode = 2 break end end end if errorCode then if errorCode == 1 then return displayNotification(thePlayer,"Map queue","This map is already in map queue!",0,100,255) elseif errorCode == 2 then return displayNotification(thePlayer,"Map queue","You have one map in map queue now!",0,100,255) end end local mapQueueTable = {} local map = getResourceFromName(resourceName) if map then local mapQueueTable = { getResourceInfo(map, "name") or resourceName, getPlayerName(thePlayer), thePlayer, resourceName } if not mapTimers[mapQueueTable[4]] then if string.find(mapQueueTable[1],"DD",1) or string.find(mapQueueTable[1],"FUN",1) then if playerCash<specialMapCost then return displayNotification(thePlayer,"Map queue","You dont have enough cash! (Need: $"..specialMapCost..")",0,100,255) end addValue(thePlayer,'specialMaps',1) addValue(thePlayer,'cash',-specialMapCost) else addValue(thePlayer,'cash',-shopPrice.map) addValue(thePlayer,'mapsBought',1) end table.insert(mapQueue,mapQueueTable) if #mapQueue == 1 then triggerEvent("onUserpanelWantNextmap",getRootElement(),mapQueue[1]) end mapTimers[mapQueueTable[4]] = setTimer(resetMapTimer,mapBuyDelay*60000,1,mapQueueTable[4]) displayNotification(thePlayer,"Map queue","You successfully add new map to map queue!",0,100,255) outputChatBox("[MAP] #ffffff"..getPlayerName(thePlayer).." #ffffffadd {colorCode}"..mapQueueTable[1].."#ffffff to map queue.",getRootElement(),255,255,255,true) refreshScoreboard(thePlayer) checkAchievements(thePlayer,4) checkAchievements(thePlayer) else if isTimer(mapTimers[mapQueueTable[4]]) then local rem = getTimerDetails(mapTimers[mapQueueTable[4]]) local rem = math.ceil(rem/60000) displayNotification(thePlayer,"Map queue","You can set this map in: "..rem.." minutes.",0,100,255) end end else displayNotification(thePlayer,"Map queue","Cant find a map!",0,100,255) end else displayNotification(thePlayer,"Map queue","You dont have enough cash!",0,100,255) end end sentMapQueueToClients() end addEvent("onRaceCallNextMapCommand",true) addEventHandler("onRaceCallNextMapCommand",getRootElement(),addMapToQueue) function resetMapTimer(mapString) if isTimer(mapTimers[mapString]) then killTimer(mapTimers[mapString]) end mapTimers[mapString] = nil end function sentMapQueueToClients() callClientFunction(getRootElement(),"updateMapQueue",mapQueue) end function updateMapQueueOnMapStart() randomMap = randomMap + 1 if randomMap ~= 4 then if #mapQueue ~= 0 then if #mapQueue == 1 then table.remove(mapQueue,1) else table.remove(mapQueue,1) triggerEvent("onUserpanelWantNextmap",getRootElement(),mapQueue[1]) outputDebugString("Calling next map to race",1,255,255,255) end end else randomMap = 0 triggerEvent("onUserpanelWantNextmap",getRootElement(),'Random map') end sentMapQueueToClients() end addEvent("onRaceCallNextMap",true) addEventHandler("onRaceCallNextMap",getRootElement(),updateMapQueueOnMapStart)
×
×
  • Create New...