Jump to content
Sign in to follow this  
DecimusAquila

Some questions on syntax

Recommended Posts

I have read what it is about on the questions I ask but yet I find it difficult to fully understand their uses. In wiki, It explains them with examples but I noticed these syntax can be used on other occations as seen in other missions.

I have only started playing ARMA a month now and learning fast. I hope to be great at scripting in some months to come, but now I need all the help I can get from the veterans of ARMA/OFP.

<span style='color:blue'>1. what really is an Event handler? (this syntax is used quite alot esspecially with scripts). Wiki explains this but in terms to those who already have an idea of scripting. I know that there are certain commands used only with event handlers like fire and so on stated in wiki. One code I saw was;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired",{if (_this select 2 == "ak74" && !myvar_akFired) then {myvar_akFired=true; _this exec "echo.sqs"}}];

This code got me crazy thinking forcing me to have a 100gram vodka even after reading the sqs file. huh.gif</span>

<span style='color:red'>2. Some missions or objectives end with this code;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">"0"objstatus"DONE";one=true;publicVariable"one" via trigger

Now what bugs me is the publicVariable"one". Now "one" a text word written on the trigger and NOT the name of the trigger.

I have also seen another code with this same syntax but used in a different manner;

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

Can someone explain this syntax "publicVariable" clearer and its uses?</span>

<span style='color:green'>3. My last question; when you make a trigger, "TYPE" box were we have end1,end2,end3,...we also have switch.

Well, due to the name it is understandable but

Is switch made for...

[if ""condition"" is triggered then switch ""activate"" to trigger?]</span>

These questions may be noodish but what can I say, I am not clear with them.

Share this post


Link to post
Share on other sites
Quote[/b] ]<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired",{if (_this select 2 == "ak74" && !myvar_akFired) then {myvar_akFired=true; _this exec "echo.sqs"}}];

With eventhandler you attach a piece of code to a specific object that will be run when the specified event happens.

The example code adds "fired" event to the unit, so the code is run every time that unit fires his weapon. In the code part it first checks if the fired weapon is AK74 and the code isnt executed before. myvar_akFired is used to make the script ran only once.

Quote[/b] ]

Can someone explain this syntax "publicVariable" clearer and its uses?

Lets use your example. "one" is a variable that is used to hold the information about the status of the first objective. If its completed its true, otherwise false.

publicvariable comes into play when you need to tell other client (players) that you just completed the first objective. The publicvariable command is used to broadcast a variable to everyone, because variables are local by default and they aren't automatically synced.

Someone smarter can comment on the switch, I only know you can use it to break patrols (move <-> cycle waypoints), so that it goes straight to the waypoint after cycle when the trigger is activated. smile_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">this addEventHandler ["fired",{if (_this select 2 == "ak74" && !myvar_akFired) then {myvar_akFired=true; _this exec "echo.sqs"}}];

With eventhandler you attach a piece of code to a specific object that will be run when the specified event happens.

The example code adds "fired" event to the unit, so the code is run every time that unit fires his weapon. In the code part it first checks if the fired weapon is AK74 and the code isnt executed before. myvar_akFired is used to make the script ran only once.

Quote[/b] ]

Can someone explain this syntax "publicVariable" clearer and its uses?

Lets use your example. "one" is a variable that is used to hold the information about the status of the first objective. If its completed its true, otherwise false.

publicvariable comes into play when you need to tell other client (players) that you just completed the first objective. The publicvariable command is used to broadcast a variable to everyone, because variables are local by default and they aren't automatically synced.

Someone smarter can comment on the switch, I only know you can use it to break patrols (move <-> cycle waypoints), so that it goes straight to the waypoint after cycle when the trigger is activated. smile_o.gif

Thankyou Shuko,

I do now catch the drift of event handlers and glad that you explained this to me.

The same goes with "publicVariable". I am begining to have an idea on what it is used for after your answer.

Thanks once again Shuko.

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  

×