AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Color blend code (https://forums.alliedmods.net/showthread.php?t=183702)

.Dare Devil. 04-25-2012 13:06

Color blend code
 
Hi, today i got one problem what i can not solve.
usually if that happen then i do not script for several weeks.
But today i decided to ask your help!

this is a color blend code what i made.
I dont see any bug here but there is a bug, its not working like i want.

I give him correct rgb value and rgb value what must be
mustrgb[] = must rgb value
gvar[Ent][6] = correct red value
gvar[Ent][7] = correct green value
gvar[Ent][8] = correct blue value

gvar[Ent][3] = power that -/+ correct value ( gvar[Ent][6] -= gvar[Ent][3] or gvar[Ent][6] += gvar[Ent][3] )

PHP Code:

                                              // Red Case
                                              
if ( gvar[Ent][6] != mustrgb[0] )
                                              {
                            if ( 
gvar[Ent][6] > mustrgb[0] - gvar[Ent][3] )
                            {    
                                
musttemp mustrgb[0] - gvar[Ent][6]
                                if ( 
musttemp gvar[Ent][3] + )
                                {
                                    
gvar[Ent][6] = mustrgb[0]
                                }
                                else
                                {
                                    
gvar[Ent][6] -= gvar[Ent][3]
                                }
                            }

                            if ( 
gvar[Ent][6] < mustrgb[0] + gvar[Ent][3] )
                            {
                                
musttemp mustrgb[0] - gvar[Ent][6]
                                if ( 
musttemp gvar[Ent][3] + )
                                {
                                    
gvar[Ent][6] = mustrgb[0]
                                }
                                else
                                {
                                    
gvar[Ent][6] += gvar[Ent][3]
                                }
                            }
                        }

                        
// Green Case
                        
if ( gvar[Ent][7] != mustrgb[1] )
                        {
                            if ( 
gvar[Ent][7] > mustrgb[1] - gvar[Ent][3] )
                            {    
                                
musttemp mustrgb[1] - gvar[Ent][7]
                                if ( 
musttemp gvar[Ent][3] + )
                                {
                                    
gvar[Ent][7] = mustrgb[1]
                                }
                                else
                                {
                                    
gvar[Ent][7] -= gvar[Ent][3]
                                }
                            }

                            if ( 
gvar[Ent][7] < mustrgb[1] + gvar[Ent][3] )
                            {
                                
musttemp mustrgb[1] - gvar[Ent][7]
                                if ( 
musttemp gvar[Ent][3] + )
                                {
                                    
gvar[Ent][7] = mustrgb[1]
                                }
                                else
                                {
                                    
gvar[Ent][7] += gvar[Ent][3]
                                }
                            }
                        }

                        
// Blue Case
                        
if ( gvar[Ent][8] != mustrgb[2] )
                        {
                            if ( 
gvar[Ent][8] > mustrgb[2] - gvar[Ent][3] )
                            {    
                                
musttemp mustrgb[2] - gvar[Ent][8]
                                if ( 
musttemp gvar[Ent][3] + )
                                {
                                    
gvar[Ent][8] = mustrgb[2]
                                }
                                else
                                {
                                    
gvar[Ent][8] -= gvar[Ent][3]
                                }
                            }

                            if ( 
gvar[Ent][8] < mustrgb[2] + gvar[Ent][3] )
                            {
                                
musttemp mustrgb[2] - gvar[Ent][8]
                                if ( 
musttemp gvar[Ent][3] + )
                                {
                                    
gvar[Ent][8] = mustrgb[2]
                                }
                                else
                                {
                                    
gvar[Ent][8] += gvar[Ent][3]
                                }
                            }
                        } 

the problem is that not working at all.
only the red value seems to move but very wrong way.

So what is wrong on my code?
Thanks!


All times are GMT -4. The time now is 07:54.

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