Variables
How to check using an easy way to check which of the 4 variables has the highest value?
|
Re: Variables
PHP Code:
|
Re: Variables
Quote:
PHP Code:
|
Re: Variables
Make an array, if you want so much these "NoScope","Normal",etc. you can make an enum.
Like: PHP Code:
PHP Code:
PHP Code:
The loop will be: PHP Code:
So at the end you get the highest value of the options in the array, in the max_value variable and then you can use it like this: PHP Code:
|
Re: Variables
Code:
new array[4]Code:
max( array[ 0 ] , max( array[ 1 ] , max( array[ 2 ] , array[ 3 ] ) ) ); |
Re: Variables
Quote:
|
Re: Variables
If you didn't want to create an array you could try something like
new max = max(szNoScope, max(szNormal, max(szGravity, szVip))); if (szNoScope == max) { } else if (szNormal == max) { } else if (szGravity == max) { } else { // implied that szVip is max } Which I think would be the simplest for you to implement. The only problem with this method (and the array method) is that this will only tell you the first one that equals max, so to get more then one equaling max, just make them each their own if-statement. As a side note, don't use hungarian notation in a type-less language if you don't understand how it works. It's really annoying when it's super important to understand your code. http://en.wikipedia.org/wiki/Hungarian_notation |
Re: Variables
PHP Code:
|
Re: Variables
Quote:
|
Re: Variables
Normally it's working, but now it isnt. If it chooses Cmd_KillVip(id), it works, but with the vote it ain't working...
|
| All times are GMT -4. The time now is 00:28. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.