AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Clamp (https://forums.alliedmods.net/showthread.php?t=75149)

anakin_cstrike 07-31-2008 09:42

Clamp
 
Hi, could you explain a bit more and give an example ?
"Clamp ensures that a variable stays within 2 threshold values"

PHP Code:

clamp(110,0,100) == 100
clamp
(9,0,10) == 


Arkshine 07-31-2008 09:49

Re: Clamp
 
with this exemple : clamp(MyValue,0,10)

If 'MyValue' < 0, it will return 0.

If 'MyValue' > 10, it will return 10

Otherwise, it will return 'MyValue'.

Bugsy 07-31-2008 10:42

Re: Clamp
 
Think of it as only allowing a number returned to be within the two values (min,max) entered. If the number entered exceeds the min or max, the relative min or max value is returned.

clamp( your number, min allowed , max allowed )

clamp( -55 , 0 , 10 ) = 0
clamp( 34 , 0 , 25 ) = 25

Arkshine 07-31-2008 10:45

Re: Clamp
 
As additional infos , all is written here : clamp()

Also, for float, use : floatclamp()

anakin_cstrike 07-31-2008 11:02

Re: Clamp
 
Thanks, i understand now :D


All times are GMT -4. The time now is 05:37.

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