SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Scripting Help (https://forum.sa-mp.com/forumdisplay.php?f=12)
-   -   Dynamic Variable Naming / Variable Variables / Indirect Variable Access (https://forum.sa-mp.com/showthread.php?t=348239)

Redgie 04/06/2012 06:06 PM

Dynamic Variable Naming / Variable Variables / Indirect Variable Access
 
I've been told this is impossible in C so I have very little hope it's possible in P, but what I'm trying to do is use this for a textdraw system, whereby the name the variable containing the textdraw is referenced dynamically, such as:

Storing the Textdraw Variable names
pawn Code:
new Array[1][1] = {
{"ArrayName"}
};

Referencing the Variable Name
pawn Code:
new Text:Array[0][0] = TextDrawCreate(blaa blaa);

Obviously this doesn't work, but any idea on a system that would achieve similar results? What I'm trying to achieve is a none-static system, otherwise applying the textdraw effects has to be done on individual textdraw names which is not an option...

If this isn't a clear enough explanation, it is somewhat achieved with PHP's $$Variable system.

ViniBorn 04/06/2012 06:22 PM

Re: Dynamic Variable Naming / Variable Variables / Indirect Variable Access
 
Is this?
pawn Code:
new Text:TextDrawID[2];

TextDrawID[0] = TextDrawCreate(...);
TextDrawID[1] = TextDrawCreate(...);

MP2 04/06/2012 07:01 PM

Re: Dynamic Variable Naming / Variable Variables / Indirect Variable Access
 
He means using a string as a variable name, I assume. No this isn't possible as far as I know, as variable names are only pre-compile, they 'disappear' (for lack of a better word..) at compile time.

Redgie 04/06/2012 07:32 PM

Re: Dynamic Variable Naming / Variable Variables / Indirect Variable Access
 
Yeah that's what I thought. Only alternative I've been able to come up with so swap the variable names with array indexes, but going to experiment with this tomorrow.


All times are GMT. The time now is 12:59 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.