Jump to content
thedubl

Looking for some advice and help on first eventhandler

Recommended Posts

Should also be

_unit = _this select 0;

_unit addeventHandler

but meh thats what you get when i paste from testing in units init ;)
  • Like 1

Share this post


Link to post
Share on other sites

Whoa! Thanks! I added the #define _unit. So, a couple questions. Should I wrap the isServer around it still? Should I add, "null = [this]execVM "tkpunish.sqf";" in the localplayerinit or the playable init (does it even matter)?  I am visual person/learner and actually seeing that bit really solidified some things I was not sure about. I will give it a go and post back! Thanks again for all the assistance.

 

dubl

Share this post


Link to post
Share on other sites

Should I wrap the isServer around it still?

Better leave it out, because you want this stuff to work client side. As long as you test on your local PC, isServer will be true. But when you actually have a running server and clients joining that server, isServer will be false on the clients.

 

Should I add, "null = [this]execVM "tkpunish.sqf";" in the localplayerinit or the playable init (does it even matter)?

You may put that into the init field of the playable unit in the ingame editor. But if you lookup here, you'll find an "initPlayerLocal.sqf" in that table. That file will be executed on the client when he joins the mission.

 

So you could also take the above line, replace "this" by "player" and put it into a file called "initPlayerLocal.sqf" which is to be put where your "init.sqf" is located and you don't need to worry about your editor placed unit's init fields regardings this point.

Share this post


Link to post
Share on other sites

Ok. I already have a initplayerlocal.init. So, I will go that route. Trying it now! Larrow I would like to clarify something. _unit = _this select 0; in the eventhandler does not need the parenthesis? Is it the same for the _killer = (_this select 1);? It wasn't working last night, but I did not  really have a chance to mess with it long.

 

 

initplayerlocal.init

 

//tk script
null = [player]execVM "tkpunish.sqf";

 

tkpunish.sqf

 


#define TIME_START = 59;

TAG_fnc_teamKill = {

disableUserInput true;

//We can use player as we are now on the clients machine that killed
player setCaptive true;
player switchMove "AinjPpneMstpSnonWrflDnon";

titleText ["Teamkill punishment!", "PLAIN", 2];
sleep 3;

_time = TIME_START;
while {_time > 0} do {
_time = _time - 1;
sleep 1;
titleText [format["Time Left: %1",_time], "PLAIN"];
};

disableUserInput false;

player setCaptive false;
forceRespawn player;

};


_unit addEventHandler ["killed", {
_unit = (_this select 0);
_killer = (_this select 1);

//If we are a vehicle death exit
if(vehicle _killer isEqualTo vehicle _unit) exitWith{};

if (isPlayer _killer && { side group _unit isEqualTo side _killer} ) then {


[] remoteExec [ "TAG_fnc_teamKill", _killer ];

};
}];

dubl

Share this post


Link to post
Share on other sites

Hey there! I will try using the playable unit init since the the initplayerlocal.init was a no go. I already have some things in the player init. It is ok to have multiple exec in the init? Again, the above is exactly what I am using.

 

 

example:

null = [this]execVM "tkpunish.sqf";

null = [this]execVM "exmaple.sqf";

 

dubl

Share this post


Link to post
Share on other sites

The define was not working. However, I set time in the function and it works. Thanks for the help!

 

UPDATE: I might have spoken to soon. Doesn't seem to run on the server. Still looking into it.

 

UPDATE: player init all working!!! 

 

Thanks!

dubl

 

WORKING BELOW:

/********************************************************************************
Teamkiller punishment

place this in the initplayerlocal.init
null = [player]execVM "tkpunish.sqf";

or
playable init of the unit
null = [this]execVM "tkpunish.sqf";

*********************************************************************************/

//#define TIME_START = 10

_unit= _this select 0;

TAG_fnc_teamKill = {

//We can use player as we are now on the clients machine that killed

disableUserInput true;


player setCaptive true;
player switchMove "AinjPpneMstpSnonWrflDnon";

titleText ["Teamkill punishment!", "BLACK FADED", 2];
sleep 3;


_time = 60;
while {_time > 3} do {
_time = _time - 1;
sleep 1;
titleText [format["Time Left: %1",_time], "PLAIN"];

};


titleText ["Be aware of your team at all times to avoid time out!", "BLACK FADED", 2];
sleep 3;


disableUserInput false;
player setCaptive false;
forceRespawn player;



};


_unit addEventHandler ["killed", {
_unit= _this select 0;
_killer=_this select 1 ;


//If we are a vehicle death exit
if(vehicle _killer isEqualTo vehicle _unit) exitWith{};


if (isPlayer _killer && { side group _unit isEqualTo side _killer } ) then {



[] remoteExec [ "TAG_fnc_teamKill", _killer ];

};
}];

  • Like 1

Share this post


Link to post
Share on other sites

Just to round it out, it's supposed to be #define TIME_START 10 (without "="), not #define TIME_START = 10.

 

Defines are no variables, but placeholders which the preprocessor searches in the script and replaces by the respective value (10 here) prior to interpreting ("compiling") the script. That's why they don't have a "=".

Share this post


Link to post
Share on other sites

AHHHHH! hahaha well... I can't believe I overlooked it. Thanks everyone for helping and contributing! It is a fixed and working with define or with setting time in the function.

 

dubl

Share this post


Link to post
Share on other sites

Well the function which you wrote is no dramatic enough.

Try this one.

TAG_fnc_teamKill = {
private ["_txt", "_output", "_declare"];
[profileName + " has killed Teammate!", "systemChat"] call BIS_fnc_MP;
sleep 2;
player setCaptive true;
disableUserInput true;
sleep 2;
	titleCut ["", "BLACK FADED", 999];
	sleep 3;
	playSound "WoundedGuyA_03";
	titleText ["YOU HAVE KILLED A TEAMMATE!!","PLAIN"]; 
	titleFadeOut 5;
	sleep 5;
        playSound "WoundedGuyA_04";
	titleText ["HOW COULD YOU?!","PLAIN"]; 
	titleFadeOut 5;
	sleep 5;
	_txt = "You are experiencing extreme stress caused by killing your teammate!!";
	_output = [
		[_txt,"<t size='1.2' font='PuristaBold'>%1</t>",15] 
	];

	_declare = [_output,0,0.5,"<t color='#FFFFFFFF' align='center'>%1</t>"] spawn BIS_fnc_typeText;
	waitUntil {scriptDone _declare};
	
	"dynamicBlur" ppEffectEnable true;   
	"dynamicBlur" ppEffectAdjust [6];   
	"dynamicBlur" ppEffectCommit 0;     
	"dynamicBlur" ppEffectAdjust [0.0];  
	"dynamicBlur" ppEffectCommit 5;  

	titleCut ["", "BLACK IN", 5];
	sleep 3;
        playSound "WoundedGuyA_06";
player switchMove "Acts_UnconsciousStandUp_part2";
waituntil { sleep 0.5; animationState player != "Acts_UnconsciousStandUp_part2"};
titleCut ["", "BLACK FADED", 999];
sleep 2;
playSound "4Five_near";
player setdamage 0.9;
player setCaptive false;
disableUserInput false;
"dynamicBlur" ppEffectEnable true;   
"dynamicBlur" ppEffectAdjust [6];   
"dynamicBlur" ppEffectCommit 0;     
"dynamicBlur" ppEffectAdjust [0.0];  
"dynamicBlur" ppEffectCommit 5;  
titleCut ["", "BLACK IN", 5];
player setdamage 1;
};
  • Like 1

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

×