Jump to content

DD "onPlayerWinDD"


Tomc0

Recommended Posts

Hell guys.

I'm doing an addon for the gamemode DD, and I have a little problem. I want to get how many times the player finished in the first, second or the third places. I have an idea how to do this, but it's looks like that's not going to work.

  
firstPlace = 0 
secondPlace = 0 
thirdPlace = 0 
  
addEvent("onCalculatePlace",true) 
addEvent("onPlayerWinDD",true) 
addEvent("onPlayerFinishDD",true) 
  
function getIfFirstPlace()  
    firstPlace = firstPlace + 1  
end 
addEventHandler("onPlayerWinDD",getRootElement(),getIfFirstPlace) 
  
function getOtherPlaces(rank)  
    if(rank == 2) then 
        secondPlace = secondPlace + 1 
    else if(rank == 3) then 
        thirdPlace = thirdPlace + 1 
    end 
    end 
    triggerEvent("onCalculatePlace",true) 
end 
addEventHandler("onPlayerFinishDD",getRootElement(),getOtherPlaces) 
  
function setPlaceData()  
    setAccountData(account,"firstPlaces",firstPlace) -- there was an "account" variable in an other file that I made  
    setAccountData(account,"secondPlaces",secondPlace) 
    setAccountData(account,"thirdPlaces",thirdPlace) 
end 
addEventHandler("onCalculatePlace",getRootElement(),setPlaceData) 
  
function getPlaceData()  
    firstPlace = getAccountData(account,"firstPlaces") 
    secondPlace = getAccountData(account,"secondPlaces") 
    thirdPlace = getAccountData(account,"thirdPlaces") 
    outputChatBox("|"..tostring(firstPlace).."|"..tostring(secondPlace).."|"..tostring(thirdPlace).."|") 
end 
addCommandHandler("place",getPlaceData) 
  

I don't know why this is not working. The MTA not supports those DD events anymore?

If you can, please help me! :)

Thank you!

Link to comment

Thanks, but there is no "rank" parameter for it, so I can't really use it. Should I use the "getPlayerRank" function? Because I used it before, and because I called it when the player "died", the rank was 0. Any other ideas? :S

Oh, and I've seen this forum topic: /viewtopic.php?f=91&t=58893&p=563255

And that's the reason why I used those DD functions... They are worked for this guy.

Link to comment

So, now, my code looks like that:

function getOtherPlaces(rank)  
    if(exports["race"]:getPlayerRank(player) == 1) then         
        --firstPlace = firstPlace + 1 
        outputChatBox("1") 
        --triggerEvent("onCalculatePlace",getRootElement()) 
    else if(exports["race"]:getPlayerRank(player) == 2) then 
        --secondPlace = secondPlace + 1  
        --triggerEvent("onCalculatePlace",getRootElement()) 
    else if(exports["race"]:getPlayerRank(player) == 3) then   
        --thirdPlace = thirdPlace + 1 
        --triggerEvent("onCalculatePlace",getRootElement()) 
    else if(exports["race"]:getPlayerRank(player) == 4) then 
     
    else if(exports["race"]:getPlayerRank(player) == 5) then 
     
    else if(exports["race"]:getPlayerRank(player) == 6) then  
     
    else if(exports["race"]:getPlayerRank(player) == 7) then  
     
    else if(exports["race"]:getPlayerRank(player) == -- s8) --> then  
     
    else if(exports["race"]:getPlayerRank(player) == 9) then  
     
    else if(exports["race"]:getPlayerRank(player) == 10) then 
     
    end 
    end 
    end 
    end 
    end 
    end 
    end 
    end 
    end 
    end 
end 
addEventHandler("onRacePlayerWasted",getRootElement(),getOtherPlaces) 

But still not works :S Can you please tell me what's wrong with it? I just can't find the problem, and that's annoying as hell :D Maybe the problem is that I want to write a resource for the DD mod? I mean maybe the "race" functions are don't really working on the Destruction Derby...

Thanks.

Link to comment
  • Moderators
function getOtherPlaces(vehicle) 
    local rank = exports["race"]:getPlayerRank(source) 
    if rank then         
        outputChatBox("Player rank: " .. rank) 
    end 
end 
addEventHandler("onPlayerRaceWasted",getRootElement(),getOtherPlaces) 

Updated

Reasons why it did not work:

- non defined player, (source)

- wrong event: onRacePlayerWasted > onPlayerRaceWasted

- defined the vehicle as rank

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