Jump to content
Sign in to follow this  
spitfire007

Script to only allow one player control of a uav backpack

Recommended Posts

Hi,

Is there a way I can restrict a UAV to be only available to one player at a time ?

At the moment multiple players can go to the UAV and call it.

I only want one to be available at any one time.

Share this post


Link to post
Share on other sites

Hey Spitfire007

This is how I do it. There may be an easy way but this works for me!!!

if !(isnull player) then {

null = [] execvm "briefing.sqf";

if (playerSide == west && rank player == "CAPTAIN") then {null = [] execVM "what ever script you want the player who is CAPTAIN to use"};

};

Then in a briefing.sqf put this

if ( isNil{player getVariable "mk_killedEHadded"} ) then

{

player addEventHandler ["killed",

{

[] spawn {

waitUntil { alive player }; // waitUntil player has respawned

if (playerSide == west && rank player == "CAPTAIN") then {null = [] execVM "The same SCRIPT you want the player to use";}

};

}];

player setVariable ["mk_killedEHadded", true];

};

This was shown to me and it works! What ever unit you put down in the editor with a rank of captain can use the script!!!

Share this post


Link to post
Share on other sites

Thankyou for the reply AVIBIRD 1

Unfortunately it is not quite what I was looking for, although it would be fine if I gave people ranks in the misson.

What I am trying to do is.

Each player should be able to use the UAV whatever their rank.

But .. I just want it locked out if another player is accessing it at the time the other player is using it so there are not two UAV's up at the same time.

Hope this makes sense.

Share this post


Link to post
Share on other sites

I did not see you wanted all the playable units to use the script. There is a way using publicvariable to call the script and the sleep command so it can not be used again until the sleep command is over and then the script can be called again.

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

Hummm.... I will try it ... but I don't see how it will lock other players out when they are all captains.

All players should be able to use the script .. but only one at a time.

Share this post


Link to post
Share on other sites

Thanks for the code AVIBIRD 1....

I am thinking that what I really need is a variable that I can call on on the server so check if someone else is using the script.

Looking through this post has given me the idea that I might be able to pass a variable to the server to lock out the other player from executing the script.

http://killzonekid.com/arma-scripting-tutorials-basic-multiplayer-coding/

I am very new at this arma scripting so hope this is making sense.

Share this post


Link to post
Share on other sites

Hey mate here you go a very simple one should work on most scripts (:

//Put this at the top of your script

if (!((player getVariable "uavAvailable") == "uavAvailable")) exitWith {hint "uav not available for Support"};

player setVariable ["uavAvailable", "uavUNAvailable"];

// script goes here

// script goes here

//script goes here

//then put this at the bottom of your script

sleep 600; // what ever time you want in seconds this is 10 minutes until the script can be used again

player setVariable ["uavAvailable", "uavAvailable"];

hint "US Army air surveillance ready for support if needed!";

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

That's an interesting idea.

That will not stop other people using the UAV though will it ? as they will have to run the same script too ?

I probably should mention that I want this for multiplayer :)

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  

×