Jump to content
Sign in to follow this  
celery

Global and private commands

Recommended Posts

Is there a help section anywhere that explains how to make certain things global and some private?

I have difficulty grasping the exec command and how the different brackets affect it. What's the difference between [], [dude], (dude) or just dude exec "script.sqs"? Which script commands are global category and which ones are not?

Share this post


Link to post
Share on other sites

Follow the wiki tutorials for awhile and then ask around at OFPEC. Additionally, you can open other's work and see what they've done.

It is a skill which is not as complicated as it looks, but takes a long time to master.

Since I don't believe in just pointing and leaving, I will try and answer your question:

the command EXEC takes two parameters:

param1 EXEC param2

param1 must be an array (i.e. ["somevalue","anotherValue"] )

param2 must be a string (filename to be exact)

the reason you might see :

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

myVar exec "script.sqs"

is only because the myVar is probably an array to begin with..

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

myVar = ["someValue",player, 10]

myVar exec "script.sqs"

Brackets ALWAYS denotes an array. It is basically a collection of several other values/variables between brackets and seperated by commas.

Paranthesis is like paranthesis in math. It simply defines calculations to be performed before another:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

15 / ( 5 + 10)   = 1

15 / 5 + 10 = 13

Anything in curly braces { } is usually a code block (and most likely in SQF format).

In regards to global/private, this can mean many things, but usually private variables begin with an underscore (e.g. _myVar) and usually means that the value in this variable is not available by any other script. Any variable without an underscore is global and thus you can retrieve the value at any time by any script.

Share this post


Link to post
Share on other sites

Well thanks, but I'm kind of past the tutorial stage and the biki isn't the best place for specific information. I'm just wondering how globalisation or getting rid of it works.

The stuff I asked about [], [dude], (dude) and dude exec "script.sqs" was because I've noticed they have different effects on how the script works and I want to know the exact differences.

For example, (playerdude) exec "camera.sqs" creates a camera at point 000 while playerdude exec "camera.sqs" creates it where the guy is.

Share this post


Link to post
Share on other sites

The main thing is that sometimes I want a script to affect everyone in play and other times I want to limit the effect to one unit, be it the activator of the script or someone else.

Normally player means every player controlled unit, but in a trigger combined with an init of ?alive player, the activation loses its global status and only the player who just turned alive is affected. I want to dig into the logic of that kind of stuff.

Share this post


Link to post
Share on other sites

Welcome in multiplayer scripting xmas_o.gif

See Biki MP locality entry for a very brief start.

Much of the work on the subject for me is mainly trial and error. Some people know the various command locality status but the info is very rarely written anywhere so digging it out is rather tough

Share this post


Link to post
Share on other sites

Disclaimer: my information is based on how OFP:R 1.96 works. I have no reason to assume this would not be true in ArmA also.

the command EXEC takes two parameters:

param1 EXEC param2

param1 must be an array (i.e. ["somevalue","anotherValue"] )

Mate, are you sure about that? In OFP it isn't like so. Param1 doesn't have to be an array.

player exec "script.sqs"

script.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint format ["%1",getPos _this]

would show as hint the position of the player, right? No arrays passed to the script.

I recommend not passing an array for your scripts when you only have one argument, as there is no point in doing so (other than if you absolutely want to add an unnecessary command and use select to pick that one argument out of the array).

Oh, and about the player command: it is local to the computer where it is used, as such its value is different on every computer in the session. This means, if you host a session, if you run the player command on your computer, there is only one player character and that is your own character. Other player computers in the session have the player pointing to, well you can guess it now already. This information is, as stated above, for OFP and I can't say what happens with the character switching stuff present in ArmA. But it sounds logical to me that at any one time there can only be one player, you, in your computer, even if there is a character switching system in place.

Regards,

Baddo.

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  

×