Forum Jump :

Author Message


Posts: 4
Rank:


Level: Member

Country: it
Location:
Occupation:
Age:
In-game name:

 
#1 Posted at 2016-03-27 01:00        
     
Hello everyone,

I'm trying to write a script to disguise the player on a mission.
In essence, wearing the right uniform set the player setCaptive true and when it will change the uniform the setCaptive return false.

Just started the script everything works properly, in fact the OPFOR do not attack me, but when i change the uniform nothing happens.

To do this I used the IF function but it seems that when i change uniform IF function donot update the variation of equipment and therefore do not change setCaptive to false.

I leave the code and a video on youtube that shows more clearly what happens.

Thank you.
if (uniforme == "U_B_HeliPilotCoveralls") then
{
    hint "Using enemy uniform";
    sold setCaptive true;
}
else
{
    Hint "You are not using enemy uniform";
    sold setCaptive false;
};

Video


Author Message


Posts: 6
Rank:


Level: Member

Country: de
Location:
Occupation:
Age:
In-game name:

 
#2 Posted at 2016-03-27 01:20        
     
Im not sure if it will work, but you can try

while {true} do
{
    waitUntil{alive player};
    if (uniforme == "U_B_HeliPilotCoveralls") then
    {
        hint "Using enemy uniform";
        sold setCaptive true;
    }
    else
    {
        Hint "You are not using enemy uniform";
        sold setCaptive false;
    };
    waitUntil{!alive player};
};


Advertisement


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#3 Posted at 2016-03-27 02:20        
     
# H3xag0n : Im not sure if it will work, but you can try

while {true} do
{
    waitUntil{alive player};
    if (uniforme == "U_B_HeliPilotCoveralls") then
    {
        hint "Using enemy uniform";
        sold setCaptive true;
    }
    else
    {
        Hint "You are not using enemy uniform";
        sold setCaptive false;
    };
    waitUntil{!alive player};
};

That will not work, as you will check the uniform once, then wait until the player is dead, it will not continually check if the uniform has changed until after the player has died and respawned.

Take a look at this thread, you should be able to work it into your needs:

https://forums.bistudio.com/topic/180281-yet-another-player-undercover-as-civ-scripting/#entry2840776

https://forums.bistudio.com/topic/179144-script-help-enemies-ignore-players-based-on-uniform/#entry2817924

This post was edited by JShock (2016-03-27 02:46, 573 days ago)

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Author Message


Posts: 4
Rank:


Level: Member

Country: it
Location:
Occupation:
Age:
In-game name:

 
#4 Posted at 2016-03-27 08:51        
     
Thank you for your quick response!

By following the second link you gave me I found the code I needed.

player addEventHandler
[
	"InventoryClosed",
	{
		if (uniform (_this select 0) isEqualTo "U_B_HeliPilotCoveralls") then
		{
			(_this select 0) setCaptive true;
		}
		else
		{
			(_this select 0) setCaptive false;
		};
	}
];

This script makes it possible for the mission to monitor the equipment every time I close the inventory.

I think it's the best way.


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#5 Posted at 2016-03-27 09:33        
     
Alternatively you could use this code too.

player addEventHandler ["InventoryClosed", {
    player setCaptive (uniform player == "U_B_HeliPilotCoveralls");
}];

There is usually no need for an if else when it looks like this:
if (CONDITION) then {
    //Do a single line thing
} else {
    //Do a single line opposite thing
};

This post was edited by 654wak654 (2016-03-27 10:01, 572 days ago)

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#6 Posted at 2016-03-27 16:56        
     
I'm on it for my new mission but the hardest thing to do is to enable civilian clothes for a blufor. I don't know why BI doesn't allow this possibility! You can fire all weapons you want (by default) but you can't dress as you want.
Something at the opposite of the common sense!

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 4
Rank:


Level: Member

Country: it
Location:
Occupation:
Age:
In-game name:

 
#7 Posted at 2016-03-27 17:47        
     
Time ago all factions units was enable to take directly from enemy bodies without problems.

So actually the script work perfectly, i add another string but have an problem, if i shoot at 500km from the enemy setCaptive will set False.

sold addEventHandler ["fired", {player setCaptive false}];

I have read about the FiredNear function but i really don't know how use it.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#8 Posted at 2016-03-27 19:34        
     
FiredNear fires very close (69 m) but it's a common event handler.

It's amazing, we are working on the same behavior! captive with (civilian) uniforms then not when firing!

player addEventHandler ["fired", {
 {
  if ( player == (_this select 0) && (_x distance player < 200)) exitWith {player setCaptive false}} forEach (allUnits select {side _x == EAST})
}];

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 4
Rank:


Level: Member

Country: it
Location:
Occupation:
Age:
In-game name:

 
#9 Posted at 2016-03-28 18:32        
     
# Pierre MGI : FiredNear fires very close (69 m) but it's a common event handler.

It's amazing, we are working on the same behavior! captive with (civilian) uniforms then not when firing!

player addEventHandler ["fired", {
 {
  if ( player == (_this select 0) && (_x distance player < 200)) exitWith {player setCaptive false}} forEach (allUnits select {side _x == EAST})
}];

With this if i shoot in 200m radius setCaptive become false?

Another problem is when the Captive state become false, for example:

When i shoot my setCaptive become false, but if i open and close the inventory the Captive state return True even if any enemy shoot me


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#10 Posted at 2016-03-28 19:17        
     
You'll need an "override" variable reference in one of the two event handlers to handle each case seperately, I'm on my phone so I can't help wholefully.

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#11 Posted at 2016-03-28 20:26        
     
I have an untested script for both cases, execVM it from your init.sqf (or initPlayerLocal.sqf) as usual.

playerFired = false;
player addEventHandler ["Fired", {
    {
        if (_x distance player < 500) exitWith {playerFired = true};
    } forEach (allUnits select {side _x == east});
}];
while {true} do {
    if (playerFired || uniform player != "U_B_HeliPilotCoveralls") then {
        player setCaptive false;
        waitUntil {sleep 1; east knowsAbout player < 2};
        playerFired = false;
    };
    player setCaptive (uniform player == "U_B_HeliPilotCoveralls");
    sleep 1;
};

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage