DrPhoX Posted December 16, 2011 Share Posted December 16, 2011 Hello, i need help with script.... give money only for 2nd, 3rd, 4th, etc. .. but not for the 1st place ... I do not know why ... I do not know where the problem is so I send you two scripts. One will be "destructionderby.lua - default" script and place for money Place money: -------------- -- Race winner -------------- addEvent("onPlayerDestructionDerbyWin",true) addEventHandler("onPlayerDestructionDerbyWin",getRootElement(), function (winner) if getPlayerCount() >= 3 then local cashToWin = moneyEarnPart*getPlayerCount() if (tonumber(loadPlayerData(winner,"level")) >= 26) then cashToWin = cashToWin*1.1 end local playerCash = loadPlayerData(winner,"cash") savePlayerData(winner,"cash",playerCash +cashToWin) local playerCash = loadPlayerData(winner,"cash") outputChatBox ("#FF6600* #FFFFFF" .. getPlayerName(winner) .." #FFFFFFhas won! He/She gets $" .. tostring(cashToWin) .."#FF6600!",getRootElement(),255,255,255,true) return else outputChatBox("#FF6600* #FFFFFFNot enough players to earn money - #ABCDEF3 #FFFFFFrequired.",winner,255,255,255,true) end callClientFunction(winner,"deathReset") callClientFunction(winner,"playWinSound") local thePlayer = winner local newAmount = cashToWin totalMoneyEarnedAdd(thePlayer,cashToWin) scoreboardRefresh(thePlayer) refreshStats(thePlayer) progressBarUpdate(thePlayer) totalMoneyAchievements(thePlayer) end) and Destructionderby DestructionDerby = setmetatable({}, RaceMode) DestructionDerby.__index = DestructionDerby DestructionDerby:register('Destruction derby') function DestructionDerby:isApplicable() return not RaceMode.checkpointsExist() and Mode.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() <= 1 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 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() if #activePlayers == 1 then self.rankingBoard:add(activePlayers[1], timePassed) showMessage(getPlayerName(activePlayers[1]) .. ' is the final survivor!', 0, 255, 0) 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 Please help Link to comment
Cadu12 Posted December 16, 2011 Share Posted December 16, 2011 [16:49:06] Dr.Pho-X: cadu? i need help from you.... I'll send you a script that says the money when you end up on the 2nd and 3rd and 4th place, etc. .. but at first it does not work ... I'm learning the scripts but so far I'm not even fix this. [16:49:20 | Edited 16:49:21] Dr.Pho-X: i am rly i dont know how to fix it [16:49:31] *** Dr.Pho-X sent main_server.lua *** [16:49:48] • Carlos Eduardo •: I dont have time [16:50:05] Dr.Pho-X: [16:50:18] Dr.Pho-X: so later help me please ... i am rly need help [16:50:22] Dr.Pho-X: its short script [16:50:48] Dr.Pho-X: 29 paragraphs [16:51:33] • Carlos Eduardo •: hm [16:51:40] • Carlos Eduardo •: /debugscript 3? [16:52:09] Dr.Pho-X: script work [16:52:12] Dr.Pho-X: but not for 1st [16:52:12] Dr.Pho-X: place [16:52:55] • Carlos Eduardo •: [url=https://wiki.multitheftauto.com/wiki/TriggerEvent]https://wiki.multitheftauto.com/wiki/TriggerEvent[/url] [16:53:02] • Carlos Eduardo •: You have to edit your race [16:53:48] Dr.Pho-X: please.. can you fix it? [16:53:54] • Carlos Eduardo •: [16:53] • Carlos Eduardo •: <<< You have to edit your race [16:54:01] • Carlos Eduardo •: [16:52] • Carlos Eduardo •: <<< [url=https://wiki.multitheftauto.com/wiki/TriggerEvent]https://wiki.multitheftauto.com/wiki/TriggerEvent[/url] You have to edit your race [16:55:38] Dr.Pho-X: and it is? race_client.lua? [16:55:41] Dr.Pho-X: or _server.lua? [16:56:12 | Edited 17:29:35] • Carlos Eduardo •: modes folder [16:57:17] Dr.Pho-X: destructionderby.lua? [16:57:45] • Carlos Eduardo •: yea You cant read about triggerEvent? Link to comment
DrPhoX Posted December 16, 2011 Author Share Posted December 16, 2011 no.. because idk how Link to comment
Castillo Posted December 16, 2011 Share Posted December 16, 2011 DestructionDerby = setmetatable({}, RaceMode) DestructionDerby.__index = DestructionDerby DestructionDerby:register('Destruction derby') function DestructionDerby:isApplicable() return not RaceMode.checkpointsExist() and Mode.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() <= 1 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 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() if #activePlayers == 1 then self.rankingBoard:add(activePlayers[1], timePassed) triggerEvent("onPlayerDestructionDerbyWin",activePlayers[1],activePlayers[1]) showMessage(getPlayerName(activePlayers[1]) .. ' is the final survivor!', 0, 255, 0) 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 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