Jump to content
Sign in to follow this  
IKG40Razor

Get script working for JIP/reconnected player in MP

Recommended Posts

Hi. I have a script for some "drug" effect

// Drugs Scripts
// drug2.sqf

if ((UH60 == player || C130 == player || CH47_1P == player || CH47_2P == player || A10_1 == player || A10_2 == player) && !isdedicated) then

{

while {isNil "NotUnderDrug1"} do 
	{
	"colorCorrections" ppEffectEnable true;
	"colorCorrections" ppEffectAdjust [1, 1, 0, [0,0,0,0.5], [random 5 - random 5,random 5 - random 5,random 5 - random 5,random 1], [random 5 - random 5,random 5 - random 5,random 5 - random 5, random 1]];  
	"colorCorrections" ppEffectCommit 1;	
	"wetDistortion" ppEffectEnable true;
	"wetDistortion" ppEffectAdjust [0.5, 1, 1, 4.1, 3.7, 2.5, 1.85, 0.0051, 0.0051, 0.0051, 0.0051, 0.5, 0.3, 10, 6.0];
	"wetDistortion" ppEffectCommit 5;
	"chromAberration" ppEffectEnable true;
	"chromAberration" ppEffectAdjust [0.02,0.02,true]; 
	"chromAberration" ppEffectCommit 1;

	sleep 3;

	};
};

"colorInversion" ppEffectEnable false;
"wetDistortion" ppEffectEnable false;
"colorCorrections" ppEffectAdjust [1, 1, 0, [0.5,0.5,0.5,0], [0.5,0.5,0.5,0], [0.5,0.5,0.5,0]]; 
"colorCorrections" ppEffectCommit 10;
waitUntil {ppEffectCommitted "colorCorrections"}; 
"colorCorrections" ppEffectEnable false;
"chromAberration" ppEffectEnable false;

And i have a trigget that stops it at certain condition like

condition:

({_x in thislist} count (units mpGroup + units moGroup))>=1

activation:

call {[] spawn {sleep 30; NotUnderDrug1 = true;}}

I have 2 problems:

1) when even the same player reconnects before trigger is activated "drug" effect is already no more

2) when even the same player reconnects after trigger was activated I'm not sure he receives the data that trigger has already been activated

Share this post


Link to post
Share on other sites

Here is the best suggestion I can think of. Modify my script to save the proper data.

You are free to use this as you wish, just please leave the original credits.

//Wyatt's score management script
/*
This script saves players data every 2 minutes.  When players reconnect to the game, their data is recovered.
*/

//Create the array if it does not already exist.

private ["_id","_present","_s","_debugcount"];
if (isnil "GlobalDataStorageArray0") then {GlobalDataStorageArray0 = []; if (rundebug) then {diag_log text format["scoresave.sqf - GlobalDataStorageArray0 array created."];};};

_present = false; //Declare variable false
_id = getPlayerUID (vehicle player);  //Get player ID and add to variable


//Lets check and see if the player is currently in our array!  If he is in our array, we will give him his score back.
{
    if ( (_x select 0) == (_id) ) exitWith
    {
       _present = true; //If the _id is found in the array, then set the _present var to true!
	player addScore (_x select 1);
	if (rundebug) then {diag_log text format["scoresave.sqf - %1 score has been recovered with ID %2", player, _x];};
	Hint "Welcome back! \nYour score has been recovered.";
	sleep 2;
	Hint "";
    };
} foreach GlobalDataStorageArray0;


//If the player is not in the array, add him to the array then broadcast!
if (!_present) then
{
    GlobalDataStorageArray0 = GlobalDataStorageArray0 + [ [_id, score player] ];
    publicVariable "GlobalDataStorageArray0";
 if (rundebug) then {diag_log text format["scoresave.sqf - New player, %1, has been added to the score save array with ID %2 and has been pushed public.", player, _id];};
};


//Score save loop!
for [{_s=0},{_s<1},{_s=_s}] do
{
   sleep 100+(random 40); //Wait approx. 2 mins +/- 20 seconds
    {
         if ( (_x select 0) == (_id) ) exitWith
         {
              _x set [1, score player]; //Put the player's current score in the array
		   if (rundebug) then {diag_log text format["scoresave.sqf - %1 score has been UPDATED with the following information %2", player, _x];};
         };
    } foreach GlobalDataStorageArray0;
    publicVariable "GlobalDataStorageArray0";
if (rundebug) then {
if (isnil "_debugcount") then {_debugcount = 0};
_debugcount = _debugcount + 1;
diag_log text format["scoresave.sqf - Infinite loop in script has reached its goal.  Loop has reached a count of %1", _debugcount];};
};
if (rundebug) then {diag_log text format["scoresave.sqf - DANGER! The script should have not made it here due to the infinite loop.  This is the end of the script."];};

Note that for all my scripts, I have rundebug = true or false in the init script. For this script, just add that near the top.

Edited by Wyattwic

Share this post


Link to post
Share on other sites

got a lil bit further

Script launched by

call {execVM "drug1.sqf"};

in init.sqf or unit's init

if "drug1.sqf" contains

// Drugs Scripts
// drug1.sqf

while {isNil "NotUnderDrug1"} do 
	{
	"colorCorrections" ppEffectEnable true;
	"colorCorrections" ppEffectAdjust [1, 1, 0, [0,0,0,0.5], [random 5 - random 5,random 5 - random 5,random 5 - random 5,random 1], [random 5 - random 5,random 5 - random 5,random 5 - random 5, random 1]];  
	"colorCorrections" ppEffectCommit 1;	
	"wetDistortion" ppEffectEnable true;
	"wetDistortion" ppEffectAdjust [0.5, 1, 1, 4.1, 3.7, 2.5, 1.85, 0.0051, 0.0051, 0.0051, 0.0051, 0.5, 0.3, 10, 6.0];
	"wetDistortion" ppEffectCommit 5;
	"chromAberration" ppEffectEnable true;
	"chromAberration" ppEffectAdjust [0.02,0.02,true]; 
	"chromAberration" ppEffectCommit 1;

	sleep 3;

	};

"colorInversion" ppEffectEnable false;
"wetDistortion" ppEffectEnable false;
"colorCorrections" ppEffectAdjust [1, 1, 0, [0.5,0.5,0.5,0], [0.5,0.5,0.5,0], [0.5,0.5,0.5,0]]; 
"colorCorrections" ppEffectCommit 10;
waitUntil {ppEffectCommitted "colorCorrections"}; 
"colorCorrections" ppEffectEnable false;
"chromAberration" ppEffectEnable false;

each player after rejoin has it's effect again.

But if it has additional line to limit it's effect on a group or number of players such as

// Drugs Scripts
// drug1.sqf

[color="#FF0000"]if !(player in units group A10) exitWith {};[/color]

while {isNil "NotUnderDrug1"} do 
	{
	"colorCorrections" ppEffectEnable true;
	"colorCorrections" ppEffectAdjust [1, 1, 0, [0,0,0,0.5], [random 5 - random 5,random 5 - random 5,random 5 - random 5,random 1], [random 5 - random 5,random 5 - random 5,random 5 - random 5, random 1]];  
	"colorCorrections" ppEffectCommit 1;	
	"wetDistortion" ppEffectEnable true;
	"wetDistortion" ppEffectAdjust [0.5, 1, 1, 4.1, 3.7, 2.5, 1.85, 0.0051, 0.0051, 0.0051, 0.0051, 0.5, 0.3, 10, 6.0];
	"wetDistortion" ppEffectCommit 5;
	"chromAberration" ppEffectEnable true;
	"chromAberration" ppEffectAdjust [0.02,0.02,true]; 
	"chromAberration" ppEffectCommit 1;

	sleep 3;

	};

"colorInversion" ppEffectEnable false;
"wetDistortion" ppEffectEnable false;
"colorCorrections" ppEffectAdjust [1, 1, 0, [0.5,0.5,0.5,0], [0.5,0.5,0.5,0], [0.5,0.5,0.5,0]]; 
"colorCorrections" ppEffectCommit 10;
waitUntil {ppEffectCommitted "colorCorrections"}; 
"colorCorrections" ppEffectEnable false;
"chromAberration" ppEffectEnable false;

or

[color="#FF0000"]if ((UH60 == player || C130 == player || CH47_1P == player || CH47_2P == player || A10_1 == player || A10_2 == player) && !isdedicated) then

{[/color]

player from group A10 or from that list after reconnect don't get script effect again. I ask what's wrong, cause I assume after reconnection player's unit still remains in A10 group?

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  

×