String to variable - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: String to variable (
/showthread.php?tid=289255)
String to variable -
whitedragon - 10.10.2011
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]
Re: String to variable -
FireCat - 10.10.2011
Can you explain a bit better please?
Re: String to variable -
Kush - 10.10.2011
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);
Re: String to variable -
grand.Theft.Otto - 10.10.2011
Ah, something like this for example ? :
pawn Код:
format(str,sizeof(str),"Grams Of Drugs Left: %d",PlayerInfo[playerid][Grams]);
Re: String to variable -
whitedragon - 10.10.2011
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
Re: String to variable -
Vince - 10.10.2011
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 */