Jump to content

onPlayerFinish


Ascla

Recommended Posts

Posted

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,

Posted

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) 

  • Moderators
Posted

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) 

Posted

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 

  • Moderators
Posted

No, stay of it.

Add this to your code.

    addEvent("onPlayerWinDD", true) 
    addEventHandler( "onPlayerWinDD", root, 
    function() 
        outputChatBox("You won the game!",source) 
    end) 

Posted

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.

Posted

I wonder why onPlayerFinishDD function does not work.

I can't put my code in toptime code because I use crypted resource.

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

Posted

okay but in dm race, for reach a tt, user must have hunter.

So I will use "onPlayerPickUpRacePickup" but how recover top time rank ?

Posted
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) 

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

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