| Blockland Forums > Modification Help |
| Gartaniums Questions -> checking to see who has the highest value |
| << < (2/2) |
| Gartanium:
hmm I'll try that, ty phflack. Edit: Allright this is what I came up with. I don't have time to test it but yeah. --- Code: ---function highestvote() { for(%i = 0; %i < clientgroup.getCount(); %i++) { %newclient = clientgroup.getobject(%i); if(%newclient.votecount > %oldclient.votecount) { %oldclient = %newclient; %newclient.votecount = 0; } } for(%i = 0; %i < clientgroup.getCount(); %i++) { %newclient = clientgroup.getobject(%i); if(%newclient.votecount == %oldclient.votecount) { %j++ if(%j == 2) { return 0; } } } return %oldclient; } --- End code --- |
| phflack:
i don't think you need %newclient.votecount = 0;, as it will reset by itself on the next loop also, what would the 2nd for loop do? the other one already finds the highest, if equal or not |
| Gartanium:
I put the 2nd loop in to see if two votecounts equal each other, and I put the votecount to 0 so on the 2nd loop, it wouldn't check for lower variables equaling each other. I only wanted it checking to see if the two highest equal each other. |
| phflack:
ah, for ties? you could use an = check after the > check, and if true, then put the name somewhere |
| Navigation |
| Message Index |
| Previous page |