Jump to content
Sign in to follow this  
Tand3rsson

error missing {

Recommended Posts

HI!

Using an eventhandler killed for this one.

_unit = _this select 0;
_killer = _this select 1;

if (!isServer) exitWith {};

if ((side _killer == EAST) and (side _unit == INDEPENDENT)) then 
{
hint "HAHA";
};

but I get "error missing {" when it fires? Anybody know why?

Share this post


Link to post
Share on other sites

I see nothing wrong in it, it may be from the addEventHandler it's self, mind posting that and perhaps an actual error report from the RPT? Otherwise not much help can be given.

Share this post


Link to post
Share on other sites
HI!

Using an eventhandler killed for this one.

_unit = _this select 0;
_killer = _this select 1;

if (!isServer) exitWith {};

if ((side _killer == EAST) and (side _unit == INDEPENDENT)) then 
{
hint "HAHA";
};

but I get "error missing {" when it fires? Anybody know why?

What does the error message say in full?

Off the top of my head and without access to the game, I don't think the engine understands

if (!isServer) exitWith {};

Which might need to be

if (!isServer) then {exitWith {}};

But exitWith might then only exit the if scope.

So you might need to refactor it to

_unit = _this select 0;
_killer = _this select 1;

if (isServer) then {

   if ((side _killer == EAST) and (side _unit == INDEPENDENT)) then {
       hint "HAHA";
   };
};

Share this post


Link to post
Share on other sites

Hi again! I tried removing the isServer check alltogether to see if that is whats wrong. Then the script looks like:

_unit = _this select 0;
_killer = _this select 1;

if ((side _killer == EAST) and (side _unit == INDEPENDENT)) then 
{
hint "HAHA";
};

and I use the following in the targets init line:

 this addEventHandler ["killed", {_this exec "killed.sqf"}];

and the error looks exactly like this:

 '|#|};' error missing {

the hint "HAHA" fires without problem though.

---------- Post added at 04:13 PM ---------- Previous post was at 04:12 PM ----------

I see nothing wrong in it, it may be from the addEventHandler it's self, mind posting that and perhaps an actual error report from the RPT? Otherwise not much help can be given.

Please explain how I access the actual error report from "RPT" and post it :P?

Share this post


Link to post
Share on other sites
Hi again! I tried removing the isServer check alltogether to see if that is whats wrong. Then the script looks like:

_unit = _this select 0;
_killer = _this select 1;

if ((side _killer == EAST) and (side _unit == INDEPENDENT)) then 
{
hint "HAHA";
};

and I use the following in the targets init line:

 this addEventHandler ["killed", {_this exec "killed.sqf"}];

and the error looks exactly like this:

 '|#|};' error missing {

the hint "HAHA" fires without problem though.

---------- Post added at 04:13 PM ---------- Previous post was at 04:12 PM ----------

Please explain how I access the actual error report from "RPT" and post it :P?

Ah, spotted it. Your eventhandler you are using exec, you need to use execVM. exec was used for .sqs and is now old and deprecated.

But to get to your RPT log you can open up your Documents and in the windows navbar where it says Documents replace it with: %LOCALAPPDATA%\Arma 3 and press enter. It should take you right to it and you are looking at the most recent RPT. If it doesn't work then you'll probably need to enable the viewing of hidden files & folders (that can be googled).

Also you can leave your check in for the if(!isServer) exitWith {}; because that code was just fine. The engine DOES understand exitWith {} otherwise why would it be listed? :P

Share this post


Link to post
Share on other sites

QUOTE=Tonic-_-;2461654]Ah, spotted it. Your eventhandler you are using exec, you need to use execVM. exec was used for .sqs and is now old and deprecated.

But to get to your RPT log you can open up your Documents and in the windows navbar where it says Documents replace it with: %LOCALAPPDATA%\Arma 3 and press enter. It should take you right to it and you are looking at the most recent RPT. If it doesn't work then you'll probably need to enable the viewing of hidden files & folders (that can be googled).

Also you can leave your check in for the if(!isServer) exitWith {}; because that code was just fine. The engine DOES understand exitWith {} otherwise why would it be listed? :P

Good spot! However, I am surprised to find that with

 this addEventHandler ["killed", {_this execVm "killed.sqf"}];

it dosen't fire the scrip so I get the hint at all?! Da f***? :S

Share this post


Link to post
Share on other sites

Make it a function instead of execVM'ing a script every time since you're obviously gonna be running this often.

Share this post


Link to post
Share on other sites
Make it a function instead of execVM'ing a script every time since you're obviously gonna be running this often.

Thanks kylania, however, it is not going to run that much.

It is a limitied of 10 INDEPENDENT, and if opfor kills anyone of them I am going to use setFriend (yes, "HAHA" will be replaced") to get them hostile towards OPFOR. So it is just running for 10 souls.

And I haven't got any idea at all how functions work :)

Share this post


Link to post
Share on other sites

Also if you call it instead of spawn/execVM, you guarantee it'll finish running before more things in the game might happen, as event handlers are non-interruptible, but scripts/functions running with execVM/spawn are interruptible regardless of who execVMed/spawned them.

Just use:

fnc_killed = compile preprocessFileLineNumbers "killed.sqf";
...
this addEventHandler ["killed", {_this call fnc_killed}];

Share this post


Link to post
Share on other sites
Also if you call it instead of spawn/execVM, you guarantee it'll finish running before more things in the game might happen, as event handlers are non-interruptible, but scripts/functions running with execVM/spawn are interruptible regardless of who execVMed/spawned them.

You're going to have to explain that one to me mate :)

tried adding

fnc_killed = compile preprocessFileLineNumbers "killed.sqf";

to my init.sqf and then in the init of the target Soldier:

this addEventHandler ["killed", {_this call fnc_killed}];

with no luck :(

Edited by Tand3rsson

Share this post


Link to post
Share on other sites

Which might need to be

if (!isServer) then {exitWith {}};

[/php]

It's either then or exitWith, not both

Share this post


Link to post
Share on other sites

Cuel is right about the exitwith. Furthermore although it can exit the script it appears exitwith was only designed to exit the scope. What does ur current script entail. If u r running this for the server then u will not get hint as it is hinting only on server.

Removing if isserver will hint as its hinting for the client. but tonic is right the code inside the script looks sound. Re paste ur current script

Share this post


Link to post
Share on other sites

Killed.sqf

_unit = _this select 0;
_killer = _this select 1;

if (!isServer) exitWith {};

if ((side _killer == EAST) and (side _unit == INDEPENDENT)) then
{
hint "HAHA";
};

init.sqf

fnc_killed = compile preprocessFileLineNumbers "killed.sqf";

init of targetunit

 this addEventHandler ["killed", {_this call fnc_killed}]

Share this post


Link to post
Share on other sites
It's either then or exitWith, not both

Yep, I assumed, without looking at documentation that exitWith was simply "break" equivalent in SQF that wouldn't replace "then", but it actually works this way. My bad.

Share this post


Link to post
Share on other sites

looking at it - its possible that at the point of death your player is no longer assigned to INDEPENDENT - hes a CIV. The faction seems to stay the same but side changes depending on whether you are alive or not. Try hinting to find out what side is showing...

players init - this addEventHandler ["killed", {_this call fnc_killed}];

_unit = _this select 0;

_killer = _this select 1;

if (side _killer == EAST) then

{

hint format ["Faction player: %1, Side: %2", (faction _unit), (side _unit)];

};

Share this post


Link to post
Share on other sites

Is the unit you are killing local to the server? Event handler "killed", as far as I know, only runs on the machine where the killed unit is local. This means if you kill your friend, he will execute the event handler, and then exit because he is not the server. The server (or you, if you are the host and thus the server) will do nothing, as the event handler is never executed. When you are killed and are the host, though, you should see the hint if the sides are correct. If the sides are incorrect, though (for example if your side changed to CIV when you died), then you will still not see the hint.

Best solution is to have each player broadcast to the server when he dies via a killed event handler (can use publicVariableServer to save on network traffic, though usually I end up broadcasting kills to all clients in order to make other scripts work such as TK notifications), and then the server deals with it.

Share this post


Link to post
Share on other sites

i have the same problem with a similar script... when i Launch the script, the game returme the same error MISING {... my script its simple

-----------------------------------------

sleep 3;

while {alive player} do

{

if (!alive buzo2) then {

hint "El buzo2 No esta vivo";

};

if (!alive buzo3) then {

hint "El el buzo3 No esta vivo";

};

};

sleep 3;

--------------------------------------------

i launch the script in the OnAct of a trigger... with this line: [] exec"comunicacion.sqf" i can´t put in the OnAct fielt execvm "comunicacion.sqf"... and when i put a sleep code... Returnme a error... :S

Sorry For my English and i agree some Help :(

Share this post


Link to post
Share on other sites

0 = [] exec[b]VM[/b] "comunicacion.sqf";

exec is for .sqs files, you're coding in .SQF which means you need to use execVM

and anything you run with execVM from a trigger needs a script handle, in this case 0 =

You should also move the sleep 3; above the last }; to lighten up the loop.

Edited by cuel

Share this post


Link to post
Share on other sites
0 = [] exec[b]VM[/b] "comunicacion.sqf";

exec is for .sqs files, you're coding in .SQF which means you need to use execVM

and anything you run with execVM from a trigger needs a script handle, in this case 0 =

You should also move the sleep 3; above the last }; to lighten up the loop.

Perfect!! I spent two hours trying to fix the script.... without thinking that the ruling was the handler, thank you so much Cuel!!!

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  

×