Zin Posted October 5, 2014 Share Posted October 5, 2014 Hi im trying to make a script that allows the final survivor in a DM map to complete it instead of the next map starting. Im getting an error saying "Failed to getactiveplayers" Whenever someone dies. this is my code DestructionDerby = setmetatable({}, RaceMode) DestructionDerby.__index = DestructionDerby DestructionDerby:register('Destruction derby') function DestructionDerby:isApplicable() return not RaceMode.checkpointsExist() and RaceMode.getMapOption('respawn') == 'none' end function DestructionDerby:getPlayerRank(player) return #getActivePlayers() end -- Copy of old updateRank function DestructionDerby:updateRanks() for i,player in ipairs(g_Players) do if not isPlayerFinished(player) then local rank = self:getPlayerRank(player) if not rank or rank > 0 then setElementData(player, 'race rank', rank) end end end -- Make text look good at the start if not self.running then for i,player in ipairs(g_Players) do setElementData(player, 'race rank', '' ) setElementData(player, 'checkpoint', '' ) end end end function DestructionDerby:onPlayerWasted(player) if isActivePlayer(player) then self:handleFinishActivePlayer(player) if getActivePlayerCount() <= 0 then RaceMode.endMap() else TimerManager.createTimerFor("map",player):setTimer(clientCall, 2000, 1, player, 'Spectate.start', 'auto') end end RaceMode.setPlayerIsFinished(player) showBlipsAttachedTo(player, false) end function hunterAlert(mapInfo, pickupID, pickupType, vehicleModel) if pickupType == "vehiclechange" then if vehicleModel == 425 then if getActivePlayerCount() <= 1 then RaceMode.endMap() end end end end addEventHandler("onPlayerPickUpRacePickup",getRootElement(),hunterAlert) function DestructionDerby:onPlayerQuit(player) if isActivePlayer(player) then self:handleFinishActivePlayer(player) if getActivePlayerCount() <= 1 then RaceMode.endMap() end end end function DestructionDerby:handleFinishActivePlayer(player) -- Update ranking board for player being removed if not self.rankingBoard then self.rankingBoard = RankingBoard:create() self.rankingBoard:setDirection( 'up', getActivePlayerCount() ) end local timePassed = self:getTimePassed() self.rankingBoard:add(player, timePassed) -- Do remove finishActivePlayer(player) -- Update ranking board if one player left local activePlayers = getActivePlayers() local resource = exports["mapmanager"]:getRunningGamemodeMap( ) local mapName = getResourceInfo ( resource, "name" ) if string.find ( mapName, "[DD]" ) then if #activePlayers == 1 then self.rankingBoard:add(activePlayers[1], timePassed) showMessage(getPlayerName(activePlayers[1]) .. ' won the map!', 255, 0, 0) RaceMode.endMap() end elseif string.find ( mapName, "[DM]" ) then if #alivePlayers == 1 then if getElementModel (getPedOccupiedVehicle ( alivePlayers[1] )) == 425 then self.rankingBoard:add(activePlayers[1], timePassed) showMessage(getPlayerName(activePlayers[1]) .. ' won the map!', 255, 0, 0) RaceMode.endMap() end end end end Link to comment
Moderators IIYAMA Posted October 5, 2014 Moderators Share Posted October 5, 2014 From where did you get this strange function? You sure it is in the code? Link to comment
Zin Posted October 5, 2014 Author Share Posted October 5, 2014 I got it from this post viewtopic.php?f=91&t=54806&p=743147 Link to comment
Moderators IIYAMA Posted October 5, 2014 Moderators Share Posted October 5, 2014 lol, I am not here to learn you how to copy everything from other posts. and yet, that is what you did wrong. Link to comment
Zin Posted October 5, 2014 Author Share Posted October 5, 2014 Is there an alternative way to do what i want to do. which is make an auto-b for DM maps so the final player stays alive? Link to comment
Moderators IIYAMA Posted October 5, 2014 Moderators Share Posted October 5, 2014 Two ways. 1: Learn scripting (which takes years if you don't have ....) 2: Pay people who are searching for making it for you. There are always more ways, but those depends on your luck and your connections. 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