Jump to content
Sign in to follow this  
Mopsmaster

Friendly to an OPFOR AIs while being in their Zamar Ammo Truck.

Recommended Posts

So I want to know is that possible to do and if so then how to do that thing step by step :D

I want to let you know that I know nothing about scripting I just know that you can paste some script into the mpmission folders and put something in some sqm file so the script can work.

I want to make a mission in which I would go with my team to an emy stronghold in a OPFOR Transport truck and while we are in this truck with my team I don't want enemies to atack us at all until we will get out of that truck at some point in the enemy base. I want to make it the way that as long as we are in OPFOR Transport truck with my team and all of it's passengers we won't get atacked by an OPFOR so it will look like they treat us as the part of their OPFOR team.

Is that possible thing to do to apply on multiplayer server while I will create mission for my team? If it is then how to achieve that? Could someone explain it step by step please?

If im not wront it would look something like this

if BLUFOR insidie OPFOR covered transport truck then BLUFOR set to captive.

Can anyone please help?

Id like to make it in the way that the script would refer to whole BLUFOR. Wouldn't that aswell be more simple to create if it would be about the whole BLUFOR or about any player literaly?

Is it possible to make this without a trigger while BLUFOR or even literaly anyone (if that would be easier) in an OPFOR vehicle for the OPFOR to not atack BLUFOR? So the script would refer to the whole BLUFOR team as them to become a CAPTIVE while inside an OPFOR vehicle or even anyone not only the blufor but anyone to become a captive while inside any OPFOR vehicle if that would be easier thing to do.

So it would look something like that:

If BLUFOR in OPFOR covered transport truck then BLUFOR is set to captive. - only inside vehicle

It's just that I dont know nothing about the script commands and im not good at it at all but for you guys it should be very simple thing to do am I right? Can someone tell me how to make that thing to work as I describe?

Is that even possible to make that kind of complicated script?

Thank you so much for your time.

ps. does anyone knows how many people can get in to that truck at once?

Edited by Mopsmaster

Share this post


Link to post
Share on other sites

Firstly, yes, it is possible.

But to be honest, if you don't know anything about scripting, you might wanna start with the very basics before you create a real mission. There is no point in basically writing the whole thing FOR you, which - since you said, you don't know anything about scripting - would be the case as you would probably not understand any code provided here and which is probably why nobody has replied yet.

The purpose of this forum is to help each other when someone is stuck at some part of his code or needs help when dealing with an unknown part of SQF. But you're better off watching these thousands of youtube tutorials and reading the BIKI on "how to SQF".

The good thing is that you've got a clear goal so you can work your way towards that (at least for me, having a goal is very boosting). It took me less than 4 months from knowing nothing about SQF to being able to help others in the forums with their SQF trouble. Having already dealt with any programming is beneficial of course, but you'll very quickly find your way into the very basics anyways.

Good luck and have fun

Johnny

Edited by Heeeere's Johnny!

Share this post


Link to post
Share on other sites

setCaptive

I would combine this command with a trigger, to keep things simple. In the condition of the trigger you would need to check if all your players are in the truck.

Hope that gets you started, feel free to ask if you have questions. The learning process of SQF scripting can be quite time consuming but also very rewarding. In my opinion the best way to learn how to SQF is by building a missions.

Share this post


Link to post
Share on other sites

If you want to check out some good tutorials, I learnt from these videos back in Arma 2. The guy (babyalien) explains it really well imo.

Share this post


Link to post
Share on other sites

Guys yea but im sure someone already asked about this , so you say there is no such script yet?

For me it sounds easy if you understand scripting it should be very easy for you i think it would just take 2 command lines so it would be something like:

if BLUEFOR in a OPFOR vehicle : (Zamar Ammo Truck id) then OPFOR is/= BLUFOR or then BLUFOR is/= Civilian or then BLUFOR is/= Invisible (but invisible is bad thing cuz i thing then AI's won't see the obstacle? or they won't see just BLUFOR people in the truck?) and that's it the end of the code. I would like to implement not by a trigger but for it to stay. That's all what i need i just dont know the commands... maybe it's just too easy so that's the reason nobody wanted to get involved hehe...

Anyone who know about command lines and want to tell me how this should sound in a sqm language please? and then tell me how to implement it to the game?

Can someone help? I know it's easy for you guys...

Share this post


Link to post
Share on other sites
I want to make a mission in which I would go with my team to an emy stronghold in a OPFOR Zamak Ammo truck

ps. does anyone knows how many people can get in to that truck at once?

You might want to pick another truck as it's only 3 people I think in the ammo truck. (Unless your team is three people or less).

Share this post


Link to post
Share on other sites

If you're using the ingame editor to create a mission, you could place an opfor truck of your choice on the map and put the following code into the init field:

this setVariable ["originalSide", side driver this];
deleteVehicle driver this;

That way, the truck will have a variable having side opfor as value. Directly after that, the driver will be deleted from the vehicle: "deleteVehicle driver this". If you don't want that, simply omit that line.

Finally, when you've placed a unit representing the player, you put the following code either into its init field in the ingame editor - or you put it into the init.sqf, which is a file that runs at first when your mission starts:

[color=#FF8040][color=#000000]player[/color] [color=#191970][b]addEventHandler[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"AnimChanged"[/color][color=#8B3E2F][b],[/b][/color] [color=#8B3E2F][b]{[/b][/color]
   [color=#1874CD]_animation[/color] [color=#8B3E2F][b]=[/b][/color] [color=#000000]_this[/color] [color=#191970][b]select[/b][/color] [color=#FF0000]1[/color][color=#8B3E2F][b];[/b][/color]
   [color=#191970][b]if[/b][/color][color=#8B3E2F][b]([/b][/color][color=#FF0000]-1[/color] [color=#8B3E2F][b]![/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#1874CD]_animation[/color] [color=#191970][b]find[/b][/color] [color=#7A7A7A]"driver"[/color] [color=#8B3E2F][b]|[/b][/color][color=#8B3E2F][b]|[/b][/color] [color=#FF0000]-1[/color] [color=#8B3E2F][b]![/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#1874CD]_animation[/color] [color=#191970][b]find[/b][/color] [color=#7A7A7A]"passenger"[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color]
   [color=#8B3E2F][b]{[/b][/color]
       [color=#191970][b]if[/b][/color][color=#8B3E2F][b]([/b][/color][color=#000000]opfor[/color] [color=#191970][b]isEqualTo[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#191970][b]vehicle[/b][/color] [color=#000000]player[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]getVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"originalSide"[/color][color=#8B3E2F][b],[/b][/color] [color=#000000]blufor[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color]
       [color=#8B3E2F][b]{[/b][/color]
           [color=#000000]player[/color] [color=#191970][b]setCaptive[/b][/color] [color=#000000]true[/color][color=#8B3E2F][b];[/b][/color]
       [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]
   [color=#8B3E2F][b]}[/b][/color]
   [color=#191970][b]else[/b][/color]
   [color=#8B3E2F][b]{[/b][/color]
       [color=#000000]player[/color] [color=#191970][b]setCaptive[/b][/color] [color=#000000]false[/color][color=#8B3E2F][b];[/b][/color]
   [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b];[/b][/color][/color]

EDIT:

Alright, attempt #2:

[color=#FF8040][color=#8B3E2F][b][[/b][/color][color=#8B3E2F][b]][/b][/color] [color=#191970][b]spawn[/b][/color]
[color=#8B3E2F][b]{[/b][/color]
   [color=#191970][b]while[/b][/color] [color=#8B3E2F][b]{[/b][/color][color=#191970][b]sleep[/b][/color] [color=#FF0000]3[/color][color=#8B3E2F][b];[/b][/color] [color=#000000]true[/color][color=#8B3E2F][b]}[/b][/color] [color=#191970][b]do[/b][/color]
   [color=#8B3E2F][b]{[/b][/color]
       [color=#191970][b]if[/b][/color][color=#8B3E2F][b]([/b][/color][color=#000000]opfor[/color] [color=#8B3E2F][b]=[/b][/color][color=#8B3E2F][b]=[/b][/color] [color=#8B3E2F][b]([/b][/color][color=#8B3E2F][b]([/b][/color][color=#191970][b]vehicle[/b][/color] [color=#000000]player[/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]getVariable[/b][/color] [color=#8B3E2F][b][[/b][/color][color=#7A7A7A]"originalSide"[/color][color=#8B3E2F][b],[/b][/color] [color=#000000]blufor[/color][color=#8B3E2F][b]][/b][/color][color=#8B3E2F][b])[/b][/color][color=#8B3E2F][b])[/b][/color] [color=#191970][b]then[/b][/color]
       [color=#8B3E2F][b]{[/b][/color][color=#8B3E2F][/color]
           [color=#000000]player[/color] [color=#191970][b]setCaptive[/b][/color] [color=#000000]true[/color][color=#8B3E2F][b];[/b][/color]
       [color=#8B3E2F][b]}[/b][/color]
       [color=#191970][b]else[/b][/color]
       [color=#8B3E2F][b]{[/b][/color][color=#8B3E2F][/color]
           [color=#000000]player[/color] [color=#191970][b]setCaptive[/b][/color] [color=#000000]false[/color][color=#8B3E2F][b];[/b][/color]
       [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]
   [color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color]
[color=#8B3E2F][b]}[/b][/color][color=#8B3E2F][b];[/b][/color][/color]

Kudos to Killzone_Kid for his SQF to BBCode Converter.

It's probably not the most decent solution, but it seems to do its job. What that does is, every 3 seconds it checks whether you're in a vehicle which has a variable named "originalSide" with the value opfor. Whenever that's the case, the player won't be attacked by any units. But as soon as you leave the vehicle, they'll start shooting.

Edited by Heeeere's Johnny!
another more general attempt

Share this post


Link to post
Share on other sites

So the AIs will not get the atention to me as on the enemy and they will not follow me or look at me, they will just treat me as one of thir OPFOR team as long as im in the truck right? They will still keep their waypoints and just move their way like the truck is theirs yea? If that's the case that's very good cuz that's what I needed exactly and yes I think I will pick another truck , the transport truck since the opfor ammo truck has only 3 places in it. That's a very good try Johny it's amazing that this can do the work, this will work yea?

@edit well it didn't work so here's what I did step by step.

1. I created init.sql in my C:\Users\user name\Documents\Arma 3 - Other Profiles\user name\mpmissions

3 I pasted it this into init sql file in the notepad:

[] spawn
{
   while {sleep 3; true} do
   {
       if(opfor == ((vehicle player) getVariable ["originalSide", blufor])) then
       {
           player setCaptive true;
       }
       else
       {
           player setCaptive false;
       };
   };
};

3. I saved it I opened the game with MCC I spawned the truck I tried to go to enemy but they were killing me still I also spawned BLUFOR soldier and the OPFOR AIS were still shooting at him and killing while in the CSAT trucks.

So it means it doesn't work or it's just me doing something wrong?

Edited by Mopsmaster

Share this post


Link to post
Share on other sites

I'd simply create a trigger with the following condition and code:

condition: player1 in TRUCKNAME && player 2 in TRUCKNAME && player3 in TRUCKNAME .......

on activation: {_x setCaptive true} forEach [player1,player2,player3,....]

on deactivation {_x setCaptive false} forEach [player1,player2,player3,....]

In order to make this work, you have to replace the "TRUCKNAME" with the actual name of your truck, and also name all players like: player1,player2,player3.....

Share this post


Link to post
Share on other sites

R3yo that wouldn't work since you neve know who is going to be on the server / and on the mission, Id like the one that would refer to every BLUFOR player. Wouldn't that aswell be more simple to create if it would be about the whole BLUFOR or about any player literaly?

Is it possible to make this without a trigger while BLUFOR or even literaly anyone (if that would be easier) in an OPFOR vehicle for the OPFOR to not atack BLUFOR? So the script would refer to the whole BLUFOR team as them to become a CAPTIVE while inside an OPFOR vehicle or even anyone not only the blufor but anyone to become a captive while inside any OPFOR vehicle if that would be easier thing to do.

So it would look something like that:

If BLUFOR in OPFOR covered transport truck then BLUFOR is set to captive.

It's just that I dont know nothing about the script commands and im not good at it at all but for you guys it should be very simple thing to do am I right? Can someone tell me how to make that thing to work as I describe?

Is that even possible to make that kind of complicated script?

Edited by Mopsmaster

Share this post


Link to post
Share on other sites

It's not really an easy task, at least I can't wrap my head around it right now (it's 37° Celsius here)

I've just worked out something really crude, which might now work at all. But maybe it gives others an idea how to make that work.

private ["_units","_vehicles","_vehicle"];

_units = playableUnits;
_vehicles = ["classname1","classname2"]; //all vehicle classes this script should work for

for "_i" from 0 to ((count _units) - 1) do
{
_vehicle = (vehicle (_units select _i));
if (_vehicle in _vehicles) then
{
	(_units select _i) setCaptive true;
}
else
{
	(_units select _i) setCaptive false;
};
};

Share this post


Link to post
Share on other sites

Wow it doesnt really seems to look easy at all let me paste to init file and see if it work thank you mate

Share this post


Link to post
Share on other sites
Wow it doesnt really seems to look easy at all let me paste to init file and see if it work thank you mate

It won't work, it would need to be combinded with loop of some sort. Also you would fill the array _vehicles with proper classnames.

Share this post


Link to post
Share on other sites

No need for loops, player checks and whatnot, a simple eventhandler might do it.

Just replace truck with the name of your vehicle or put it inside the script you spawn the vehicle with.

_captivecheck = truck addeventhandler ["GetIn",{

if (side (_this select 2) isequalto blufor) then {

	(_this select 2) setcaptive true;hint "captive"};
}

];


_nocaptivecheck = truck addeventhandler ["GetOut",{

if (captive (_this select 2)) then {

	(_this select 2) setcaptive false;hint "not captive"};

}

];

Cheers

Share this post


Link to post
Share on other sites

my god it will really work ? DAMN!!!!!!!!!!!!!!!!!!!! MAN IF IT WORKS I F**ING LOVE YOU!!!!!

This will work for all my blufor team when we get into truck and sneak out trough enemy territory in their truck right? Its awesome! Let me check if its working

Edited by Mopsmaster

Share this post


Link to post
Share on other sites
No need for loops, player checks and whatnot, a simple eventhandler might do it.

Just replace truck with the name of your vehicle or put it inside the script you spawn the vehicle with.

_captivecheck = truck addeventhandler ["GetIn",{

   if (side (_this select 2) isequalto blufor) then {

       (_this select 2) setcaptive true;hint "captive"};
   }

];


_nocaptivecheck = truck addeventhandler ["GetOut",{

   if (captive (_this select 2)) then {

       (_this select 2) setcaptive false;hint "not captive"};

   }

];

Cheers

Didn't know there was only one specific vehicle to be dealt with which is why my approach was regardless of any specific vehicle, hence the loop.

Share this post


Link to post
Share on other sites

It didn't work for me :'( I have no idea why... Here's exactly what I did step by step:

1. I pasted the code into the C:\Users\Gray Fox\Documents\Arma 3 - Other Profiles\Trachu\mpmissions\init.sqf

2. So my file looks like this

_captivecheck = Zamak Transport (Covered) addeventhandler ["GetIn",{

   if (side (_this select 2) isequalto blufor) then {

       (_this select 2) setcaptive true;hint "captive"};
   }

];


_nocaptivecheck = Zamak Transport (Covered) addeventhandler ["GetOut",{

   if (captive (_this select 2)) then {

       (_this select 2) setcaptive false;hint "not captive"};

   }

];  

3. Opened the game clicked editor chose altis then

4. I loaded my mission in the MCC

5. Spawned Zamak Transport (Covered)

6. Killed OPFOR driver inside

7. Got inside (aswell tried puting ai blufor soldier inside the truck)

8. I drived the truck near OPFOR soldiers and the soldiers just opened fire and killed me

When I was entering the truck the blue sign for me didn't changed to purple for me so that would indicate im a captive but it didn't I was still BLUFOR.

Please help me I must be me doing something wrong maybe I cannot load init.sqf file properly?

Or it's that it doesn't work? Could you guys check?

Edited by Mopsmaster

Share this post


Link to post
Share on other sites

This:

_captivecheck = Zamak Transport (Covered) addEventHandler [...

won't work. You need to give your vehicle a name to address it in your script. If you use the ingame editor to place one on the map, double click it, there is a "name" field on the top right of the upcoming screen.

If you created the vehicle by using "createVehicle", you need to assign the statement to a variable like so:

_truck = createVehicle ["O_Truck_02_covered_F", getPosATL player, [], 0, "NONE"];

"O_Truck_02_covered_F" is the class name for the Zamak Transport (Covered). You always need the class name of an object to create it. You can find all the class names here:

https://community.bistudio.com/wiki/Arma_3_Assets

So, assuming you used the ingame editor and gave your Zamak the name "zamak", then your event handler has to look like this:

_captivecheck = zamak addEventHandler ["GetIn", {
   if (side (_this select 2) isEqualTo blufor) then {
       (_this select 2) setCaptive true;
       hint "captive";
   };
}];

Edited by Heeeere's Johnny!

Share this post


Link to post
Share on other sites

Cuz im using MCC when i place the truck I dont want to use ingame editor can't I just make all Zamak Transport (Covered) trucks to be like this? Every of them

So If I dont want give a name to my truck can I just use the default name for it and it will work?

like for example:

_captivecheck = O_Truck_02_covered_F addEventHandler ["GetIn", {
   if (side (_this select 2) isEqualTo blufor) then {
       (_this select 2) setCaptive true;
       hint "captive";
   };
}];  

Will it work ?

Edited by Mopsmaster

Share this post


Link to post
Share on other sites

The problem is that if you create objects on the fly, like you do, you have no reference to the object. All there is is a Zamak and a script, but they don't know each other. So either, you manage to give the Zamak a name (as explained) or you do the creation and addEventHandler in one step / in one script. But you can't do it like you seemingly try to.

Share this post


Link to post
Share on other sites

Yes Id like to do it with one step and in one script by addeventhandler i dont get what it is but its ok as long as I dont have to give a name to an object cuz I want to use it while I just load mission in the MCC and not in the editor so I dont want to mess with Editor I just use mcc and zeus to spawn the truck and I want the script to load automaticaly when opening the map but without doing anything in editor

Share this post


Link to post
Share on other sites

Why so anxious about the editor? It's designed especially for people who are not familiar with SQF. And it's really not hard to get into it, because you can basically do everything by clicking.

Share this post


Link to post
Share on other sites

Because Im not the server host and maybe I can manage to let my server boss agree to load one script but im sure no more files cuz he just won't agree and I want my server team to play the mission I've created. Script file will be ok to give him maybe he will agree but he will not mess with the editor for sure and I want my mission to be go. Also I just want to load everything by just one simple click in the end.

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  

×