Jump to content
Sign in to follow this  
mantls

JIP and AddAction

Recommended Posts

Hey there,

I'm having some problems with AddActions assigned to JIP's.

I have tried several things:

if (local player) then {

player addeventhandler ["Respawn", {
player addaction [("<t color=""#ED2744"">") + ("Paradrop") + "</t>", "NSS\ParaScript\Paradrop.sqf", "", 1, false, true,"", "((vehicle player) iskindof ""Air"") && (((position player) select 2) > 20)"];
}];

player addaction [("<t color=""#ED2744"">") + ("Paradrop") + "</t>", "NSS\ParaScript\Paradrop.sqf", "", 1, false, true,"", "((vehicle player) iskindof ""Air"") && (((position player) select 2) > 20)"];

};

works, but as expected not for JIPs

para = {

if (local player) then {

player addeventhandler ["Respawn", {
player addaction [("<t color=""#ED2744"">") + ("Paradrop") + "</t>", "NSS\ParaScript\Paradrop.sqf", "", 1, false, true,"", "((vehicle player) iskindof ""Air"") && (((position player) select 2) > 20)"];
}];

player addaction [("<t color=""#ED2744"">") + ("Paradrop") + "</t>", "NSS\ParaScript\Paradrop.sqf", "", 1, false, true,"", "((vehicle player) iskindof ""Air"") && (((position player) select 2) > 20)"];

};

};

[[],"para",true,true] spawn bis_fnc_mp;

works for JIPs but creates some strange bugs, the AddAction is displayed several times and i believe that stacks up with playercounts.

I've used bis_fnc_mp in another script where it works perfectly, though in that script the addActions were assigned to Objects instead of players. :'(

Any Help is much appreciated, cheers.

Share this post


Link to post
Share on other sites

It seems as if you're running the bis_fnc_mp several times? Is that the whole script or just an example of how you were calling it?

One way of making sure something is only added once is this:

para = {
if (player getVariable ["hasAction",false]) exitWith {};
player setVariable ["hasAction",true];
player addeventhandler ["Respawn", {
	player addaction [("<t color=""#ED2744"">") + ("Paradrop") + "</t>", "NSS\ParaScript\Paradrop.sqf", "", 1, false, true,"", "((vehicle player) iskindof ""Air"") && (((position player) select 2) > 20)"];
}];
player addaction [("<t color=""#ED2744"">") + ("Paradrop") + "</t>", "NSS\ParaScript\Paradrop.sqf", "", 1, false, true,"", "((vehicle player) iskindof ""Air"") && (((position player) select 2) > 20)"];
};

[[],"para",true,true] spawn bis_fnc_mp;

But I'd recommend making sure that the code only runs for JiPs. Such as setting a variable to true, PV it and then run a script through a trigger or whatever.

Share this post


Link to post
Share on other sites

But I'd recommend making sure that the code only runs for JiPs. Such as setting a variable to true, PV it and then run a script through a trigger or whatever.

Could you give me an example on that?

And yeah i guess the script runs several times, since it gets executed for every JIP i believe.

Share this post


Link to post
Share on other sites

Well I'm guessing due to the current structure that paradrop will only be available after a certain event?

When that event occurs just have a trigger with condition

!isNil "TAG_MyCondition"

on act

0 = [] execVM "paradrop.sqf"

Then whenever that event happens, just do

TAG_myCondition = true; publicVariable "TAG_MyCondition";

That will broadcast the value to everyone including JiPs, and they will run the script.

You must also make sure that the player object has been initialised in the script. This is not true for JiPs until after a certain time.

waitUntil {!isNull player}

If there is no certain event that occurs you can simply add the action in init.sqf

if (!isDedicated) then {
waitUntil {!isNull player}
player addeventhandler ["Respawn", {
player addaction [("<t color=""#ED2744"">") + ("Paradrop") + "</t>", "NSS\ParaScript\Paradrop.sqf", "", 1, false, true,"", "((vehicle player) iskindof ""Air"") && (((position player) select 2) > 20)"];
}];
player addaction [("<t color=""#ED2744"">") + ("Paradrop") + "</t>", "NSS\ParaScript\Paradrop.sqf", "", 1, false, true,"", "((vehicle player) iskindof ""Air"") && (((position player) select 2) > 20)"];
};

Share this post


Link to post
Share on other sites

That last bit of code is basically what i did, justwith the (!isNull player) check, right?

Share this post


Link to post
Share on other sites

Pretty much yeah.

Well if it was in init.sqf there's no reason to use bis_fnc_mp

Share this post


Link to post
Share on other sites

it wasn't, was a seperate File i called from the init.sqf.

Anyway that seems to have fixed it! Thank you very much, just learned something for the Future.

cheers

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  

×