Raised This Month: $51 Target: $400
 12% 

error 033: array must be indexed(variable "g_fColor")


Post New Thread Reply   
 
Thread Tools Display Modes
amirwolf
Senior Member
Join Date: Feb 2019
Location: Iran
Old 07-10-2023 , 17:12   Re: error 033: array must be indexed(variable "g_fColor")
Reply With Quote #11

HI.AGAIN
I have a strange problem with the code
The random color is applied once unless the server is restarted once
What is wrong with it?
PHP Code:
                    else if(equal(szKey"BARRIER_COLOR"))
                    {
                        
parse(szValueszTemp[0], charsmax(szTemp[]), szTemp[1], charsmax(szTemp[]), szTemp[2], charsmax(szTemp[]))
                        
                        for(
03i++)
                        {
                            
g_eSettings[BARRIER_COLOR][i] = _:floatclamp(str_to_float(szTemp[i]), -1.0255.0)
                            if (
g_eSettings[BARRIER_COLOR][i] == -1.0)
                            {
                                
g_eSettings[BARRIER_COLOR][i] = g_fColor[random(MAX_COLORS)][i];
                            }
                        }
                    } 
__________________
amirwolf is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-10-2023 , 22:01   Re: error 033: array must be indexed(variable "g_fColor")
Reply With Quote #12

I can only assume that you're loading a file in that code. If you use random() in this code, it will only execute once when the file is loaded, this is what you've coded.

If you want to choose a random color each time the color needs to be used, you have to call random() just before you use the color. I gave you all the code you need to do this, and you need to execute it when you want the random color index. The variable setting is the value of the color array index that you've stored which will be -1 if you want it to be random.

It would probably be better for you to attach your plugin and explain, without using code, what specifically you're wanting to achieve. This is the best way to help us help you.
__________________

Last edited by fysiks; 07-10-2023 at 22:03.
fysiks is online now
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 16:30.


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