Mossy Posted May 8, 2013 Share Posted May 8, 2013 function raceWin(rank) if rank ~= 1 then return end local playername = getPlayerName(source) givePlayerMoney(source,1000)---money what player get if he finish.(Default=1000) outputChatBox("* "..playername.." took $1000 for being the last survivor!",root,51,153,255) end addEventHandler("onPlayerFinish", root, raceWin ) Made this for DD. Doesn't seem to be working. No errors in debug. Any ideas? Link to comment
Castillo Posted May 9, 2013 Share Posted May 9, 2013 Try adding: addEvent ( "onPlayerFinish", true ) Link to comment
Mossy Posted May 9, 2013 Author Share Posted May 9, 2013 Try adding: addEvent ( "onPlayerFinish", true ) Still nothing. Link to comment
Castillo Posted May 9, 2013 Share Posted May 9, 2013 Are you sure that the script is set to server side on meta.xml? Link to comment
Mossy Posted May 9, 2013 Author Share Posted May 9, 2013 Are you sure that the script is set to server side on meta.xml? I found that mistake and made it serverside, but it's still not working. Here's the code again: addEvent ( "onPlayerFinish", true ) function raceWin(rank) if rank ~= 1 then return end local playername = getPlayerName(source) givePlayerMoney(source,1000)---money what player get if he finish.(Default=1000) outputChatBox("* "..playername.." took $1000 for being the last survivor!",root,51,153,255) end addEventHandler("onPlayerFinish", root, raceWin ) Link to comment
Mossy Posted May 9, 2013 Author Share Posted May 9, 2013 Try debugging it. Debug doesn't say anything about the script. Link to comment
Castillo Posted May 9, 2013 Share Posted May 9, 2013 Is not what I meant, I mean debug the code, piece by piece. Link to comment
Cadu12 Posted May 9, 2013 Share Posted May 9, 2013 "onPlayerFinish" is only for Race, so doesn't work in DD/DM. Link to comment
Mossy Posted May 9, 2013 Author Share Posted May 9, 2013 "onPlayerFinish" is only for Race, so doesn't work in DD/DM. Then what event should I use? Link to comment
Castillo Posted May 9, 2013 Share Posted May 9, 2013 Try: "onPlayerWinDD", has no arguments as far as I know. Link to comment
Mossy Posted May 11, 2013 Author Share Posted May 11, 2013 Try: "onPlayerWinDD", has no arguments as far as I know. That doesn't work either. Link to comment
3NAD Posted May 11, 2013 Share Posted May 11, 2013 Check this: addEvent ( "onPlayerFinish", true ) function raceWin ( rank ) if rank then if rank ~= 1 then return outputChatBox ( "* Your Rank [ "..rank.." ]", source, 255, 255, 0, true ) end local playername = getPlayerName ( source ) givePlayerMoney ( source, 1000 ) -- money what player get if he finish.(Default=1000) outputChatBox ( "* "..playername.." took $1000 for being the last survivor!", root, 51, 153, 255 ) else outputChatBox ( "* You Don't have any Rank.", source, 255, 0, 0, true ) end end addEventHandler ( "onPlayerFinish", root, raceWin ) If he didn't say anything at ChatBox. The Event isn't added at any resource !! Link to comment
Castillo Posted May 11, 2013 Share Posted May 11, 2013 3NAD, read this quote: "onPlayerFinish" is only for Race, so doesn't work in DD/DM. He's obviously using DD/DM and not race with checkpoints, so that event won't work. @Mossy: Go to "race/modes/destructionderby.lua" and replace the function: "handleFinishActivePlayer" with this one: 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 local rank = self:getPlayerRank(player) finishActivePlayer(player) if rank and rank > 1 then triggerEvent( "onPlayerFinishDD",player,tonumber( rank ) ) end -- 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) triggerEvent( "onPlayerWinDD",activePlayers[1] ) end end Link to comment
Mossy Posted May 11, 2013 Author Share Posted May 11, 2013 Guess what? That doesn't work either. All I want is for whenever someone is the last survivor in DD to receive $1000. Link to comment
Castillo Posted May 11, 2013 Share Posted May 11, 2013 You replaced that and you have the other script which uses that event? Link to comment
Mossy Posted May 11, 2013 Author Share Posted May 11, 2013 I replaced the destructionderby.lua yes but which script do I use? 3NAD's? Link to comment
Castillo Posted May 11, 2013 Share Posted May 11, 2013 No, use this: function raceWin ( ) local playername = getPlayerName ( source ) givePlayerMoney ( source, 1000 ) outputChatBox ( "* ".. playername .." took $1000 for being the last survivor!", root, 51, 153, 255 ) end addEvent ( "onPlayerWinDD", true ) addEventHandler ( "onPlayerWinDD", root, raceWin ) Link to comment
Mossy Posted May 12, 2013 Author Share Posted May 12, 2013 Worked. Thanks! But now I decided to add more positions but of course it doesn't work. function raceWin ( ) local playername = getPlayerName ( source ) givePlayerMoney ( source, 500 ) outputChatBox ( "* " .. playername .. " #ABCDEFreceived $500 for being the last survivor!", root, 255, 255, 255, true ) end addEvent ( "onPlayerWinDD", true ) addEventHandler ( "onPlayerWinDD", root, raceWin ) addEventHandler("onPlayerRaceWasted",root,function() local rank = exports.race:getPlayerRank(source) if rank == 2 then givePlayerMoney ( source, 250 ) outputChatBox ( "#ABCDEFYou died in 2nd place and received $250.", source, 255, 255, 255, true) elseif rank == 3 then givePlayerMoney ( source, 100 ) outputChatBox ( "#ABCDEFYou died in 3rd place and received $100.", source, 255, 255, 255, true) elseif rank == 4 then givePlayerMoney ( source, 50 ) outputChatBox ( "#ABCDEFYou died in 4th place and received $50.", source, 255, 255, 255, true) elseif rank == 5 then givePlayerMoney ( source, 25 ) outputChatBox ( "#ABCDEFYou died in 5th place and received $25.", source, 255, 255, 255, true) elseif rank == 6 then outputChatBox ( "#ABCDEFYou died in 6th place and received nothing.", source, 255, 255, 255, true) end end) Link to comment
Castillo Posted May 12, 2013 Share Posted May 12, 2013 Use the event: "onPlayerFinishDD", the first argument is the rank. Link to comment
Mossy Posted May 12, 2013 Author Share Posted May 12, 2013 Got a bit confused. Is this correct? function raceWin ( ) local playername = getPlayerName ( source ) givePlayerMoney ( source, 500 ) outputChatBox ( "* " .. playername .. " #ABCDEFreceived $500 for being the last survivor!", root, 255, 255, 255, true ) end addEvent ( "onPlayerWinDD", true ) addEventHandler ( "onPlayerWinDD", root, raceWin ) local rank = exports.race:getPlayerRank(source) if rank == 2 then givePlayerMoney ( source, 250 ) outputChatBox ( "#ABCDEFYou died in 2nd place and received $250.", source, 255, 255, 255, true) elseif rank == 3 then givePlayerMoney ( source, 100 ) outputChatBox ( "#ABCDEFYou died in 3rd place and received $100.", source, 255, 255, 255, true) elseif rank == 4 then givePlayerMoney ( source, 50 ) outputChatBox ( "#ABCDEFYou died in 4th place and received $50.", source, 255, 255, 255, true) elseif rank == 5 then givePlayerMoney ( source, 25 ) outputChatBox ( "#ABCDEFYou died in 5th place and received $25.", source, 255, 255, 255, true) elseif rank == 6 then outputChatBox ( "#ABCDEFYou died in 6th place and received nothing.", source, 255, 255, 255, true) end end) addEvent ( "onPlayerWinDD", true ) addEventHandler ( "onPlayerWinDD", rank, raceWin ) Link to comment
Castillo Posted May 12, 2013 Share Posted May 12, 2013 No, is not. You must create a new function, then use that event I told you. Link to comment
Mossy Posted May 12, 2013 Author Share Posted May 12, 2013 I kind of understand what you're saying. I'm sure this is incorrect. I want just the 1st place to be shown to everyone and I want 2nd-6th to be shown to only the player that died in that position. function raceWin ( ) local playername = getPlayerName ( source ) givePlayerMoney ( source, 500 ) outputChatBox ( "* " .. playername .. " #ABCDEFreceived $500 for being the last survivor!", root, 255, 255, 255, true ) end addEvent ( "onPlayerWinDD", true ) addEventHandler ( "onPlayerWinDD", root, raceWin ) function raceWin ( ) local rank = exports.race:getPlayerRank(source) if rank == 2 then givePlayerMoney ( source, 250 ) outputChatBox ( "#ABCDEFYou died in 2nd place and received $250.", source, 255, 255, 255, true) elseif rank == 3 then givePlayerMoney ( source, 100 ) outputChatBox ( "#ABCDEFYou died in 3rd place and received $100.", source, 255, 255, 255, true) elseif rank == 4 then givePlayerMoney ( source, 50 ) outputChatBox ( "#ABCDEFYou died in 4th place and received $50.", source, 255, 255, 255, true) elseif rank == 5 then givePlayerMoney ( source, 25 ) outputChatBox ( "#ABCDEFYou died in 5th place and received $25.", source, 255, 255, 255, true) elseif rank == 6 then outputChatBox ( "#ABCDEFYou died in 6th place and received nothing.", source, 255, 255, 255, true) end end) addEvent ( "onPlayerWinDD", true ) addEventHandler ( "onPlayerWinDD", rank, raceWin ) Link to comment
Castillo Posted May 12, 2013 Share Posted May 12, 2013 function raceWin ( ) local playername = getPlayerName ( source ) givePlayerMoney ( source, 500 ) outputChatBox ( "* " .. playername .. " #ABCDEFreceived $500 for being the last survivor!", root, 255, 255, 255, true ) end addEvent ( "onPlayerWinDD", true ) addEventHandler ( "onPlayerWinDD", root, raceWin ) addEvent ( "onPlayerFinishDD", true ) addEventHandler ( "onPlayerFinishDD", root, function ( rank ) if ( rank == 2 ) then givePlayerMoney ( source, 250 ) outputChatBox ( "#ABCDEFYou died in 2nd place and received $250.", source, 255, 255, 255, true) elseif ( rank == 3 ) then givePlayerMoney ( source, 100 ) outputChatBox ( "#ABCDEFYou died in 3rd place and received $100.", source, 255, 255, 255, true) elseif ( rank == 4 ) then givePlayerMoney ( source, 50 ) outputChatBox ( "#ABCDEFYou died in 4th place and received $50.", source, 255, 255, 255, true) elseif ( rank == 5 ) then givePlayerMoney ( source, 25 ) outputChatBox ( "#ABCDEFYou died in 5th place and received $25.", source, 255, 255, 255, true) elseif ( rank == 6 ) then outputChatBox ( "#ABCDEFYou died in 6th place and received nothing.", source, 255, 255, 255, true) end end ) Link to comment
Mossy Posted May 12, 2013 Author Share Posted May 12, 2013 Didn't work. No errors. And remember, I want just the 1st place to be shown to everyone and I want 2nd-6th to be shown to only the player that died in that position. 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