Jump to content
Alpine_gremlin

Can I Improve my JIP Check Script?

Recommended Posts

Hey guys so I`m making my first PvP team deathmatch type mission. When a player runs the mission I want to run a simple check to see if they joined in progress or were there when the server (my PC) initialized the mission. I was wondering if those more experienced than I could let me know if I can use a more effective way to check for JIP players. I would really be curious to learn.

 

init.sqf

execVM "checkforJIP.sqf"; //JIP check
execVM "startMatch.sqf"; //run for players that are in the server at mission start

checkforJIP.sqf

if (time > 20) then {
playerIsJIP = true;
}else
{
playerIsJIP = false; //will allow startMatch.sqf to run
};

if (playerIsJIP) then {
player setPos position debugPos;
zone = true;
}else
{
hint "You are not a JIP player";
};

Any tips would be appreciated!  Cheers!

  • Like 1

Share this post


Link to post
Share on other sites

 

The event script initPlayerLocal.sqf can already provide you with this information.

//initPlayerLocal.sqf

params[ "_player", "_didJIP" ];

if ( _didJIP ) then {
	_player setPos position debugPos;
	zone = true;
}else{
	hint "You are not a JIP player";
	execVM "startMatch.sqf"; //run for players that are in the server at mission start
};

 

  • Like 1
  • Thanks 3

Share this post


Link to post
Share on other sites
7 hours ago, Larrow said:

 

The event script initPlayerLocal.sqf can already provide you with this information.


//initPlayerLocal.sqf

params[ "_player", "_didJIP" ];

if ( _didJIP ) then {
	_player setPos position debugPos;
	zone = true;
}else{
	hint "You are not a JIP player";
	execVM "startMatch.sqf"; //run for players that are in the server at mission start
};

 

Hey man thanks! It works for the most part there seems to be an issue: My startMatch.sqf and script that is dependent on the zone variable to function now only work for me. They no longer affect other players and I am not sure why. I wrote the initplayerlocal exactly as you have it. Did I somehow screw up the locality of variables or something?

Share this post


Link to post
Share on other sites

Mind for initialization order. As you can see init.sqf and initplayerLocal.sqf have not the same sequence in SP or MP.

So, your variables (global (local) or public) must be defined before use.

  • Like 1

Share this post


Link to post
Share on other sites

hello, if it can help you, we use it for all our missions, it works very well.
Put in the init:

if (isServer) then {
         //server stuff
	[] spawn {
                // JIP bool for clients
		bcmJIP = FALSE; publicVariable "bcmJIP";
		waitUntil {(time > 15)};
		bcmJIP = TRUE; publicVariable "bcmJIP";
	};
} else {
	// client stuff
	if (bcmJIP) then {
		// join-in-progress only client stuff
	[] execVM "Data\scripts\initTeleportToSL.sqf";
	} else {
		// join-at-start only client stuff
	[]execVM "Data\Scripts\intro.sqf";
	};
};

 

  • Like 2

Share this post


Link to post
Share on other sites
On 12/8/2017 at 3:47 AM, Alpine_gremlin said:

I wrote the initplayerlocal exactly as you have it. Did I somehow screw up the locality of variables or something?

I only wrote the code in my previous post as a quick example containing some of the stuff from your code, just to show that whether a client JIP's is available in the event script.

As @pierremgi says depending on what your scripts entail and taking into account initialisation order you may need to adjust the example to suit.

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, Larrow said:

I only wrote the code in my previous post as a quick example containing some of the stuff from your code, just to show that whether a client JIP's is available in the event script.

As @pierremgi says depending on what your scripts entail and taking into account initialisation order you may need to adjust the example to suit.

 

Thank you for clearing that up! I`m making progress. My startMatch.sqf finally works for all players, however the zone restriction that I have still does not. The script is executed via a trigger when the player leaves the trigger area by using: zoneR = [zoneTrigger] execVM "zoneRest.sqf";

 

zoneRest.sqf

if (zone) then { //players start outside the zone, this prevents them from being killed until the match starts and they are placed inside the map
_triggerActived = _this select 0;
if (player in (list _triggerActived)) exitWith {};

leftZone = true;
cutText ["YOU ARE LEAVING THE DESIGNATED AREA. YOU HAVE 10 SECONDS TO RETURN!","PLAIN",5];
titleFadeout 6;

sleep 10;
if !(player in (list _triggerActived)) then {
	player setDamage 1;
	player groupChat "COWARDICE WILL NOT BE TOLERATED!";
}else
{
cutText ["CONTINUE THE FIGHT!","PLAIN",5];
titleFadeout 6;
};
};

Can I use a parameter passed by the trigger in order to make sure the script only runs for a player that activates it?

Share this post


Link to post
Share on other sites

don't place this trigger on the map (a global one which has to be run on each JIP),

Create a local trigger instead. That means a little code with createTrigger [type, position, false] syntax. This way you can check if the local player present or not with the condition:

player inArea thisTrigger

The result (activated code) will concern this player only.

 

  • Like 1

Share this post


Link to post
Share on other sites

Although you can place a trigger in the editor and think of it as a "Global Trigger" it is actually not and is instead a local trigger which exists on each machine but with the same settings (condition, activation etc). If you where then to use script commands on each client to change something about the trigger this change would only be local on that machine, as all of the trigger set commands have local effect only (AG EL).

 

So place your trigger in the editor and call it zoneTrigger leaving all other settings as default.

In the initPlayerLocal.sqf use the trigger commands to re-appropriate this trigger for its local client (player).

//initPlayerLocal.sqf

params[ "_player", "_didJIP" ];

//Set the trigger locally only to react to a certain vehicle when not present
zoneTrigger setTriggerActivation [ "VEHICLE", "NOT PRESENT", true ];

//Make the local player the monitored vehicle
zoneTrigger triggerAttachVehicle [ _player ];

//Set the triggers statements
zoneTrigger setTriggerStatements [
	//Condition,  this = player ( vehicle ) not present && zone ( where zone is true if monitoring is enabled )
	"this && zone",
	//Activation
	"[ thisTrigger, true ] call TAG_fnc_zoneTrigger",
	//Deactivation
	"[ thisTrigger, false ] call TAG_fnc_zoneTrigger"
];

TAG_fnc_zoneTrigger = {
	params[ "_trigger", "_activated" ];

	if ( _activated ) then {
		cutText ["YOU ARE LEAVING THE DESIGNATED AREA. YOU HAVE 10 SECONDS TO RETURN!","PLAIN",5];
		titleFadeOut 6;

		//Mark the player as AWOL
		player setVariable[ "AWOL", true ];

		//Spawn thread to kill the player in 10 seconds
		_nul = [] spawn {
			_deathTime = time + 10;

			//Wait until death time OR the player becomes not AWOL
			waitUntil { time >= _deathTime || !( player getVariable [ "AWOL", false ] ) };

			//If the player is still AWOL
			if ( player getVariable [ "AWOL", false ] ) then {
				//Kill the player
				player setDamage 1;
				player groupChat "COWARDICE WILL NOT BE TOLERATED!";
			};
		};
	}else{
		cutText ["CONTINUE THE FIGHT!","PLAIN",5];
		titleFadeOut 6;

		//Mark player as not AWOL
		player setVariable[ "AWOL", false ];
	};
};

//You may need to add events to switch  zone checking on/off

_player addEventHandler [ "Killed", {
	params[ "_killed" ];

	//Set player as not AWOL
	_killed setVariable [ "AWOL", false ];
	//Cancel zone checking
	zone = false;
}];

_player addEventHandler [ "Respawn", {
	//Re-Enable zone checking
	zone = true;
}];

 

  • Like 3

Share this post


Link to post
Share on other sites

Oh my @Larrow, thank you so much for taking the time to write all of that out! So the initPlayerLocal will set the trigger settings manually only for the local player, allowing the script to effect each player individually?

 

Cheers! I will give it a try! :)

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

×