SolvedArma 3 scripting

Posts 1–5 of 5 · Page 1 of 1
Arma 3 scripting
This is fairly simple but, what's the difference between _player and player or _relPos and relPos ect... because the one with the underscore lights up blue and the other one doesn't. From my knowledge of programming the player is a variable which you have to assign a value to but i don't know what _player is, is it a keyword that is used to represent the character which is controlled by a real person or 'player'?

Btw, I'm using notepad++ with a sqf language plugin.

Thanks.
variablename is global
_variablename is local.

heres an example, we will start on _variablename first, since _variablename is a local variable it can only be accessed by the script/.sqf file that it is in, lets say you have 2 .sqf files, one with a addaction to display a hint / message, and the other to write the message.

addmessage.sqf
Code:
_message = 4;

start = {
player addAction ["display variable value", displayv];
};

displayv = {
execVM "displaymessage.sqf";
};
displaymessage.sqf
Code:
 
hint format [" the value of the message variable is %1", _message];
see this wont work, inside of the displaymessage.sqf, it doesn't know what _message is, that is because it is local, only the file called addmessage.sqf knows what it is since the local variable was defined inside of that file. now if you were to replace that with this

addmessage.sqf
Code:
message = 4;

start = {
player addAction ["display variable value", displayv];
};

displayv = {
execVM "displaymessage.sqf";
};
displaymessage.sqf
Code:
 
hint format [" the value of the message variable is %1", _message];
as you can see i changed the variable _message to message, message is now global so displaymessage.sqf and all other files know what the variable message is and it can be accessed from any file that you want since it is global.

also player is yourself, for instance if your making a scroll menu(to cheat im assuming) you would use player as it would be for you and only you such as player addAction(as shown above).

now if you were making a mission for many people to play and you used player( we will use the init.sqf for example since that file of the mission is ran on everybody's computer), then it would show for everybody since everybodys computer is running the mission.
Wow, thanks for the detailed explanation
Quote Originally Posted by Thetox View Post
Wow, thanks for the detailed explanation
no problem, i typed it off the top of my head real quick so some stuff might not be 100% correct. do you already have a executor that you use or are you learning to script in singleplayer/making missions?
Posts 1–5 of 5 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us