Jump to content

onPlayerFinish


Ascla

Recommended Posts

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

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
  • Moderators

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

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

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
  • Moderators
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.

:roll:

For normal race use:

"onPlayerFinish"

[color=#00FF00]player[/color] = source 
[color=#00FF00]rank[/color] = argument1 
[color=#00FF00]time[/color] = argument2 

Link to comment
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...