Ascla Posted June 26, 2014 Share Posted June 26, 2014 Hey guys. I've a problem. I'm creating a script for dm server but I have a problem with onPlayerFinish. addEventHandler("onPlayerFinish", ....) doesn't work. I also try "onPlayerFinishDD", but it doesn't work. I would like recover toptime rank when a user take the hunter. Thank, Link to comment
Memory Posted June 26, 2014 Share Posted June 26, 2014 onPlayerFinish used only for race. For take the hunter you must use onPlayerPickUpRacePickup and check model of pickup vehicle. addEvent("onPlayerPickUpRacePickup", true) addEventHandler( "onPlayerPickUpRacePickup", getRootElement(), function( _, pickupType, vehicleModel ) if ( pickupType == "vehiclechange" ) and ( vehicleModel == 425 ) then outputChatBox( '[HUNTER] '..getPlayerName(source)..' has reached a Hunter!',getRootElement(),255,0,0 ) end end) Link to comment
Ascla Posted June 26, 2014 Author Share Posted June 26, 2014 Thank, but how to recover toptime rank ? I found the function onPlayerFinishDD, how to use it ? Link to comment
Moderators IIYAMA Posted June 26, 2014 Moderators Share Posted June 26, 2014 Use: "onPlayerWinDD" Link to comment
Ascla Posted June 26, 2014 Author Share Posted June 26, 2014 onPlayerWinDD doesn't work Link to comment
Moderators IIYAMA Posted June 26, 2014 Moderators Share Posted June 26, 2014 It is, when it is a dd map. Open your race zip/folder. Open the folder called "modes". There is a file called "destructionderby.lua".(open it) When you scroll down to line 74 you see this: triggerEvent( "onPlayerWinDD",activePlayers[1] ) Which makes it work, so don't be sad. addEvent("onPlayerWinDD", true) addEventHandler( "onPlayerWinDD", root, function() outputChatBox("You won the game!",source) end) Link to comment
Ascla Posted June 26, 2014 Author Share Posted June 26, 2014 Yes and, I must edit this file ? -- 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 Link to comment
Moderators IIYAMA Posted June 26, 2014 Moderators Share Posted June 26, 2014 No, stay of it. Add this to your code. addEvent("onPlayerWinDD", true) addEventHandler( "onPlayerWinDD", root, function() outputChatBox("You won the game!",source) end) Link to comment
Ascla Posted June 26, 2014 Author Share Posted June 26, 2014 This code don't work. When I reached the Hunter, this code has not launched the message Link to comment
Et-win Posted June 26, 2014 Share Posted June 26, 2014 Make it in race_toptimes (Or your DM toptimes). You can put the hunter AND toptime code in your outputChatBox if you put them in the function where the toptimes get saved. Link to comment
Ascla Posted June 26, 2014 Author Share Posted June 26, 2014 I wonder why onPlayerFinishDD function does not work. I can't put my code in toptime code because I use crypted resource. Link to comment
Moderators IIYAMA Posted June 26, 2014 Moderators Share Posted June 26, 2014 I wonder why onPlayerFinishDD function does not work.I can't put my code in toptime code because I use crypted resource. Because DD has no finish. For normal race use: "onPlayerFinish" [color=#00FF00]player[/color] = source [color=#00FF00]rank[/color] = argument1 [color=#00FF00]time[/color] = argument2 Link to comment
Ascla Posted June 26, 2014 Author Share Posted June 26, 2014 okay but in dm race, for reach a tt, user must have hunter. So I will use "onPlayerPickUpRacePickup" but how recover top time rank ? Link to comment
Moderators IIYAMA Posted June 26, 2014 Moderators Share Posted June 26, 2014 Try: local timeHasPast = export.race:getTimePassed() Link to comment
Ascla Posted June 26, 2014 Author Share Posted June 26, 2014 Try: local timeHasPast = export.race:getTimePassed() This function don't work My code : function hunter(pickupID, pickupType, vehicleModel) if (pickupType == "vehiclechange") then if (vehicleModel == 425) then outputDebugString ("Hunter !") local rang = call(getResourceFromName("race"), "getTimePassed") outputDebugSring(rang) end end end addEventHandler('onPlayerPickUpRacePickup', source, hunter) addEvent('onPlayerPickUpRacePickup', true) Link to comment
Castillo Posted June 26, 2014 Share Posted June 26, 2014 outputDebugSring You got a typo there, it's: outputDebugString Link to comment
Moderators IIYAMA Posted June 26, 2014 Moderators Share Posted June 26, 2014 Try: local timeHasPast = export.race:getTimePassed() This function don't work Fine if you take a no for correct answers, then figure it out by yourself. 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