Jump to content
Sign in to follow this  
Icaruk

Making people immune (locally) on certain conditions.

Recommended Posts

init.sqf

null = [player] execVM "script.sqf";

script.sqf

_caller = _this select 0;

while {true} do {
if ((_caller distance center) > 45) then { // when someone is far away from the center, he will be vulnerable
	_caller allowdamage true;
	waitUntil {((_caller distance center) < 45)};
	_caller allowdamage false;
};

if ((_caller distance center) < 45) then {
	_caller allowdamage false;
	waitUntil {((_caller distance center) > 45)}; // when someone is near the center, he will be immune
	_caller allowdamage true;
};
sleep 5;	
};

The idea is that the script works just to the player that is near the centre, not to all players on map, but the problem is that _caller is not defined, on local it works nice, but on multiplayer doesn't... any ideas?

Edited by Icaruk

Share this post


Link to post
Share on other sites

It needs some time for player initialization, add this in the begining:

waitUntil {!isNull _caller};

Edited by Champ-1

Share this post


Link to post
Share on other sites

waitUntil (player == player);

Could work too?

Share this post


Link to post
Share on other sites

It's the same thing.

"player" will be a null object on JiPs until they've been loaded, so you're basically writing this:

waitUntil {objNull == objNull};

Which will be false because null doesn't equal anything, not even itself. Once the "player" object has been initalized and assigned the waitUntill will continue because then you're checking if some object equals the same object.

I prefer the "!isNull player" approach, it makes it easier to read.

Also

"script".sqf;  

Typo I presume

Share this post


Link to post
Share on other sites

add and remove a handledamage eventhandler

Share this post


Link to post
Share on other sites
It's the same thing.

"player" will be a null object on JiPs until they've been loaded, so you're basically writing this:

waitUntil {objNull == objNull};

Which will be false because null doesn't equal anything, not even itself. Once the "player" object has been initalized and assigned the waitUntill will continue because then you're checking if some object equals the same object.

I prefer the "!isNull player" approach, it makes it easier to read.

Also

"script".sqf;  

Typo I presume

Yeah, typo xD

I'll test this, thanks.

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  

×