Raised This Month: $ Target: $400
 0% 

Higher cvar


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RuleBreaker
Senior Member
Join Date: May 2011
Old 07-31-2011 , 18:40   Higher cvar
Reply With Quote #1

I have 3 cvars, how to see whitch one is higher?
here`s example what i want to do
new cvar1
new cvar2
new cvar3

if cvar1 == higher
function1
if cvar2 == higher
function2
if cvar3 == higher
function3
if cvar1, cvar2, cvar3 == 0
function4
if cvar1, cvar2 == higher
function5
......

You get it?
RuleBreaker is offline
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 07-31-2011 , 18:58   Re: Higher cvar
Reply With Quote #2

higher than what?
OvidiuS is offline
Send a message via Skype™ to OvidiuS
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-31-2011 , 19:02   Re: Higher cvar
Reply With Quote #3

Why do you need this exacly ?

But to answer your question... if you want to know which cvar is higher:
Code:
new highestCvar = 0

if(cvar1 > cvar2 && cvar1 > cvar3)
    highestCvar = 1

else if(cvar2 > cvar1 && cvar2 > cvar3)
    highestCvar = 2

else if(cvar3 > cvar2 && cvar3 > cvar1)
    highestCvar = 3
... but I think there's a better way for it.

Or if you just want the highest value of the three cvars:
Code:
new highestValue = max(max(cvar1, cvar2), cvar3)
Quote:
Originally Posted by OvidiuS View Post
higher than what?
Higher than themselves I guess, he's making a bad code example.
__________________
Hunter-Digital is offline
RuleBreaker
Senior Member
Join Date: May 2011
Old 07-31-2011 , 19:17   Re: Higher cvar
Reply With Quote #4

I meant the highest
@hunter thanks, but how to make statment "if" if they`re all 0 and if there`s 2 equal?
RuleBreaker is offline
Old 07-31-2011, 19:24
eXtrem
This message has been deleted by eXtrem.
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-31-2011 , 19:51   Re: Higher cvar
Reply With Quote #6

Code:
new values[/* how many cvars you have */] values[0] = get_pcvar_num(/* 1st cvar */) values[1] = get_pcvar_num(/* 2nd cvar */) // etc new highestIndex, highestVal = values[0] for(new i = 1, val, highestVal = values[0]; i < sizeof(values); i++) {     if((val = values[i]) > highestVal)     {         highestVal = val         highestIndex = i     } } switch(highestIndex) {     case 0: function1()     case 1: function2()     // etc. }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode