AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Array must be indexed... (https://forums.alliedmods.net/showthread.php?t=320462)

Shadows Adi 12-23-2019 09:51

Array must be indexed...
 
Code:
PHP Code:

public HudHPColor(Float:a, &Float:b, &Float:c)
{
    static 
r[3], g[3], b[3]
    
get_pcvar_string(g_msg_colorsr2)
    
    
strbreak(rg9b2)
    
str_to_float(r)
    
str_to_float(g)
    
str_to_float(b)


Error:
PHP Code:

plugin.sma(49 -- 50) : error 033: array must be indexed (variable "r")
plugin.sma(50 -- 51) : error 033: array must be indexed (variable "g")
plugin.sma(51 -- 52) : error 033: array must be indexed (variable "b")
plugin.sma(51 -- 52) : fatal error 107too many error messages on one line 


thEsp 12-23-2019 11:33

Re: Array must be indexed...
 
Jeez...
You are creating 3 (static) array variables and trying to use them independently without an index.
Just for the sake of record, what are you really trying to achieve?

HamletEagle 12-23-2019 12:49

Re: Array must be indexed...
 
It's pretty clear, split a string of the form "r g b"("255 255 255" for example) in integers representing the r g b channels value for the color.

You should assign str_to_float(*) to a/b/c, not r/g/b.

Bugsy 12-23-2019 18:19

Re: Array must be indexed...
 
thEsp, he's probably setting HUD color using a string cvar "255 0 0", or something, and needs the individual values.

Shadows Adi, consider using argparse

Shadows Adi 12-24-2019 11:56

Re: Array must be indexed...
 
Quote:

Originally Posted by Bugsy (Post 2677861)
thEsp, he's probably setting HUD color using a string cvar "255 0 0", or something, and needs the individual values.
[/URL]

something like this..

Shadows Adi 12-24-2019 11:56

Re: Array must be indexed...
 
Quote:

Originally Posted by thEsp (Post 2677817)
Jeez...
You are creating 3 (static) array variables and trying to use them independently without an index.
Just for the sake of record, what are you really trying to achieve?

yeap, I want that Nobel, ty.=)))


All times are GMT -4. The time now is 02:59.

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