Home   Help Search Login Register  

Author Topic: Tip of the week.. er month...  (Read 4063 times)

0 Members and 1 Guest are viewing this topic.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Tip of the week.. er month...
« on: 31 Jul 2009, 23:25:45 »
As you can see we haven't been diligent about keeping the tip of the week up to date. So if you have a tip worth sharing please post it here and I will do my best to keep it updated.

Tips should be a small code snippet, try to keep it to 5 or 6 lines of code if possible, and 5 or 6 lines of descrption.

thanks
hoz
Xbox Rocks

Offline Inkompetent

  • Members
  • *
Re: Tip of the week.. er month...
« Reply #1 on: 01 Aug 2009, 00:18:21 »
Tributed to DLBlue on TacticalGamer, since he posted this on their forum:

Quote
Basically a script to just complete a task. Gives the nice little update on the hud and updates it in their map.

Code: [Select]
_task = _this select 0;
_status = _this select 1;

_task setTaskState _status;
null = [objNull, ObjNull, _task, _status] execVM "CA\Modules\MP\data\scriptCommands\taskHint.sqf";

Its called by using:
Code: [Select]
null = [Arg1, Arg2] execVM "taskUpdate.sqf";
Arg1 - The task name to be completed
Arg2 - The state of the task. It can be "SUCCEEDED", "FAILED" or "CANCELED",

Probably too long for Tip of the Week, but the shortest I could come up with on short notice, and really useful :)

Offline sharkattack

  • Former Staff
  • ****
Re: Tip of the week.. er month...
« Reply #2 on: 01 Aug 2009, 00:28:47 »
Im gonna get wrong for this  but   :D

my tip of the month / week

Code: [Select]
--- snip ---
* note  
why isnt scripting as simple as that ?

mmm i cant delete post ...  im gonna get grief  ...  
« Last Edit: 01 Aug 2009, 02:03:04 by Worldeater »
"HOLY SARDINE" - see Shark-Attack meet his match

Offline sardaukar17

  • Members
  • *
Re: Tip of the week.. er month...
« Reply #3 on: 01 Aug 2009, 00:58:58 »
Going more basic.. and I know it is way too long.. But god if I would have discovered this info early on..... so many hours of my life.. *sniff* gone :weeping:.

One of the things that took me a while to wrap my head around and once figured out helped me the most was understanding all the This select 0, this select 1, stuff. All these are are variables in an array that you get to define. For example:
Code: [Select]
_name = _this select 0
_position = _this select 1
_azimut =_this select 2
The array translates to this [name,position,azimut]. You can define whatever you want as the name, position and azimut. Do not be confused by the names I am using. These are not defined by the word they are defined by the script inwhich the above is entered. These are only examples.  These can be defined as anything. For example, lets say I want my tank named 'Tank1' to be moved to the position of a marker I placed on the map named Marker1 and I want the tanks direction(azimut) to be 35. I would enter this into the array like this [tank1,"marker1",35]. Always put "" around marker names. Took me forever to figure that one out.

Now to actually make all that work I need the actual script to define these things. It would look something like this:
Code: [Select]
_name = _this select 0
_position = _this select 1
_azimut = _this select 3

_name setpos (getmarkerpos "_position");
_name setdir _azimut;

exit


Now what this does is allow you to enter any names or numbers you want into your array when executing this script. For example, Lets say I want this to be activated by a trigger. In the Activation field of the trigger I would enter
Code: [Select]
[tank1,"marker1",35] exec "Nameofscript.sqs" 
Now the beaughty of this is that you can activate this same script multiple times for multiple objects by simplying entering in the corrisponding informaiion into the array when executing. You can make tank2 go to maker2 and get set facing an azimut of 125 by entering
[tank2,"marker2",125] exec "nameofscript.sqs" in a new trigger or script or whatever you want to activate it.. Even the same trigger infact... Awsome I know.. Saves hours of tedious mind nummbing scripting. Yay ;)

Offline mikey

  • Former Staff
  • ****
  • Whitespace Whore
Re: Tip of the week.. er month...
« Reply #4 on: 01 Aug 2009, 16:18:58 »
To me the most annoying thing in arma2 as a mission maker is the auto-save in the MP editor, but no more!

Code: [Select]
enableSaving [false, false];

Add this to your init.sqf, and done.

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Tip of the week.. er month...
« Reply #5 on: 07 Aug 2009, 10:03:09 »
If you want turn off the default conversation with NPCs...

Code: [Select]
unit setVariable ["BIS_noCoreConversations", true]

The unit could be the player in most cases.
Fix bayonet!

Offline sardaukar17

  • Members
  • *
Re: Tip of the week.. er month...
« Reply #6 on: 11 Aug 2009, 03:07:31 »
Passing local variables from one script to another through the usual means and through Arrays. Figured this out with help from another string.

Your begining execution line can define A, B, and C as anything you want. like this [Truck,Man,Gamelogic] exec "YourScript.sqs". In the script these variables are pulled out through the _this select 0,1,2 lines

Code: [Select]

_Truck= _this select 0
_Man= _this select 1
_Gamelogic= _this select 2

;Add your script content here.

[_Truck,_Man,_Gamelogic] exec "Yourscript.sqs"
You will need to pull out Truck,Man, and Gamelogic in the new script similar to how it was here. 
That is the usual way. But say you have a list of things. Or you have a command that only allows 1 variable to be passed such as AddAction. You can pass it in an array as follows:
Code: [Select]
_A= _this select 0
_B=_this select 1
_C=_this select 2
_D=_this select3
_array=[_A,_B,_C,_D]

So now you have one local variable named _array that carries all the other variables. Use this array to execute your next script as follows [_array] exec "Yourscript.sqs"
To pull your variables back out of the array you'll need to work it slightly different
Code: [Select]
_array = _this select 0
_A=_array select 0
_B=_array select 1
_C=_array select 2
_D=_array select 3

Notice that the A-D variables are pulled from _Array instead of _This. That should do it. All you would need to do now is enter in your script data reusing your old variables.

Offline nominesine

  • Former Staff
  • ****
  • I'm NOT back!
    • The IKB Forum
Re: Tip of the week.. er month...
« Reply #7 on: 11 Aug 2009, 08:35:29 »
Place a Secondary Operations Manager [F7] in the editor, name it mySom and synchronize it with a playable unit and execute the following code in a trigger:

["ambush", true, mySom] call BIS_SOM_requestSecOpFunc;

You now how a simple randomized mission. You can replace "ambush" with any of the following variants:

"attack_location"
"trap"
"rescue"
"defend_location"
"search"
"escort"
OFPEC | Intel Depot
RETARDED Ooops... Retired!

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Tip of the week.. er month...
« Reply #8 on: 24 Aug 2009, 08:25:19 »
If you create a Single Mission and you want to check up (green dot) the mission in the ArmA 2 GUI, if player finished the mission do this:

in the description.ext:
Code: [Select]
doneKeys[]={"mission_name_or_id"};
And in the mission put this line into the END trigger:
Code: [Select]
activatekey "mission_name_or_id"
Fix bayonet!

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re: Tip of the week.. er month...
« Reply #9 on: 24 Aug 2009, 10:41:01 »
to get the briefing to work in a deathmatch, put this code in your init.sqf.  Since everyone is side enemy the briefing.sqf has an issue showing the briefing
Code: [Select]
_diary = player createDiaryRecord["Diary", ["Friendly forces", "<br/>There are no friendlies here, kill or be killed."]];

Offline mikey

  • Former Staff
  • ****
  • Whitespace Whore
Re: Tip of the week.. er month...
« Reply #10 on: 27 Aug 2009, 13:23:19 »
To find out who is crew and who is cargo, even in multi-turreted vehicles (like bmp-3, t-34, etc):

Code: [Select]
_crew = [];
_cargo = [];
{
if ( ((assignedVehicleRole _x) select 0) == "Cargo" ) then
{
_cargo = _cargo + [_x];
} else
{
_crew = _crew + [_x];
};
} forEach (crew _vehToCheck);
« Last Edit: 28 Aug 2009, 02:34:10 by mikey »

Offline Zipper5

  • BIS Team
  • ****
Re: Tip of the week.. er month...
« Reply #11 on: 02 Sep 2009, 16:20:36 »
My tip would be to use the -showScriptErrors command in your ArmA II shortcuts if you are mission making. I have played many a custom mission for ArmA II that has many errors popping up when this is enabled.

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Tip of the week.. er month...
« Reply #12 on: 05 Sep 2009, 00:54:40 »
Frankly, I'd rather keep preaching to constantly monitor the RPT for errors during development: run A2 in window mode and use a decent text editor/log viewer to track RPT changes.
try { return true; } finally { return false; }

Offline sardaukar17

  • Members
  • *
Re: Tip of the week.. er month...
« Reply #13 on: 05 Sep 2009, 05:38:28 »
Forcing a unit Maximum for your map:
Code: [Select]
_Unitmax= count allunits
?(_unitmax >=300):goto "exit"
Put that at the begining of any unit creation commands. Keeps servers from crashing.
The 300 could be any number you feel comfortable with. 300 is probly too high

Offline bardosy

  • Honoured Contributor
  • ***
  • campaign designer
    • CartooDiv
Re: Tip of the week.. er month...
« Reply #14 on: 07 Sep 2009, 07:21:13 »
If you use multiple playable characters (so player can switch characters during the game), don't add task to player, because player is always different! Named the main character (e.g.: p) and add the task to him.
Fix bayonet!

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Tip of the week.. er month...
« Reply #15 on: 12 Oct 2009, 23:06:58 »
Thanks so far for all the suggestions. As you can see I've been choosing the smaller tips but since Bedges updated the ED page I can go with a bit bigger tip.  We'll try to incorporate the best ones so keep them coming.
Xbox Rocks