Nahar Posted December 25, 2013 Share Posted December 25, 2013 Hey all, I need little help, how i can make that when DD map start the last player alive( winner) can't drive more , and when a DM start the last player can finish the map. Here is my destructionderby.lua 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 getMapDM() then if getActivePlayerCount() <= 0 then triggerClientEvent ( "onWins", getRootElement()) RaceMode.endMap() triggerEvent ( "activatePodium", getRootElement()) triggerClientEvent ( "w3", getRootElement()) else TimerManager.createTimerFor("map",player):setTimer(clientCall, 2000, 1, player, 'Spectate.start', 'auto') end local activePlayers = getActivePlayers() if getActivePlayerCount() == 1 then if getElementModel(getPedOccupiedVehicle(activePlayers[1])) == 425 then setElementHealth(activePlayers[1],0) end end else if getActivePlayerCount() <= 1 then triggerClientEvent ( "showWinMessage", getRootElement()) RaceMode.endMap() triggerEvent ( "activatePodium", getRootElement()) triggerClientEvent ( "w3", getRootElement()) else TimerManager.createTimerFor("map",player):setTimer(clientCall, 2000, 1, player, 'Spectate.start', 'auto') end end end RaceMode.setPlayerIsFinished(player) showBlipsAttachedTo(player, false) end function DestructionDerby:onPlayerQuit(player) if isActivePlayer(player) then self:handleFinishActivePlayer(player) if getMapDM() then if getActivePlayerCount() <= 0 then RaceMode.endMap() triggerEvent ( "activatePodium", getRootElement()) triggerClientEvent ( "w3", getRootElement()) end else if getActivePlayerCount() <= 1 then RaceMode.endMap() triggerEvent ( "activatePodium", getRootElement()) triggerClientEvent ( "w3", getRootElement()) end 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() if #activePlayers == 1 then self.rankingBoard:add(activePlayers[1], "Winner") callClientFunction(getRootElement(),"setPlayerNameOnWinMessege", activePlayers[1]) triggerEvent("onPlayerDestructionDerbyWin", getRootElement(), activePlayers[1]) end end ------------------------------------------------------------ -- activePlayerList stuff -- function isActivePlayer( player ) return table.find( g_CurrentRaceMode.activePlayerList, player ) end function addActivePlayer( player ) table.insertUnique( g_CurrentRaceMode.activePlayerList, player ) end function removeActivePlayer( player ) table.removevalue( g_CurrentRaceMode.activePlayerList, player ) end function finishActivePlayer( player ) table.removevalue( g_CurrentRaceMode.activePlayerList, player ) table.insertUnique( g_CurrentRaceMode.finishedPlayerList, _getPlayerName(player) ) end function getFinishedPlayerCount() return #g_CurrentRaceMode.finishedPlayerList end function getActivePlayerCount() return #g_CurrentRaceMode.activePlayerList end function getActivePlayers() return g_CurrentRaceMode.activePlayerList end function getMapDM() local getMapName = g_MapInfo.name if string.find(getMapName, "[DM]", 1, true) then return true else return false end end Link to comment
manve1 Posted December 25, 2013 Share Posted December 25, 2013 Use [lua ] [/lua ] tags Link to comment
Whit3 Posted May 12, 2014 Share Posted May 12, 2014 (edited) LoL! - This is my Server side script.... Edited June 6, 2014 by Guest Link to comment
Arnold-1 Posted May 12, 2014 Share Posted May 12, 2014 LoL!- This is my Client ... ........................................ what he have posted is a server side. and yes use lua tags. Link to comment
Whit3 Posted June 6, 2014 Share Posted June 6, 2014 is the same for me, it's always mine. Link to comment
Arnold-1 Posted June 6, 2014 Share Posted June 6, 2014 People doesn't download serverside, so it isn't yours, and IF you were saying the truth, so it's your responsibility to protect your scripts(i know it's not yours) Link to comment
Whit3 Posted June 14, 2014 Share Posted June 14, 2014 1)triggerClientEvent ( "w3", getRootElement()) -- if you don't KNOw, W3 mean my nick Whit3 ----> W3 2)I know that I didn't compiled it, I forgot. 3) this is the edit of destructionderby ( I know that i didn't created this script ) 4) how he took this server-side? 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