SA-MP Forums Archive
Getting any variable value with a command - 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: Getting any variable value with a command (/showthread.php?tid=347251)



Getting any variable value with a command - serj009 - 01.06.2012

So basically, is it possible for the format to return the proper variable value in the following code? For example, If I have a variable in the server called IsCool[playerid]. I will type "/checkv IsCool" and it will return me what my current value for "IsCool[playerid]" is, and it will work with any variable that exists in the script, please let me know if this is possible and if so, elaborate. Thanks alot!

Код:
	format(string1,sizeof(string1),"%s[playerid]",params); // what i typed in the command "/checkv [variable]"
	format(string2,sizeof(string2),"%d",string1); //Trying to retrieve the value from the "[variable]"
	format(string3,sizeof(string3),"%s == %d",string1,string2); //Trying to return it to me "[variable] == [value]"



Re: Getting any variable value with a command - iJumbo - 01.06.2012

never tryed ...no i think this will only print..


Re: Getting any variable value with a command - serj009 - 01.06.2012

Well obviously this is not the entire command, all the rest is irrelevent


Re: Getting any variable value with a command - iJumbo - 01.06.2012

yes but you have to compile it to work .. so you cant "print" the script

you can try this http://forum.sa-mp.com/showthread.ph...highlight=Exec can help ..


Re: Getting any variable value with a command - serj009 - 01.06.2012

Ok you are misunderstanding this entire question


Re: Getting any variable value with a command - MadeMan - 01.06.2012

No, not possible. There might be a way (#emit), but it requires a lot of knowledge about PAWN and AMX.


Re: Getting any variable value with a command - Vince - 01.06.2012

I don't think it's possible, even through the use of emit. Variable and functions names are merely stored as addresses in memory and cannot be accessed by name. The exceptions being public functions and variables.

Variables can be declared public as well, but I'm not sure how that would work out as it's never been used before.


Re: Getting any variable value with a command - MadeMan - 01.06.2012

Quote:
Originally Posted by Vince
Посмотреть сообщение
I don't think it's possible, even through the use of emit. Variable and functions names are merely stored as addresses in memory and cannot be accessed by name. The exceptions being public functions and variables.

Variables can be declared public as well, but I'm not sure how that would work out as it's never been used before.
Yes, but I was thinking maybe it's possible to make a table where all names and addresses of variables are saved, so it's possible to look up variable addresses by name and show the values. Just a thought, I'm not very familiar with #emit.

EDIT: And if not with #emit, maybe a plugin?


Re: Getting any variable value with a command - milanosie - 01.06.2012

Hmm, Sounds like impossible if Pawn works the same way as C+ with this.