'LinKin Posted March 10, 2014 Share Posted March 10, 2014 Hello, I've this: onPlayerFinishDD There I get the rank of the player. (Position when he died) I want to give some money to the player according to the position(rank) and the number of players online in the server. But I cannot find a good formula... Can someone here give me a hand with that? It really requires creativity PD: Also onPlayerWinDD Thanks. Link to comment
xXMADEXx Posted March 10, 2014 Share Posted March 10, 2014 maybe you could do something like: local giveCash = (getPlayerCount()*3)-(rank*2) and of course you can always adjust it. Link to comment
'LinKin Posted March 10, 2014 Author Share Posted March 10, 2014 Uh, Thank you for that fast reply. Link to comment
Moderators Citizen Posted March 10, 2014 Moderators Share Posted March 10, 2014 I've this: onPlayerFinishDDThere I get the rank of the player. (Position when he died) Are you sure that onPlayerFinishDD is triggered when someone dies ?? I would say onPlayerRaceWasted when a player dies Link to comment
xXMADEXx Posted March 10, 2014 Share Posted March 10, 2014 I've this: onPlayerFinishDDThere I get the rank of the player. (Position when he died) Are you sure that onPlayerFinishDD is triggered when someone dies ?? I would say onPlayerRaceWasted when a player dies He probably has a custom game-mode. He is looking for a math formula, not to fix his script. Link to comment
'LinKin Posted March 10, 2014 Author Share Posted March 10, 2014 No, yes Citizen. I've been developing this for like 1 month. And onPlayerFinishDD triggers when: Someone dies (exept when the winner of the match dies) When a player quits I think it's more efficient for DD. Because in every server of DD where they have kills script, for example if u kill a player but he quits before dying, u would not get the kill. But using this event (onPlayerFinishDD) u would not have that 'error'/bug. @Madex: I will think about more options for the formula. I have this info (money gained per event) Kill = 15 Ast.Kill = 10 +1 Min Playtime = 5 I'd need to 'adjust' the money gained by finishing the match in a certain position, so that it's more than 15.. If you have any idea just write it down, It'd be appreciated Link to comment
'LinKin Posted March 11, 2014 Author Share Posted March 11, 2014 I need to find the formula that gives me what I want. Which is the following: With 5 players in server: Rank 1 = $ 15 Rank 2 = $ 11 Rank 3 = $ 8 Rank 4 = $ 6 Rank 5 = $ 5 Do you notice the pattern? - Last rank will get the amount of cash corresponding to the players in the server. Then the upper rank will get the former rank's amount of cash + the number of positions climbed... Let me explain graphically because It's kinda confusing using words. Read this from the bottom to the top: Rank 1 = $ 11+4 = $ 15 Rank 2 = $ 8+3 = $ 11 Rank 3 = $ 6+2 = $ 8 Rank 4 = $ 5+1 = $ 6 Rank 5 = $ 5 I need to find out a formula for that.. Can you help me? Link to comment
arezu Posted March 11, 2014 Share Posted March 11, 2014 I need to find the formula that gives me what I want. Which is the following:Read this from the bottom to the top: Rank 1 = $ 11+4 = $ 15 Rank 2 = $ 8+3 = $ 11 Rank 3 = $ 6+2 = $ 8 Rank 4 = $ 5+1 = $ 6 Rank 5 = $ 5 I need to find out a formula for that.. Can you help me? We can see that Rank 1 - Rank 2 = 4 Rank 2 - Rank 3 = 3 Rank 3 - Rank 4 = 2 etc, so the difference is one less for each rank (not tested) local playersAtStartOfRound = 5 -- Highest rank should be rank 1, while lowest being = playersAtStartOfRound function getCashByRank(rank) local rankDiff = (playersAtStartOfRound - 1) - (rank - 1) -- n * (n + 1) / 2 = sum equation return playersAtStartOfRound + (rankDiff * (rankDiff + 1) / 2) end Link to comment
'LinKin Posted March 12, 2014 Author Share Posted March 12, 2014 Thanks arezu- I had done it this way. But yours is obviously more efficient. function refreshMoneyToGive () for i = 1, #moneyToGiveTable do table.remove(moneyToGiveTable, i) end local amount = currentPlayerCount local increase = 0 for i = currentPlayerCount, 1, -1 do amount = amount + increase moneyToGiveTable[i] = amount increase = increase + 1 end end And then I just took the money to give like this: moneyToGive[rank] 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