Jump to content
Sign in to follow this  
Deadfast

Execute a script on a client's machine

Recommended Posts

Hello again!

I'm having a little problem with a script I'm working on.

Basically it allows one person to kick out another person from its vehicle.

Everything is working as it should, except for the part when I need a camera screen to be executed for the guy that gets kicked out.

So a quick recap would be:

A script on PC #1 executes a script on PC #2.

Thanks a bunch!

Deadfast

Share this post


Link to post
Share on other sites

One solution is to define a publicVariableEventhandler on all client machines (in the mission init.sqs for example)

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

"DF_kickedout_crew" addPublicVariableEventhandler {

               if(player in (_this select 1)) then {

                            // execute your script for the camera screen here

               };

};

To the script that ejects the units, add something like this right after the command that ejects the unit/s.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">DF_kickedout_crew = (crew vehicle player) - [player];   // or some other array of units in the vehicle

publicVariable "DF_kickedout_crew";

Maybe it's better not to run the "eject command" on a remote machine (PC #1) but on the machine where the ejected unit is local to (PC #2). Might behave better in case there's some lag. And this solution requires at least ArmA v1.09b, as earlier versions don't support broadcasting arrays.

Share this post


Link to post
Share on other sites

It doesn't work sad_o.gif

part of the script itself:

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

hint "Executing";

pulledout = (_crew select 0);

publicVariable "pulledout";

init.sqf

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

pulledout = [];

"pulledout" addPublicVariableEventhandler {

             

if (player in (_this select 1)) then

               {

                       hint "Executed on victim's PC";

                       player action ["eject", vehicle player];

               };

};

Apparently the script never gets to be executed on the victim's PC (the hint doesn't show up).

Share this post


Link to post
Share on other sites

Of course it won't work the way you wrote it.

Quote[/b] ]pulledout = (_crew select 0);

Now pulledout is type OBJECT, but the pVEventhandler is expecting an ARRAY (checking with the command 'in' ).

When sending over a certain crew member, check with this line:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (player == (_this select 1)) then {

or convert the variable pulledout from OBJECT to ARRAY, and leave the check with 'in'

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">pulledout = [(_crew select 0)];

For testing if you received something at all, move the hint message out side of the if-check, because when the condition is false you won't see anything and don't know whether you received something or not.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">hint format["Executed on victim's PC - Var-Name: %1 - Var-Value: %2", (_this select 0), (_this select 1)];

Displays what pc#2 received. (for debugging)

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  

×