Jump to content
Sign in to follow this  
kiyoshisaotome

Locking Unlocking vehicle in I&A

Recommended Posts

Greeting everyone

I'm currently working along side with friends in developing an I&A coo-op game-play. A problem we ran into while developing out mission file is having the ability to lock and unlock vehicles. We want all supporting vehicle tank\CAS\Arty\LAV\UCAV to be lock from the start of the game, and can be unlock by an individual name "HQ" which B_officer_F. My friends and I rack our brain but can't come up with any solution to this. If you can help us in any way, we would be extremely grateful.

Share this post


Link to post
Share on other sites

What is there to rack your brain over?

Lock the vehicles and add an action to unlock them that only shows up for your HQ unit.

 

Should be really simple or what is it that you don't understand about it ?

  • Like 1

Share this post


Link to post
Share on other sites
this addAction [(if ((locked this < 2)) then {"Lock"} else {"Unlock"}), {if ((locked (_this select 0) < 2)) then {(_this select 0) lock 2; (_this select 0) setUserActionText [(_this select 2), "Unlock"];} else {(_this select 0) lock 0; (_this select 0) setUserActionText [(_this select 2), "Lock"];};}];
this addAction [(if ((locked this < 2)) then {"Lock"} else {"Unlock"}), {if ((locked (_this select 0) < 2)) then {(_this select 0) lock 2; (_this select 0) setUserActionText [(_this select 2), "Unlock"];} else {(_this select 0) lock 0; (_this select 0) setUserActionText [(_this select 2), "Lock"];};}, "", 0, false, false, "", "(getPlayerUID _this in [""123""])"];

 

Share this post


Link to post
Share on other sites
3 hours ago, HazJ said:

this addAction [(if ((locked this < 2)) then {"Lock"} else {"Unlock"}), {if ((locked (_this select 0) < 2)) then {(_this select 0) lock 2; (_this select 0) setUserActionText [(_this select 2), "Unlock"];} else {(_this select 0) lock 0; (_this select 0) setUserActionText [(_this select 2), "Lock"];};}];

this addAction [(if ((locked this < 2)) then {"Lock"} else {"Unlock"}), {if ((locked (_this select 0) < 2)) then {(_this select 0) lock 2; (_this select 0) setUserActionText [(_this select 2), "Unlock"];} else {(_this select 0) lock 0; (_this select 0) setUserActionText [(_this select 2), "Lock"];};}, "", 0, false, false, "", "(getPlayerUID _this in [""123""])"];

 

This go to the vehicle?

Share this post


Link to post
Share on other sites
3 hours ago, Tajin said:

What is there to rack your brain over?

Lock the vehicles and add an action to unlock them that only shows up for your HQ unit.

We are beginner in script-er,  at most we can modify values from pre-existing scripts, writing script is out of the question for us.

Share this post


Link to post
Share on other sites

Vehicle init in the editor, yes.

6 minutes ago, kiyoshisaotome said:

We are beginner in script-er,  at most we can modify values from pre-existing scripts, writing script is out of the question for us.

Doesn't seem like you can do that, I've done it for you. I doubt you even searched around to help yourself. Just note: I won't be doing this for you again. I don't mind helping you, or anyone on the forums, as long as they are motivated to learn and try themselves. NOT expect everything done for them! If you searched, you would of found either a working example or at least some code that you could of messed with, and even added it in your thread.

Share this post


Link to post
Share on other sites
2 minutes ago, HazJ said:

Vehicle init in the editor, yes.

Can this be tailor to just B_officer_F?

also it is lost after respawn

Share this post


Link to post
Share on other sites

You have clearly ignored my message in my previous post so I will now ignore you, I will say this however... Try to help yourself before expecting it all done for you. Check out this here!

Share this post


Link to post
Share on other sites

I try comparing it to other script use by other server to see if it worked

 

This one is for UAV operator use on most I&A server

 

this addAction ["<t color='#ff1111'>Recycle UAV crew</t>","scripts\actions\uavfix_switch.sqf",[],21,true,true,"",'((vehicle player) == player) && ((player distance _target) < 5) && (player isKindOf "B_soldier_UAV_F")']; 

 

replace the end with (player isKindOf "B_officer_F") 

 

this addAction [(if ((locked this < 2)) then {"Lock"} else {"Unlock"}), {if ((locked (_this select 0) < 2)) then {(_this select 0) lock 2; (_this select 0) setUserActionText [(_this select 2), "Unlock"];} else {(_this select 0) lock 0; (_this select 0) setUserActionText [(_this select 2), "Lock"];};}, "", 0, false, false, "", "(getPlayerUID _this in [""123""])"];

 

Doesn't seem to work out well

 

 

 

 

Share this post


Link to post
Share on other sites

What about it? 123 was just an example/placeholder and needs to be changed, obviously.

Share this post


Link to post
Share on other sites
8 minutes ago, pierremgi said:

(getPlayerUID _this in [""123""]) ?

What about it? It should be:

this addAction [(if ((locked this < 2)) then {"Lock"} else {"Unlock"}), {if ((locked (_this select 0) < 2)) then {(_this select 0) lock 2; (_this select 0) setUserActionText [(_this select 2), "Unlock"];} else {(_this select 0) lock 0; (_this select 0) setUserActionText [(_this select 2), "Lock"];};}, "", 0, false, false, "", "(_this isKindOf ""B_officer_F"")"];

Double quotes as it is in a string already. Some people use single quotes, I use double quotes though.

Share this post


Link to post
Share on other sites

I don't think it really helps anyone to just throw them random bits of code with no comment whatsoever and without knowing the details. (checking for playerUIDs was never part of the question and while its great to provide an alternative solution, you should at least comment it)

 

it's better for everyone if things happen in the right order.:

The first thing should always be that the person asking for help provides enough information !

I wouldn't bother posting any solutions purely based on guesswork.

 

Basically this:

- What do you want to achieve

- What have you tried to achieve it (sharing the existing code is always helpful)

- Where are you stuck / what kind of help are you looking for

- any additional info on your specific scenario (for example that your vehicles can respawn)

 

However, like HazJ mentioned earlier, this forum is mainly for people who need help scripting things. Beeing new to scripting it is perfectly fine. People will gladly help you out if you're stuck. Just don't expect them to do everything for you, so you don't have to learn it yourself.

 

 

- - - - -

 

 

Anyway, there are multiple ways this can be done, which one is best depends on the situation and how strict you want the limitation to be....

 

For example, maybe you want every vehicle of a certain type to be locked for players by default, even enemy ones. This could be the case on a public server if you want to make sure certain vehicles are not publicly available so people cant mess around with them.

 

In that case it may be better to not lock those vehicles one by one but instead use an EventHandler that you can attach to each player, which then checks if they enter a vehicle and throws them back out if they're not allowed to use that vehicle. This would easily work with vehicles that are added later on, or respawn. You would just have to add a variable to them to allow them to be usable.

 

Actively locking vehicles basically works the other way around and requires you to do it for every single vehicle that you want locked. Even when they respawn or get added later. Certainly doable but normally more suited when you have a limited number of vehicles to which it should apply.

 

 

 

I'd also suggest reading this: https://community.bistudio.com/wiki/addAction

It is one of the true bread and butter commands for anyone starting to script.

  • Like 2

Share this post


Link to post
Share on other sites
3 hours ago, Tajin said:

I don't think it really helps anyone to just throw them random bits of code with no comment whatsoever and without knowing the details. (checking for playerUIDs was never part of the question and while its great to provide an alternative solution, you should at least comment it)

 

it's better for everyone if things happen in the right order.:

The first thing should always be that the person asking for help provides enough information !

I wouldn't bother posting any solutions purely based on guesswork.

 

Basically this:

- What do you want to achieve

- What have you tried to achieve it (sharing the existing code is always helpful)

- Where are you stuck / what kind of help are you looking for

- any additional info on your specific scenario (for example that your vehicles can respawn)

 

However, like HazJ mentioned earlier, this forum is mainly for people who need help scripting things. Beeing new to scripting it is perfectly fine. People will gladly help you out if you're stuck. Just don't expect them to do everything for you, so you don't have to learn it yourself.

 

 

- - - - -

 

 

Anyway, there are multiple ways this can be done, which one is best depends on the situation and how strict you want the limitation to be....

 

For example, maybe you want every vehicle of a certain type to be locked for players by default, even enemy ones. This could be the case on a public server if you want to make sure certain vehicles are not publicly available so people cant mess around with them.

 

In that case it may be better to not lock those vehicles one by one but instead use an EventHandler that you can attach to each player, which then checks if they enter a vehicle and throws them back out if they're not allowed to use that vehicle. This would easily work with vehicles that are added later on, or respawn. You would just have to add a variable to them to allow them to be usable.

 

Actively locking vehicles basically works the other way around and requires you to do it for every single vehicle that you want locked. Even when they respawn or get added later. Certainly doable but normally more suited when you have a limited number of vehicles to which it should apply.

 

 

 

I'd also suggest reading this: https://community.bistudio.com/wiki/addAction

It is one of the true bread and butter commands for anyone starting to script.

I could of, but it would be a complete waste of time. @kiyoshisaotome doesn't seem motivated or willing to learn so I couldn't be bothered. I at least gave him working code. I realised about the HQ classname after pierremgi's post. Which in fact after that I posted again with ready to use 'working' code. I don't know why you are telling me how to reply on the forums and honestly couldn't give a sh*t since you didn't contribute at all to the original question at all. Why bother posting? There is a feature called private messaging.

Share this post


Link to post
Share on other sites

Hey I simply made a point and I think I've explained it well enough, theres no reason to be rude about it.

 

I wanted to get some more information out of him before answering so we can help in a way that is actually useful to him instead of wasting ours and his time.

As it turns out, he's new to scripting, so it just wouldn't make sense to me to drop him a few lines of code without even telling what they do.

 

 

13 hours ago, HazJ said:

didn't contribute at all to the original question at all

Really? I took apart the problem and explained to him that there are different ways to do it, depending on what exactly he wants to achieve. How does that not contribute to the question?

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

@Tajin

It's fucking boring to read the same queries over and over because a poster can't/won't/didn't use the search function.

 

And it's more fucking boring when they provide so little info that the thread takes like 15 posts or so to establish exactly what they want and budding scripters prostrate themselves by offering up whole chunks of code seemingly on demand.  They are not helping the OP by getting them to actually use their brain and they are doing themselves a disservice by being at the beck and call of anyone who posts a one-liner question.

 

It's become "script request" and is the reason why I spend less and less time on what was once a good forum.

  • Like 2
  • Thanks 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
Sign in to follow this  

×