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,

560x95.png
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) 

Ingame name: [sV]Kostya

Name in scripts: Kostya

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

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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 

560x95.png
  • 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) 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

I wonder why onPlayerFinishDD function does not work.

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

560x95.png
  • 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 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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 ?

560x95.png
  • Moderators
Posted

Try:

local timeHasPast = export.race:getTimePassed() 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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) 

560x95.png
Posted
outputDebugSring 

You got a typo there, it's:

outputDebugString 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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