Tomc0 Posted August 27, 2013 Share Posted August 27, 2013 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
Castillo Posted August 27, 2013 Share Posted August 27, 2013 That event is triggered after all the players are dead and just 1 is alive. You can use onRacePlayerWasted and check their rank. Link to comment
Tomc0 Posted August 28, 2013 Author Share Posted August 28, 2013 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? 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
Tomc0 Posted August 30, 2013 Author Share Posted August 30, 2013 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 Can you please tell me what's wrong with it? I just can't find the problem, and that's annoying as hell 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 IIYAMA Posted August 30, 2013 Moderators Share Posted August 30, 2013 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
Tomc0 Posted August 30, 2013 Author Share Posted August 30, 2013 Thank you, but the rank is still returns 0 Link to comment
Moderators IIYAMA Posted August 30, 2013 Moderators Share Posted August 30, 2013 with how many people are you racing? Link to comment
Tomc0 Posted August 30, 2013 Author Share Posted August 30, 2013 Oh, I'm just testing it alone right now... But I will try it with another players soon. Do you think that's the problem? I need more players? Because that would be great... Link to comment
Moderators IIYAMA Posted August 30, 2013 Moderators Share Posted August 30, 2013 I think so, it returns 0, why would it not return another value? 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