Jump to content
Sign in to follow this  
blackgrain

Doubt aabout publicVariable...

Recommended Posts

Hello!!

I have a doubt about publicVariable command... well.. the real doubt not is about publicVariable ... is about his use.

Well.. i go try explain myself... sorry for my bad english! confused_o.gif

If I use a "global variable" (for example _variable_in_server) but I only need this variable (_variable_in_server) to read/modify in scripts running on server machine... really need call to:

publicVariable "_variable_in_server";

...any time I modify his value?

If really.. the value of _variable_in_server ONLY is needed in scripts running on server machine... I don´t need to public his value around the net... I'm right???.. or always I must to public tihs value with publicVarible despite use the value ONLY in the server machine... huh.gif

Thank!! wink_o.gif

Share this post


Link to post
Share on other sites

You are right, you have no reason to publicVariable something if it is only ever needed on the one machine.

You will need to make sure that the scripts/functions which are only needed to run on server, are only run on server. Use isServer command.

From thereon you make sure that the global variables which are used only by the scripts/functions run on the server are only present at the server.

We can even see a programming security concept here: if you keep as much in the hands of the server as possible, in local variables, then you are potentially fighting off people who try to cheat. I'm saying local because public data is more exposed and more easily changed by definition.

So, to add further, my advice would be to minimize the number of global variables. It should be obvious, but I think it is often neglected.

Share this post


Link to post
Share on other sites

Thanks Baddo!!!

The security is one reason... and another important one is reduce traffic over net smile_o.gif

Thanks!! wink_o.gif

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×