SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/06/2012, 06:06 PM   #1
Redgie
Huge Clucker
 
Join Date: Aug 2007
Posts: 206
Reputation: 13
Default 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.
Redgie is offline   Reply With Quote
Old 04/06/2012, 06:22 PM   #2
ViniBorn
Godfather
 
ViniBorn's Avatar
 
Join Date: Aug 2010
Location: Brasília
Posts: 5,314
Reputation: 720
Default Re: Dynamic Variable Naming / Variable Variables / Indirect Variable Access

Is this?
pawn Code:
new Text:TextDrawID[2];

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



CONTATO: F A C E B O O K: @vinibornpawn

ViniBorn is offline   Reply With Quote
Old 04/06/2012, 07:01 PM   #3
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,237
Reputation: 1004
Default 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.
__________________
Owner and developer of Mike's Cops and Robbers.

Click here to visit our site and find out more. Click here to view trailers.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Old 04/06/2012, 07:32 PM   #4
Redgie
Huge Clucker
 
Join Date: Aug 2007
Posts: 206
Reputation: 13
Default 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.
Redgie is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Compile error(warning 219: local variable "string" shadows a variable at a preceding level) calin1996 Scripting Help 6 25/04/2012 03:13 PM
warning 219: local variable "PlayerName" shadows a variable at a preceding level captainjohn Scripting Help 2 13/04/2012 07:44 PM
How do I access a variable in another running script? biltong Help Archive 1 07/04/2010 10:36 PM
TextDraws as server variable?? How to i change to Player Variable? DarrenReeder Help Archive 2 06/04/2010 07:02 AM


All times are GMT. The time now is 09:04 AM.


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