String to variable
#1

Hello i just wondering how to make
new string[64];
format(str,sizeof(str),"Variable1");
to variable
formated str will be variable that then i call
Info[str] it give there Variable1.
Like it search for Info[Variable1] not Info[str]
Reply
#2

Can you explain a bit better please?
Reply
#3

Quote:
Originally Posted by FireCat
Посмотреть сообщение
Can you explain a bit better please?
I'm assuming he's wanting to call string in different areas within his code.

PHP код:
    new string[5+1] = "Debug";
    print(string); 
Reply
#4

Ah, something like this for example ? :
pawn Код:
format(str,sizeof(str),"Grams Of Drugs Left:  %d",PlayerInfo[playerid][Grams]);
Reply
#5

I mean:
pawn Код:
new str[64];
enum stuff{
   Variable1,
   Variable2
}
new Info[stuff];

// some public
switch(x)
{
   case 1: format(str,sizeof(str),"Variable1");
   case 2: format(str,sizeof(str),"Variable2");
}
Info[str] // he should look Variable1 but str
Reply
#6

If I understand correctly, then what you're trying to do is not possible. At least not in this way. Something like this should work though:
pawn Код:
new idx;
switch(x)
{
   case 1: idx = stuff:Variable1;
   case 2: idx = stuff:Variable2;
}
Info[idx] = /* your stuff */
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)