Jump to content
Sign in to follow this  
J. Schmidt

Remote Control Script

Recommended Posts

I've been working on this script for a couple of days now, and have read about everything that I'm able to find for the remoteControl script. After searching I have found very little on someone successfully creating a Remote Control script using the remoteControl found in the wiki.

I'm having an issue where if you don't switch back to the commander positions before you leave, when you re-enter you'll be able to switch positions anymore. Does anyone know of a script or where to find a script that'll automatically switch the players position to commander and then exit? What needs to be added and, or fixed so that this will be successful?

(I've moved this part of the creation from my MULE to here because this problem is strictly related to scripting in-game, so it belongs here and not in Model and Config editing. So I'll no longer talk about the remoteControl script in my other thread, and will continue to talk about Model and Config editing in the other thread.)

Here are the Scripts:

RemoteControl.sqf

private ["_controller","_cmdr","_driver","_gun"];
_controller = UGV_Operator;
_cmdr = Commander UGV;
_driver = Driver UGV;
_gun = Gunner UGV;

_controller remoteControl _cmdr;
_cmdr switchCamera "Gunner";
_cmdr action ["moveInDriver", UGV];

//Make AI Controllable

[_cmdr] join grpNull;
selectPlayer _driver;
selectPlayer _gun;
selectPlayer _cmdr;

EndRemoteControl.sqf

private ["_controller","_cmdr","_driver","_gun"];
_controller = UGV_Operator;
_cmdr = Commander UGV;
_driver = Driver UGV;
_gun = Gunner UGV;

objNull remoteControl _cmdr;
objNull remoteControl _driver;
objNull remoteControl _gun;
_controller switchCamera "External";
selectPlayer _controller;	
[_cmdr] join grpNull;

(I had to put three objNulls so no matter what position that the player exits, they'll have control of there original character.) Any help will be appreciated.

---------- Post added at 08:40 PM ---------- Previous post was at 08:39 PM ----------

I've figured out a way in which will allow the player to re-enter the Remote Control mode and be able to switch to different positions. Before the player exits the Remote Control mode, they need to switch back to the commander position then exit. Knowing this is there something that I can add to the EndRemoteControl.sqf that before exiting the Remote Control mode, the player is automatically switched back to the commander position then finally exits? Please help, thanks.

Edited by JSF 82nd Reaper

Share this post


Link to post
Share on other sites

To Move them to the commander try moveInCommander or assignAsCommander and I think this will work for making them get out.

_controller action ["eject", _veh];

With _veh being the variable name of the vehicle. Which you may want to define in your script aswell.

Share this post


Link to post
Share on other sites

@Matt15 Correct if me if I'm wrong but what you've posted would work if the _controller actually entered the vehicle? But with what I've done the _controller doesn't ever move into the vehicle, he stays outside of it where ever he's at. But the beauty behind this script, is that I'm actually using the remoteControl command found here: http://community.bistudio.com/wiki/remoteControl but turned it into a more advanced remoteControl script that has countered the annoying camera defects that are used in this command. (As shown in the link "jeep1 switchCamera "internal";").

To further more my explanation, I need to figure out a way in which whatever position that the player is controlling; when they exit the Remote Control, the AI in which they're controlling (unless they're controlling the commander position) switches to the commanders seat allowing the EndRemoteControl.sqf script to finally finish its execution and giving the player their original character.

---------- Post added at 03:15 PM ---------- Previous post was at 02:48 PM ----------

I've changed up the RemoteControl.sqf script since there were some things that weren't needed, and some things to try. But I'm still having the same issue as was stated in the first post.

RemoteControl.sqf

private ["_controller","_cmdr","_driver","_gun"];
_controller = UGV_Operator;
_cmdr = Commander UGV;
_driver = Driver UGV;
_gun = Gunner UGV;

   _controller remoteControl _cmdr;
   _cmdr switchCamera "Internal";

//Make AI Controllable

[_cmdr] join grpNull;
selectPlayer _cmdr;
   setPlayable _driver;
   setPlayable _gun;

Edited by JSF 82nd Reaper

Share this post


Link to post
Share on other sites

Great News I fixed the problem, but what can I use that'll make the AI not eject out of the vehicle and then enter it again?

RemoteControl.sqf

private ["_controller","_cmdr","_driver","_gun"];
_controller = UGV_Operator;
_cmdr = Commander UGV;
_driver = Driver UGV;
_gun = Gunner UGV;

   _controller remoteControl _cmdr;
   _cmdr switchCamera "Internal";

//Make AI Controllable

[_cmdr] join grpNull;
selectPlayer _cmdr;	
setPlayable _driver;
setPlayable _gun;

EndRemoteControl.sqf

private ["_controller","_cmdr","_driver","_gun","_cmdrpos"];
_controller = UGV_Operator;
_cmdr = Commander UGV;
_driver = Driver UGV;
_gun = Gunner UGV;
_cmdrpos = getPos Commander UGV;

_driver setPos _cmdrpos;
_gun setPos _cmdrpos;

objNull remoteControl _cmdr;
objNull remoteControl _driver;
objNull remoteControl _gun;

_controller switchCamera "External";
selectPlayer _controller;	
[_cmdr] join grpNull;

---------- Post added at 08:45 PM ---------- Previous post was at 06:48 PM ----------

I've edited the EndRemoteControl.sqf script so that now only one AI ejects out of the vehicle and then re-enters. But I'm still looking for a way in which none of the AI ejects, but are still able to switch positions. (I believe that I may have taken this script as far as it can go, but correct me if I'm wrong.)

    _driver setPos _cmdrpos;
   _gun moveTo _cmdrpos;

instead of

    _driver setPos _cmdrpos;
   _gun setPos _cmdrpos;

Share this post


Link to post
Share on other sites

I must've misunderstood your question. My bad. Glad you found a way to make it work.

Share this post


Link to post
Share on other sites

:confused: Well I partially fixed it, now after so many enter and exits of the Remote Control Script it doesn't work. :confused:

Share this post


Link to post
Share on other sites

I think I need to create an if then statement, that says something like if gunner then moveTo commander, and another if then statement, that says if driver moveTo commander. But I'm unsure of how to do this. Can anyone give me a hand?

Share this post


Link to post
Share on other sites

Can someone tell me what this If Then statement that I came up with means in English?

       if (_this == _gun) then
      {
             _gun doMove _cmdrpos;
      };

      sleep 5;

      if (_this == _driver) then
      {
             _driver doMove _cmdrpos;
      };

      sleep 5;

Edited by JSF 82nd Reaper

Share this post


Link to post
Share on other sites

I just thought of something, I've been giving the vehicle the action to "Exit Remote Control" and not the "Commander". That's why whenever you get near the vehicle or what ever position you are in, you get the "Exit Remote Control". But the script starts out by remotely controlling the commander, so it should end only by switching back to the commander and exiting. This will probably fix what I'm having trouble with, and still be able to control the other positions when I "Enter Remote Control" again.

(This is just a theory based on my past experience with the basic script I use "whom remoteControl whom". And when I just used this I had to switch back to the commander for it to work properly.)

remotecontrol.sqf

private ["_cntr","_cmdr","_drv","_gun"];
_cntr = UGV_Operator;
_cmdr = Commander UGV;
_drv = Driver UGV;
_gun = Gunner UGV;

   _cntr remoteControl _cmdr;
   _cmdr switchCamera "Internal";

//Make AI Controllable

   [_cmdr] join grpNull;
   selectPlayer _cmdr;    
   setPlayable _drv;
   setPlayable _gun;

exitremotecontrol.sqf

private ["_cntr","_cmdr"];
_cntr = UGV_Operator;
_cmdr = Commander UGV;

   objNull remoteControl _cmdr;
   _controller switchCamera "External";
   selectPlayer _cntr;

And to activate these scripts you need to have this:

initremotecontrol.sqf

private ["_cntr","_cmdr"];
_cntr = UGV_Operator;
_cmdr = Commander UGV;

_cntr addAction ["Enter UGV Mode", "\remotecontrol.sqf"];
_cmdr addAction ["Exit UGV Mode", "\exitremotecontrol.sqf"];

:p (I'm not sure if I still need to keep "[_cmdr] join grpNull;" after "selectPlayer _cntr;", I haven't tested it yet, for I just had a last minuet idea while laying in bed, and had to write it down before I could go to sleep.) :p

Edited by JSF 82nd Reaper

Share this post


Link to post
Share on other sites

Well I'm going to go and test this theory now, but I'm wondering if this will work to make the _cntr equip and switch their weapon to the "pt101_ugvcontroller"?

_cntr addWeapon "pt101_ugvcontroller"; 
_cntr selectWeapon "pt101_ugvcontroller";

Edited by JSF 82nd Reaper

Share this post


Link to post
Share on other sites
I just thought of something, I've been giving the vehicle the action to "Exit Remote Control" and not the "Commander". That's why whenever you get near the vehicle or what ever position you are in, you get the "Exit Remote Control". But the script starts out by remotely controlling the commander, so it should end only by switching back to the commander and exiting. This will probably fix what I'm having trouble with, and still be able to control the other positions when I "Enter Remote Control" again.

(This is just a theory based on my past experience with the basic script I use "whom remoteControl whom". And when I just used this I had to switch back to the commander for it to work properly.)

remotecontrol.sqf

private ["_cntr","_cmdr","_drv","_gun"];
_cntr = UGV_Operator;
_cmdr = Commander UGV;
_drv = Driver UGV;
_gun = Gunner UGV;

   _cntr remoteControl _cmdr;
   _cmdr switchCamera "Internal";

//Make AI Controllable

   [_cmdr] join grpNull;
   selectPlayer _cmdr;    
   setPlayable _drv;
   setPlayable _gun;

exitremotecontrol.sqf

private ["_cntr","_cmdr"];
_cntr = UGV_Operator;
_cmdr = Commander UGV;

   objNull remoteControl _cmdr;
   _controller switchCamera "External";
   selectPlayer _cntr;

And to activate these scripts you need to have this:

initremotecontrol.sqf

private ["_cntr","_cmdr"];
_cntr = UGV_Operator;
_cmdr = Commander UGV;

_cntr addAction ["Enter UGV Mode", "\remotecontrol.sqf"];
_cmdr addAction ["Exit UGV Mode", "\exitremotecontrol.sqf"];

:p (I'm not sure if I still need to keep "[_cmdr] join grpNull;" after "selectPlayer _cntr;", I haven't tested it yet, for I just had a last minuet idea while laying in bed, and had to write it down before I could go to sleep.) :p

Why can't I find the action to "Exit UGV Mode" when I'm in the vehicle? Is it something to do with objNull, or do I have to name the commander?

Share this post


Link to post
Share on other sites

@Cuel I was able to get a hold of someone who knows a lot about scripting and everything is working now, thanks though.

After getting help from Nordin, who created an action array script and fixed up my scripts a bit, everything works now. If anyone would like to use the script feel free, but you will have to change some of the script in order to get it to work for yourself.

(Also take in consideration that these scripts are set up around having to equip and select the UGV_Controller that I created for my addon. If you just want the action to appear without the pt101_ugvcontroller, take out the "currentWeapon player == 'pt101_ugvcontroller'" command.)

init.sqf

private ["_caller"];

_caller = _this select 0;

_caller setVariable ["101_ugv_busy", 0, true];

if (isnil ("101_ugv_ctrl")) then {
player addAction ["Ctrl UGV", "pt101_mule\scr\action_array.sqf", "", 6, false, true, "", "currentWeapon player == 'pt101_ugvcontroller'"];
101_ugv_ctrl = 1;
};

_caller addAction ["DeCtrl UGV", "pt101_mule\scr\exitremotecontrol.sqf","", 6, false, true, "", "commander (vehicle player) == player"];

action_array.sqf

private ["_list","_action_list","_action_nr","_name","_action","_temp"];

_list= position player nearObjects ["Mule_Step1",10000];
_action_list = [];
_action_nr = _this select 2;
player removeAction _action_nr;

{
if (_x getVariable "101_ugv_busy" == 0) then{
_name = format ["<t color='#ff0000'>UGV: %1</t>", _x];
_action = player addAction [_name , "pt101_mule\scr\remotecontrol.sqf", _x, 6, false, true, "", "currentWeapon player == 'pt101_ugvcontroller'"];
_temp = [_action];
_action_list = _action_list + _temp;
}
}forEach _list;

sleep 10;


{
player removeAction _x; 
}forEach _action_list;

player addAction ["Ctrl UGV", "pt101_mule\scr\action_array.sqf", "", 6, false, true, "", "currentWeapon player == 'pt101_ugvcontroller'"];

remotecontrol.sqf

private ["_cntr","_veh","_cmdr"];

ugv_mule_exit = false;
_cntr = _this select 1;
_veh = _this select 3;
_cmdr = Commander _veh;


//Make AI Controllable

_cntr remoteControl _cmdr;
_veh switchCamera "Internal";

[_cmdr] join grpNull;
selectPlayer _cmdr;

_veh setVariable ["101_ugv_busy", 1, true];

waitUntil {!alive _veh or !alive player or ugv_mule_exit};

objNull remoteControl _cmdr;
_cntr switchCamera "External";
[_cntr] join grpNull;
selectPlayer _cntr;
_cntr selectWeapon (primaryWeapon _cntr);

_veh setVariable ["101_ugv_busy", 0, true];

exitremotecontrol.sqf

ugv_mule_exit = true;

I hope you enjoy, it was pretty hard work to find a way around the camera thing that many who have used the original command would come across:

who remoteControl whom; x switchCamera "";

Edited by JSF 82nd Reaper

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  

×