Jump to content
pliskin124

Adding AI only when Specific Player is on

Recommended Posts

Greetings,

 

I am looking to script in a function into my mission when only a SPECIFIC player joins (or a specific slot), namely a jet pilot. I don't want jets flying around the map, or SAM sites for that matter when everyone is running infantry. We are running the EOS system, so my idea was essentially this...

 

Detect if player joins,

create marker at invisible object location for EOS zone (At a variable square size)

EOS script will run based on that marker position and handle all of the spawns etc.

Player leaves, delete marker

Rinse and repeat for every rejoin / leaving.

 

Here is what I think I can use to build the framework for this...

 

/* 
ReservedSlot.sqf by Kahna
*/

while {true} do 
{
private ["_reserved_units", "_reserved_uids", "_uid"];

waitUntil {!isNull player};
waitUntil {(vehicle player) == player};
waitUntil {(getPlayerUID player) != ""};

// Variable Name of the Player Character to be restricted. //
_reserved_units = [PlayerNameHere];

// The player UID is a 17 digit number found in the profile tab. //
_reserved_uids = 
[
"xxxxxxxxxxxxxxxxxxxx"/* PlayerNameHere*/
];

// Stores the connecting player's UID //
_uid = getPlayerUID player;


if ((player in _reserved_units)&& !(_uid in _reserved_uids)) then 
{
  titleText ["", "BLACK OUT"];
  disableUserInput true;
  hint "You are in a reserved slot! You will be kicked to the lobby in 15 seconds!";
  sleep 5;
  hint "You are in a reserved slot! You will be kicked to the lobby in 10 seconds!";
  sleep 5;
  hint "You are in a reserved slot! You will be kicked to the lobby in 5 seconds!";
  sleep 5;
  titleText ["", "BLACK IN"];
  disableUserInput false;
  failMission "end1";
  	};  
};

 

By using this reserved slot script to detect whether a player is in, and then calling a "create marker command" through an PilotIn.sqf...

 

_markerstr = createMarker ["EOSFighterPilot1", InvisibleObj1]; _markerstr setMarkerShape "RECTANGLE"; _markerstr setMarkerSize [1000,1000];

 

and if the pilot is not in the game... having it run a PilotOut.sqf

 

deleteMarker "EOSFighterPilot1";

 

 

How would I go about detecting the specific player is on, to run the PilotIn.sqf on entry, and PilotOut.sqf on exit.

 

Any assistance would be greatly appreciated.

Share this post


Link to post
Share on other sites

Thought...

 

Maybe this would be easier to run through a trigger...

 

init:

Detect x player name is alive

On Action:

PilotIn.sqf

On Deactivation:

PilotOut.sqf

 

What is the command to detect if a player is alive?

Share this post


Link to post
Share on other sites

Found this little script that might help...

 

(!isNil "unit1" && {alive unit1})

 

unit1 being the player name, detecting if the player is in the player slot and alive...,

 

however would this require me to set the OnAction to PilotOut.sqf, and the deact to PilotIn.sqf? Going to test.

Share this post


Link to post
Share on other sites
8 hours ago, pliskin124 said:

Found this little script that might help...

 


(!isNil "unit1" && {alive unit1})

 

unit1 being the player name, detecting if the player is in the player slot and alive...,

 

however would this require me to set the OnAction to PilotOut.sqf, and the deact to PilotIn.sqf? Going to test.

 

Worked fine in the editor... however when I tested with the actual player on MP it didn't work. Thoughts?

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

×