AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] Assign constants to an arrays of variable (https://forums.alliedmods.net/showthread.php?t=241908)

Flick3rR 06-11-2014 06:12

[HELP] Assign constants to an arrays of variable
 
Hey, guys! I don't know if my termins are right, but I guess so. Now on the problem. Let's say I have three constants - const1, const2 and const3. And I want to assing them to arrays in one variable. Like the first array of the var should be equal to the first const, the second array to be equal to second const and etc. I don't even know if that's possible, but if it is, I would want to know the way. Let me show you what I've tried:
PHP Code:

new const1[][] = {"""Something1"}
new 
const2[][] = {"""Something2"}
new 
const3[][] = {"""Something3"}

//...//
new Consts[3]
Consts[0] = const1
Consts
[1] = const2
Consts
[2] = const3 

But I get error - Must be assigned to an array. Only when I add an index to the const, like a num from it, it's all right. I know, that it should be equal to something, when it's variable, but I want the variable's array to be equal just to the const name. Tried with defines, but it's too far hardcoding - maany errors. Any ideas?

fysiks 06-11-2014 06:28

Re: [HELP] Assing constants to an arrays of variable
 
So you are trying to use pointers? If you provided information about what you are actually trying to do, a better solution could probably be found (aka The XY Problem).

WildCard65 06-11-2014 06:40

Re: [HELP] Assing constants to an arrays of variable
 
Hmm, thread title needs a little repair.

Flick3rR 06-11-2014 06:59

Re: [HELP] Assign constants to an arrays of variable
 
The whole story is that I want to use the different constants as one variable with arrays in a loop, where to loop between the arrays of variable. I say again, maybe this what I call 'array' is not the same as what it means, but i mean the [32] after the var for example (think these were vector cells, but noe pretty sure). So, I need to use different const names in a loop, which are in one variable, and Variable[0] will be const1, Varriable[1] will be const2, etc. I'm not sure if this is possible.

WildCard65 06-11-2014 07:17

Re: [HELP] Assign constants to an arrays of variable
 
If this is true, you have to use a string function in order to change strings around (like strcopy)

SpeeDeeR 06-11-2014 08:24

Re: [HELP] Assign constants to an arrays of variable
 
To beging with, you are trying to assign 2D array (const) to 1D array(Consts)
PHP Code:

 copy(Constscharsmax(Consts), const1[0]); 

I have no idea what are you trying to achieve though.

Flick3rR 06-11-2014 09:03

Re: [HELP] Assign constants to an arrays of variable
 
Okay. Let me explain more. I want to put three consts into one variable with three vector cells. Maybe if I make the variable with two arrays (I mean two [][]) and put in the frist 3 vector cells, because the consts are three, and in the second vector cells I will have to put the size of each const. But it's only one array (the second []), when I have to put different sizes of consts for the three different consts in the first array (which is [3]). Like when the first array is [0], the second to be [sizeof const1], when the first array is [1], the second to be [sizeof const2]. Don't know how to explain it, but I want to get the different const name when the vector cell of the variable is different. For the different cell to result a different const. Again, don't know if this imaginated method is possible.

hleV 06-11-2014 09:59

Re: [HELP] Assing constants to an arrays of variable
 
Quote:

Originally Posted by fysiks (Post 2149703)
The XY Problem


Flick3rR 06-11-2014 10:02

Re: [HELP] Assign constants to an arrays of variable
 
Don't know snything 'bout that XY problem. :D Can someone explain, or it is still unsolved?

fysiks 06-11-2014 14:58

Re: [HELP] Assign constants to an arrays of variable
 
Quote:

Originally Posted by Flick3rR (Post 2149793)
Don't know snything 'bout that XY problem. :D Can someone explain, or it is still unsolved?

http://mywiki.wooledge.org/XyProblem


All times are GMT -4. The time now is 09:42.

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