florent6001 Posted July 8, 2016 Share Posted July 8, 2016 (edited) Hi, the last survivor doesn't work. Nothing is displayed when a player is alone alive. And when the last player get the hunter the nextmap doesn't start, he need to press enter or die My destructionderby.lua 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() local rank = self:getPlayerRank(player) if rank == 1 then --if getResourceState( getResourceFromName( "podium" )) ~= "running" then triggerClientEvent("winnerMessage",resourceRoot,"Winner!!!", getPlayerNametagText(player)) --else -- triggerClientEvent("winnerMessage",resourceRoot,"","") --end --else --self.rankingBoard:add(player, timePassed, rank) end -- Do remove finishActivePlayer(player) if rank and rank > 1 then triggerEvent( "onPlayerFinishDD",player,tonumber( rank ) ) end -- Update ranking board if one player left local activePlayers = getActivePlayers() triggerEvent("onPlayerDeadInRace",getRootElement(),rank,player) if #activePlayers == 1 then --self.rankingBoard:add(activePlayers[1], timePassed, #activePlayers) if (not isMapDM()) then if getResourceState( getResourceFromName( "podium" )) ~= "running" then triggerClientEvent("winnerMessage",resourceRoot,"Winner!!!", getPlayerNametagText(activePlayers[1])) else triggerClientEvent("winnerMessage",resourceRoot,"","") setElementHealth(activePlayers[1],0) end end if getElementModel(getPedOccupiedVehicle(activePlayers[1])) == 425 then setElementHealth(activePlayers[1],0) end triggerEvent( "onPlayerWinDD",activePlayers[1] ) end end Edited July 9, 2016 by Guest Link to comment
florent6001 Posted July 9, 2016 Author Share Posted July 9, 2016 Someones can help me please? Link to comment
kikos500 Posted July 9, 2016 Share Posted July 9, 2016 local activePlayers = getActivePlayers() where is this function defined? as far as i know mta doesn't have this try local activePlayers = getAlivePlayers() Link to comment
florent6001 Posted July 9, 2016 Author Share Posted July 9, 2016 the function: function getActivePlayers() return g_CurrentRaceMode.activePlayerList end Link to comment
florent6001 Posted July 9, 2016 Author Share Posted July 9, 2016 can i make the last survivor in a script? Link to comment
Captain Cody Posted July 9, 2016 Share Posted July 9, 2016 You can use a table, when they start they are all in the table, as they die / disconnect they are removed from the table, then using a timer, check every few seconds how many people are left in the table, if only one then display the message to that person and advance the map. Link to comment
Captain Cody Posted July 9, 2016 Share Posted July 9, 2016 aliveplayers = {} function setUpPlayers() for i,v in pairs(getElementsByType("player")) do if getElementData(v,"InSaidMiniGame") == true then aliveplayers[v] = v end end end function playerDeathOrQuit() for i,v in pairs(aliveplayers) do if v == source then aliveplayers[source] = nil end end end addEventHandler ( "onPlayerWasted", getRootElement(), playerDeathOrQuit) addEventHandler ( "onPlayerQuit", getRootElement(), playerDeathOrQuit) Link to comment
Captain Cody Posted July 9, 2016 Share Posted July 9, 2016 To list alive players use -- local amount = #alivePlayers Then to award the last player for i,v in pairs(alivePlayers)do outputChatBox("Congrats you survived",v) end Link to comment
florent6001 Posted July 9, 2016 Author Share Posted July 9, 2016 Do you have skype? I'm not really good in script 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